1 /**************************************************************************/
2 /* File: can.h - CAN driver IOCTL and messages interface */
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> */
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. */
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: */
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 /**************************************************************************/
35 #ifndef _CAN_DRVAPI_T_H
36 #define _CAN_DRVAPI_T_H
40 #include <linux/time.h>
41 #include <linux/types.h>
42 #include <linux/ioctl.h>
44 #else /* __KERNEL__ */
48 #include <sys/types.h>
49 #include <sys/ioctl.h>
51 #endif /* __KERNEL__ */
59 /* CAN ioctl magic number */
60 #define CAN_IOC_MAGIC 'd'
62 typedef unsigned long bittiming_t;
63 typedef unsigned short channel_t;
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
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.
75 struct can_baudparams_t {
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 */
88 #define CMD_START _IOW(CAN_IOC_MAGIC, 1, channel_t)
89 #define CMD_STOP _IOW(CAN_IOC_MAGIC, 2, channel_t)
92 #define CONF_BAUD _IOW(CAN_IOC_MAGIC, 4, bittiming_t)
94 //#define CONF_XTDACCM
97 #define CONF_FILTER _IOW(CAN_IOC_MAGIC, 8, unsigned char)
99 //#define CONF_FENABLE
100 //#define CONF_FDISABLE
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)
112 #endif /*_CAN_DRVAPI_T_H*/