]> rtime.felk.cvut.cz Git - lincan.git/blob - lincan/include/can.h
LinCAN driver major structured comments and documentation update
[lincan.git] / lincan / include / can.h
1 #ifndef _CANMSG_T_H
2 #define _CANMSG_T_H
3
4 #include <linux/types.h>
5 #include <linux/ioctl.h>
6
7 #ifndef PACKED
8 #define PACKED __attribute__((packed))
9 #endif
10
11 #define CAN_MSG_LENGTH 8
12
13 /**
14  * struct canmsg_t - structure representing CAN message
15  * @flags:  message flags, %MSG_RTR .. message is Remote Transmission Request,
16  *      %MSG_EXT .. message with extended ID, %MSG_OVR indication of queue
17  *      overflow condition
18  * @cob:    communication object number (not used)
19  * @id:     ID of CAN message
20  * @timestamp: not used
21  * @length: length of used data
22  * @data:   data bytes buffer
23  *
24  * Header: can.h
25  */
26 struct canmsg_t {
27         short           flags;
28         int             cob;
29         unsigned long   id;
30         unsigned long   timestamp;
31         unsigned int    length;
32         unsigned char   data[CAN_MSG_LENGTH];
33 } PACKED;
34
35 struct canfilt_t {
36         int             flags;
37         int             cob;
38         unsigned long   id;
39         unsigned long   mask;
40 };
41
42 /* Definitions to use for canmsg_t flags */
43 #define MSG_RTR (1<<0)
44 #define MSG_OVR (1<<1)
45 #define MSG_EXT (1<<2)
46
47 /* CAN ioctl magic number */
48 #define CAN_IOC_MAGIC 'd'
49
50 typedef unsigned long bittiming_t;
51 typedef unsigned short channel_t;
52
53 /* CAN ioctl functions */
54 #define CMD_START _IOW(CAN_IOC_MAGIC, 1, channel_t)
55 #define CMD_STOP _IOW(CAN_IOC_MAGIC, 2, channel_t)
56 //#define CMD_RESET 3
57
58 #define CONF_BAUD _IOW(CAN_IOC_MAGIC, 4, bittiming_t)
59 //#define CONF_ACCM
60 //#define CONF_XTDACCM
61 //#define CONF_TIMING
62 //#define CONF_OMODE
63 #define CONF_FILTER _IOW(CAN_IOC_MAGIC, 8, unsigned char)
64
65 //#define CONF_FENABLE
66 //#define CONF_FDISABLE
67
68 #define STAT _IO(CAN_IOC_MAGIC, 9)
69 #define CONF_FILTER_QUE0 _IOW(CAN_IOC_MAGIC, 10, struct canfilt_t)
70
71 #endif /*_CANMSG_T_H*/