]> rtime.felk.cvut.cz Git - lincan.git/blob - lincan/include/can.h
Added prefix sja to all sjaXX_YY register bit-fields definitions.
[lincan.git] / lincan / include / can.h
1 #ifndef _CAN_DRVAPI_T_H
2 #define _CAN_DRVAPI_T_H
3
4 #ifdef __KERNEL__
5
6 #include <linux/time.h>
7 #include <linux/types.h>
8 #include <linux/ioctl.h>
9
10 #else /* __KERNEL__ */
11
12 #include <sys/time.h>
13 #include <sys/types.h>
14 #include <sys/ioctl.h>
15
16 #endif /* __KERNEL__ */
17
18 #include "./canmsg.h"
19
20 #ifdef __cplusplus
21 extern "C" {
22 #endif
23
24 /* CAN ioctl magic number */
25 #define CAN_IOC_MAGIC 'd'
26
27 typedef unsigned long bittiming_t;
28 typedef unsigned short channel_t;
29
30 /**
31  * struct can_baudparams_t - datatype for calling CONF_BAUDPARAMS IOCTL 
32  * @flags: reserved for additional flags for chip configuration, should be written -1 or 0
33  * @baudrate: baud rate in Hz
34  * @sjw: synchronization jump width (0-3) prescaled clock cycles
35  * @sampl_pt: sample point in % (0-100) sets (TSEG1+1)/(TSEG1+TSEG2+2) ratio
36  * 
37  * The structure is used to configure new set of parameters into CAN controller chip.
38  * If default value of some field should be preserved, fill field by value -1.
39  */
40 struct can_baudparams_t {
41         long flags;
42         long baudrate;
43         long sjw;
44         long sample_pt;
45 };
46
47 /* CAN ioctl functions */
48 #define CAN_DRV_QUERY _IO(CAN_IOC_MAGIC, 0)
49 #define CAN_DRV_QRY_BRANCH    0 /* returns driver branch value - "LINC" for LinCAN driver */
50 #define CAN_DRV_QRY_VERSION   1 /* returns driver version as (major<<16) | (minor<<8) | patch */
51 #define CAN_DRV_QRY_MSGFORMAT 2 /* format of canmsg_t structure */
52
53 #define CMD_START _IOW(CAN_IOC_MAGIC, 1, channel_t)
54 #define CMD_STOP _IOW(CAN_IOC_MAGIC, 2, channel_t)
55 //#define CMD_RESET 3
56
57 #define CONF_BAUD _IOW(CAN_IOC_MAGIC, 4, bittiming_t)
58 //#define CONF_ACCM
59 //#define CONF_XTDACCM
60 //#define CONF_TIMING
61 //#define CONF_OMODE
62 #define CONF_FILTER _IOW(CAN_IOC_MAGIC, 8, unsigned char)
63
64 //#define CONF_FENABLE
65 //#define CONF_FDISABLE
66
67 #define STAT _IO(CAN_IOC_MAGIC, 9)
68 #define CANQUE_FILTER _IOW(CAN_IOC_MAGIC, 10, struct canfilt_t)
69 #define CANQUE_FLUSH  _IO(CAN_IOC_MAGIC, 11)
70 #define CONF_BAUDPARAMS  _IOW(CAN_IOC_MAGIC, 11, struct can_baudparams_t)
71
72 #ifdef __cplusplus
73 } /* extern "C"*/
74 #endif
75
76 #endif /*_CAN_DRVAPI_T_H*/