]> rtime.felk.cvut.cz Git - lincan.git/blob - lincan/include/can.h
LinCAN sources go through big white-space cleanup.
[lincan.git] / lincan / include / can.h
1 /**************************************************************************/
2 /* File: can.h - CAN driver IOCTL and messages interface                  */
3 /*                                                                        */
4 /* LinCAN - (Not only) Linux CAN bus driver                               */
5 /* Copyright (C) 2002-2009 DCE FEE CTU Prague <http://dce.felk.cvut.cz>   */
6 /* Copyright (C) 2002-2009 Pavel Pisa <pisa@cmp.felk.cvut.cz>             */
7 /* Funded by OCERA and FRESCOR IST projects                               */
8 /* Based on CAN driver code by Arnaud Westenberg <arnaud@wanadoo.nl>      */
9 /*                                                                        */
10 /* LinCAN is free software; you can redistribute it and/or modify it      */
11 /* under terms of the GNU General Public License as published by the      */
12 /* Free Software Foundation; either version 2, or (at your option) any    */
13 /* later version.  LinCAN is distributed in the hope that it will be      */
14 /* useful, but WITHOUT ANY WARRANTY; without even the implied warranty    */
15 /* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU    */
16 /* General Public License for more details. You should have received a    */
17 /* copy of the GNU General Public License along with LinCAN; see file     */
18 /* COPYING. If not, write to the Free Software Foundation, 675 Mass Ave,  */
19 /* Cambridge, MA 02139, USA.                                              */
20 /*                                                                        */
21 /* To allow use of LinCAN in the compact embedded systems firmware        */
22 /* and RT-executives (RTEMS for example), main authors agree with next    */
23 /* special exception:                                                     */
24 /*                                                                        */
25 /* Including LinCAN header files in a file, instantiating LinCAN generics */
26 /* or templates, or linking other files with LinCAN objects to produce    */
27 /* an application image/executable, does not by itself cause the          */
28 /* resulting application image/executable to be covered by                */
29 /* the GNU General Public License.                                        */
30 /* This exception does not however invalidate any other reasons           */
31 /* why the executable file might be covered by the GNU Public License.    */
32 /* Publication of enhanced or derived LinCAN files is required although.  */
33 /**************************************************************************/
34
35 #ifndef _CAN_DRVAPI_T_H
36 #define _CAN_DRVAPI_T_H
37
38 #ifdef __KERNEL__
39
40 #include <linux/time.h>
41 #include <linux/types.h>
42 #include <linux/ioctl.h>
43
44 #else /* __KERNEL__ */
45
46 #include <inttypes.h>
47 #include <sys/time.h>
48 #include <sys/types.h>
49 #include <sys/ioctl.h>
50
51 #endif /* __KERNEL__ */
52
53 #include "./canmsg.h"
54
55 #ifdef __cplusplus
56 extern "C" {
57 #endif
58
59 /* CAN ioctl magic number */
60 #define CAN_IOC_MAGIC 'd'
61
62 typedef unsigned long bittiming_t;
63 typedef unsigned short channel_t;
64
65 /**
66  * struct can_baudparams_t - datatype for calling CONF_BAUDPARAMS IOCTL
67  * @flags: reserved for additional flags for chip configuration, should be written -1 or 0
68  * @baudrate: baud rate in Hz
69  * @sjw: synchronization jump width (0-3) prescaled clock cycles
70  * @sampl_pt: sample point in % (0-100) sets (TSEG1+1)/(TSEG1+TSEG2+2) ratio
71  *
72  * The structure is used to configure new set of parameters into CAN controller chip.
73  * If default value of some field should be preserved, fill field by value -1.
74  */
75 struct can_baudparams_t {
76         long flags;
77         long baudrate;
78         long sjw;
79         long sample_pt;
80 };
81
82 /* CAN ioctl functions */
83 #define CAN_DRV_QUERY _IO(CAN_IOC_MAGIC, 0)
84 #define CAN_DRV_QRY_BRANCH    0 /* returns driver branch value - "LINC" for LinCAN driver */
85 #define CAN_DRV_QRY_VERSION   1 /* returns driver version as (major<<16) | (minor<<8) | patch */
86 #define CAN_DRV_QRY_MSGFORMAT 2 /* format of canmsg_t structure */
87
88 #define CMD_START _IOW(CAN_IOC_MAGIC, 1, channel_t)
89 #define CMD_STOP _IOW(CAN_IOC_MAGIC, 2, channel_t)
90 //#define CMD_RESET 3
91
92 #define CONF_BAUD _IOW(CAN_IOC_MAGIC, 4, bittiming_t)
93 //#define CONF_ACCM
94 //#define CONF_XTDACCM
95 //#define CONF_TIMING
96 //#define CONF_OMODE
97 #define CONF_FILTER _IOW(CAN_IOC_MAGIC, 8, unsigned char)
98
99 //#define CONF_FENABLE
100 //#define CONF_FDISABLE
101
102 #define STAT _IO(CAN_IOC_MAGIC, 9)
103 #define CANQUE_FILTER _IOW(CAN_IOC_MAGIC, 10, struct canfilt_t)
104 #define CANQUE_FLUSH  _IO(CAN_IOC_MAGIC, 11)
105 #define CONF_BAUDPARAMS  _IOW(CAN_IOC_MAGIC, 11, struct can_baudparams_t)
106 #define CANRTR_READ  _IOWR(CAN_IOC_MAGIC, 12, struct canmsg_t)
107
108 #ifdef __cplusplus
109 } /* extern "C"*/
110 #endif
111
112 #endif /*_CAN_DRVAPI_T_H*/