00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00034 #ifndef __CAN_H
00035 #define __CAN_H
00036
00037
00038 # define CAN4LINUXVERSION 0x0305
00039
00040 #ifndef __KERNEL__
00041 #include <sys/time.h>
00042 #endif
00043
00044
00045 #define CAN_MSG_LENGTH 8
00048 #define MSG_ACTIVE (0)
00049 #define MSG_BASE (0)
00050 #define MSG_RTR (1<<0)
00051 #define MSG_OVR (1<<1)
00052 #define MSG_EXT (1<<2)
00053 #define MSG_SELF (1<<3)
00054 #define MSG_PASSIVE (1<<4)
00055 #define MSG_BUSOFF (1<<5)
00056 #define MSG_WARNING (1<<6)
00057 #define MSG_BOVR (1<<7)
00061 #define MSG_ERR_MASK (MSG_OVR+MSG_PASSIVE+MSG_BUSOFF+MSG_BOVR+MSG_WARNING)
00062
00063
00064
00065 #define CAN_SFF_MASK 0x000007FFU
00066 #define CAN_EFF_MASK 0x1FFFFFFFU
00067 #define CANDRIVERERROR 0xFFFFFFFFul
00068
00074 typedef struct {
00076 int flags;
00077 int cob;
00078 unsigned long id;
00079 struct timeval timestamp;
00080 short int length;
00081 unsigned char data[CAN_MSG_LENGTH];
00082 } canmsg_t;
00083
00084
00085
00088
00089 #define CAN4L_IOC_MAGIC 'c'
00090
00091 #define CAN_IOCTL_COMMAND 0
00092 #define CAN_IOCTL_CONFIG 1
00093 #define CAN_IOCTL_SEND 2
00094 #define CAN_IOCTL_CONFIGURERTR 4
00095 #define CAN_IOCTL_STATUS 5
00097
00098
00100 struct Command_par {
00101 int cmd;
00102 int target;
00103 unsigned long val1;
00104 unsigned long val2;
00105 int error;
00106 unsigned long retval;
00107 };
00108
00109
00112 typedef struct Command_par Command_par_t ;
00115 typedef struct Command_par Config_par_t ;
00120 typedef struct CanStatusPar {
00121 unsigned int baud;
00122 unsigned int status;
00123 unsigned int error_warning_limit;
00124 unsigned int rx_errors;
00125 unsigned int tx_errors;
00126 unsigned int error_code;
00127 unsigned int rx_buffer_size;
00128 unsigned int rx_buffer_used;
00129 unsigned int tx_buffer_size;
00130 unsigned int tx_buffer_used;
00131 unsigned long retval;
00132 unsigned int type;
00133 } CanStatusPar_t;
00134
00137 #define CAN_TYPE_UNSPEC 0
00138 #define CAN_TYPE_SJA1000 1
00139 #define CAN_TYPE_FlexCAN 2
00140 #define CAN_TYPE_TouCAN 3
00141 #define CAN_TYPE_82527 4
00142 #define CAN_TYPE_TwinCAN 5
00143 #define CAN_TYPE_BlackFinCAN 6
00144 #define CAN_TYPE_AT91SAM9263 7
00145 #define CAN_TYPE_MCP2515 8
00146
00147
00150 typedef struct Send_par {
00151 canmsg_t *Tx;
00152 int error;
00153 unsigned long retval;
00154 } Send_par_t ;
00155
00158 typedef struct Receive_par {
00159 canmsg_t *Rx;
00160 int error;
00161 unsigned long retval;
00162 } Receive_par_t ;
00163
00166 typedef struct ConfigureRTR_par {
00167 unsigned message;
00168 canmsg_t *Tx;
00169 int error;
00170 unsigned long retval;
00171 } ConfigureRTR_par_t ;
00172
00176 # define CMD_START 1
00177 # define CMD_STOP 2
00178 # define CMD_RESET 3
00179 # define CMD_CLEARBUFFERS 4
00180
00181
00182
00183
00187 # define CONF_ACC 0
00188 # define CONF_ACCM 1
00189 # define CONF_ACCC 2
00190 # define CONF_TIMING 3
00191 # define CONF_OMODE 4
00192 # define CONF_FILTER 5
00193 # define CONF_FENABLE 6
00194 # define CONF_FDISABLE 7
00195 # define CONF_LISTEN_ONLY_MODE 8
00196 # define CONF_SELF_RECEPTION 9
00197 # define CONF_BTR 10
00198
00199 # define CONF_TIMESTAMP 11
00200 # define CONF_WAKEUP 12
00201
00202 # define CONF_ACC1 100
00203 # define CONF_ACC2 101
00204 # define CONF_ACC3 102
00205 # define CONF_ACC4 103
00206 # define CONF_ACC5 104
00207 # define CONF_ACC6 105
00208 # define CONF_ACC7 106
00209
00210 #endif