00001
00041 #ifndef CAN_H
00042 #define CAN_H
00043
00044 #include <linux/ioctl.h>
00045
00046
00047
00048
00055 #define SAVE_TIMESTAMP
00056
00058 #define CAN_MAGIC 'z'
00059
00065 #define MAJOR_NUM 100
00066
00068
00069
00070
00085 #define IOCTL_SET_MSG _IOR(MAJOR_NUM, 0, char *)
00086
00098 #define IOCTL_GET_MSG _IOR(MAJOR_NUM, 1, char *)
00099
00111 #define IOCTL_GET_NTH_BYTE _IOWR(MAJOR_NUM, 2, int)
00112
00115
00116
00117
00124 #define CAN_NORMAL_MODE 0
00125
00127 #define CAN_SLEEP_MODE 1
00128
00130 #define CAN_LOOPBACK_MODE 2
00131
00133 #define CAN_LISTEN_MODE 3
00134
00136 #define CAN_CONFIG_MODE 4
00137
00139
00140
00141
00169 #define CAN_IOC_BAUDRATE _IOW(CAN_MAGIC, 0x80, unsigned long)
00170
00179 #define CAN_IOC_SAMPLE _IOW(CAN_MAGIC, 0x81, unsigned char)
00180
00191 #define CAN_IOC_MODE _IOW(CAN_MAGIC, 0x82, unsigned char)
00192
00197 #define CAN_IOC_STATUS _IO(CAN_MAGIC, 0x83)
00198
00203 #define CAN_IOC_RESET _IO(CAN_MAGIC, 0x84)
00204
00209 #define CAN_IOC_INT _IO(CAN_MAGIC, 0x85)
00210
00217 #define CAN_IOC_REG _IOW(CAN_MAGIC, 0x86, unsigned char)
00218
00225 #define CAN_IOC_FILTER _IOW(CAN_MAGIC, 0x87, struct mcp2515_filter_t *)
00226
00232 #define CAN_IOC_GET_FILTER _IOR(CAN_MAGIC, 0x88, struct mcp2515_filter_t *)
00233
00239 #define CAN_IOC_SET_REG _IOW(CAN_MAGIC, 0x89, struct reg_t *)
00240
00248 #define CAN_IOC_TXQUEUE_FULL _IO(CAN_MAGIC, 0x8A)
00249
00255 #define CAN_IOC_RXQUEUE_SIZE _IO(CAN_MAGIC, 0x8B)
00256
00263 #define CAN_IOC_SET_RETRY _IOW(CAN_MAGIC, 0x8E, unsigned long)
00264
00270 #define CAN_IOC_GET_TX_ERR _IO(CAN_MAGIC, 0x8F)
00271
00277 #define CAN_IOC_GET_TX_OK _IO(CAN_MAGIC, 0x90)
00278
00284 #define CAN_IOC_GET_RX_ERR _IO(CAN_MAGIC, 0x91)
00285
00291 #define CAN_IOC_GET_RX_OK _IO(CAN_MAGIC, 0x92)
00292
00298 #define CAN_IOC_GET_BUS_OFF_ERR _IO(CAN_MAGIC, 0x93)
00299
00303
00304
00305
00312 struct reg_t
00313 {
00314 unsigned long addr;
00315 unsigned long value;
00316 };
00317
00320 struct msg_t
00321 {
00322 unsigned long ident;
00324 unsigned long eident;
00326 int data_length;
00327 unsigned char data[8];
00328 unsigned char bits;
00340 #ifdef SAVE_TIMESTAMP
00341 unsigned long rx_time;
00342 #endif
00343 };
00348 #define CANMSG_SET_EID(eid,p_canmsg) {p_canmsg->ident = (eid >> 18) & 0x7FF; p_canmsg->eident = eid & 0x3FFFF; p_canmsg->bits |= 0x1;}
00349
00353 #define CANMSG_SET_ID(id,p_canmsg) {p_canmsg->ident = id & 0x7FF; p_canmsg->bits &= 0xFE;}
00354
00377 struct mcp2515_filter_t
00378 {
00389 unsigned char rollover;
00390
00397 unsigned char filter_mode[2];
00398
00399
00400 unsigned long mask_sid[2];
00401 unsigned long mask_eid[2];
00409 unsigned char filter_frame[6];
00410
00411 unsigned long filter_sid[6];
00412 unsigned long filter_eid[6];
00415 };
00418 #endif
00419