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