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 0x0304
00039
00040 #ifndef __KERNEL__
00041 #include <sys/time.h>
00042 #endif
00043
00044
00045 #define CAN_MSG_LENGTH 8
00048 #define MSG_RTR (1<<0)
00049 #define MSG_OVR (1<<1)
00050 #define MSG_EXT (1<<2)
00051 #define MSG_SELF (1<<3)
00052 #define MSG_PASSIVE (1<<4)
00053 #define MSG_BUSOFF (1<<5)
00054 #define MSG_ (1<<6)
00055 #define MSG_BOVR (1<<7)
00059 #define MSG_ERR_MASK (MSG_OVR + MSG_PASSIVE + MSG_BUSOFF + MSG_BOVR)
00060
00066 typedef struct {
00068 int flags;
00069 int cob;
00070 unsigned long id;
00071 struct timeval timestamp;
00072 short int length;
00073 unsigned char data[CAN_MSG_LENGTH];
00074 } canmsg_t;
00075
00076
00077
00080
00081 #define CAN4L_IOC_MAGIC 'c'
00082
00083 #define CAN_IOCTL_COMMAND 0
00084 #define CAN_IOCTL_CONFIG 1
00085 #define CAN_IOCTL_SEND 2
00086 #define CAN_IOCTL_RECEIVE 3
00087 #define CAN_IOCTL_CONFIGURERTR 4
00088 #define CAN_IOCTL_STATUS 5
00090
00091
00093 struct Command_par {
00094 int cmd;
00095 int target;
00096 unsigned long val1;
00097 unsigned long val2;
00098 int error;
00099 unsigned long retval;
00100 };
00101
00102
00105 typedef struct Command_par Command_par_t ;
00108 typedef struct Command_par Config_par_t ;
00113 typedef struct CanStatusPar {
00114 unsigned int baud;
00115 unsigned int status;
00116 unsigned int error_warning_limit;
00117 unsigned int rx_errors;
00118 unsigned int tx_errors;
00119 unsigned int error_code;
00120 unsigned int rx_buffer_size;
00121 unsigned int rx_buffer_used;
00122 unsigned int tx_buffer_size;
00123 unsigned int tx_buffer_used;
00124 unsigned long retval;
00125 unsigned int type;
00126 } CanStatusPar_t;
00127
00130 #define CAN_TYPE_UNSPEC 0
00131 #define CAN_TYPE_SJA1000 1
00132 #define CAN_TYPE_FlexCAN 2
00133 #define CAN_TYPE_TouCAN 3
00134 #define CAN_TYPE_82527 4
00135 #define CAN_TYPE_TwinCAN 5
00136 #define CAN_TYPE_BlackFinCAN 6
00137
00138
00141 typedef struct Send_par {
00142 canmsg_t *Tx;
00143 int error;
00144 unsigned long retval;
00145 } Send_par_t ;
00146
00149 typedef struct Receive_par {
00150 canmsg_t *Rx;
00151 int error;
00152 unsigned long retval;
00153 } Receive_par_t ;
00154
00157 typedef struct ConfigureRTR_par {
00158 unsigned message;
00159 canmsg_t *Tx;
00160 int error;
00161 unsigned long retval;
00162 } ConfigureRTR_par_t ;
00163
00167 # define CMD_START 1
00168 # define CMD_STOP 2
00169 # define CMD_RESET 3
00170 # define CMD_CLEARBUFFERS 4
00171
00172
00173
00174
00178 # define CONF_ACC 0
00179 # define CONF_ACCM 1
00180 # define CONF_ACCC 2
00181 # define CONF_TIMING 3
00182 # define CONF_OMODE 4
00183 # define CONF_FILTER 5
00184 # define CONF_FENABLE 6
00185 # define CONF_FDISABLE 7
00186 # define CONF_LISTEN_ONLY_MODE 8
00187 # define CONF_SELF_RECEPTION 9
00188 # define CONF_BTR 10
00189
00190 # define CONF_TIMESTAMP 11
00191 # define CONF_WAKEUP 12
00192
00193 #endif