2 * can4linux.h - can4linux CAN driver module
4 * This file is subject to the terms and conditions of the GNU General Public
5 * License. See the file "COPYING" in the main directory of this archive
8 * Copyright (c) 2001 port GmbH Halle/Saale
9 *------------------------------------------------------------------
10 * $Header: /canfestival/CanFestival-3/drivers/can_can4linux/can4linux.h,v 1.1 2008-01-22 09:27:13 groke6 Exp $
12 *--------------------------------------------------------------------------
15 * modification history
16 * --------------------
17 * $Log: can4linux.h,v $
18 * Revision 1.1 2008-01-22 09:27:13 groke6
19 * Added can4linux driver support.
21 * Revision 1.1 2004/08/12 10:14:31 jschoew
22 * add can4linux examples
24 * Revision 1.5 2004/05/14 10:02:54 oe
25 * - started supporting CPC-Card
26 * - version number in can4linux.h available
27 * - only one structure type for Config_par_t Command_par_t
28 * - new ioctl command CMD_CLEARBUFFERS
30 * Revision 1.4 2003/08/27 17:49:04 oe
31 * - New CanStatusPar structure
33 * Revision 1.3 2002/08/20 05:57:22 oe
34 * - new write() handling, now not ovrwriting buffer content if buffer fill
35 * - ioctl() get status returns buffer information
37 * Revision 1.2 2002/08/08 17:50:46 oe
38 * - MSG_ERR_MASK extended
40 * Revision 1.1 2002/01/10 19:13:19 oe
41 * - application header file changed name can.h -> can4linux.h
43 * Revision 1.2 2001/09/14 14:58:09 oe
46 * Revision 1.1.1.1 2001/06/11 18:30:54 oe
47 * minimal version can4linux embedded, compile time Konfigurierbar
52 *--------------------------------------------------------------------------
57 * \author Heinz-Jrgen Oertel, port GmbH
59 * $Date: 2008-01-22 09:27:13 $
61 * can4linux interface definitions
76 #define CAN4LINUXVERSION 0x0301 /*(Version 3.1)*/
81 /*---------- the can message structure */
83 #define CAN_MSG_LENGTH 8 /**< maximum length of a CAN frame */
86 #define MSG_RTR (1<<0) /**< RTR Message */
87 #define MSG_OVR (1<<1) /**< CAN controller Msg overflow error */
88 #define MSG_EXT (1<<2) /**< extended message format */
89 #define MSG_PASSIVE (1<<4) /**< controller in error passive */
90 #define MSG_BUSOFF (1<<5) /**< controller Bus Off */
91 #define MSG_ (1<<6) /**< */
92 #define MSG_BOVR (1<<7) /**< receive/transmit buffer overflow */
94 * mask used for detecting CAN errors in the canmsg_t flags field
96 #define MSG_ERR_MASK (MSG_OVR + MSG_PASSIVE + MSG_BUSOFF + MSG_BOVR)
99 * The CAN message structure.
100 * Used for all data transfers between the application and the driver
101 * using read() or write().
104 /** flags, indicating or controlling special message properties */
106 int cob; /**< CAN object number, used in Full CAN */
107 unsigned long id; /**< CAN message ID, 4 bytes */
108 struct timeval timestamp; /**< time stamp for received messages */
109 short int length; /**< number of bytes in the CAN message */
110 unsigned char data[CAN_MSG_LENGTH]; /**< data, 0...8 bytes */
116 ---------- IOCTL requests */
118 #define COMMAND 0 /**< IOCTL command request */
119 #define CONFIG 1 /**< IOCTL configuration request */
120 #define SEND 2 /**< IOCTL request */
121 #define RECEIVE 3 /**< IOCTL request */
122 #define CONFIGURERTR 4 /**< IOCTL request */
123 #define STATUS 5 /**< IOCTL status request */
125 /*---------- CAN ioctl parameter types */
127 IOCTL Command request parameter structure */
129 int cmd; /**< special driver command */
130 int target; /**< special configuration target */
131 unsigned long val1; /**< 1. parameter for the target */
132 unsigned long val2; /**< 2. parameter for the target */
133 int error; /**< return value */
134 unsigned long retval; /**< return value */
138 typedef struct Command_par Command_par_t ;
140 PSW made them all the same
141 IOCTL Configuration request parameter structure */
142 typedef struct Command_par Config_par_t ;
146 IOCTL generic CAN controller status request parameter structure */
147 typedef struct CanStatusPar {
148 unsigned int baud; /**< actual bit rate */
149 unsigned int status; /**< CAN controller status register */
150 unsigned int error_warning_limit; /**< the error warning limit */
151 unsigned int rx_errors; /**< content of RX error counter */
152 unsigned int tx_errors; /**< content of TX error counter */
153 unsigned int error_code; /**< content of error code register */
154 unsigned int rx_buffer_size; /**< size of rx buffer */
155 unsigned int rx_buffer_used; /**< number of messages */
156 unsigned int tx_buffer_size; /**< size of tx buffer */
157 unsigned int tx_buffer_used; /**< number of messages */
158 unsigned long retval; /**< return value */
159 unsigned int type; /**< CAN controller / driver type */
163 IOCTL CanStatusPar.type CAN controller hardware chips */
164 #define CAN_TYPE_UNSPEC 0
165 #define CAN_TYPE_SJA1000 1
166 #define CAN_TYPE_FlexCAN 2
167 #define CAN_TYPE_TouCAN 3
168 #define CAN_TYPE_82527 4
169 #define CAN_TYPE_TwinCAN 5
173 IOCTL Send request parameter structure */
174 typedef struct Send_par {
175 canmsg_t *Tx; /**< CAN message struct */
176 int error; /**< return value for errno */
177 unsigned long retval; /**< return value */
181 IOCTL Receive request parameter structure */
182 typedef struct Receive_par {
183 canmsg_t *Rx; /**< CAN message struct */
184 int error; /**< return value for errno */
185 unsigned long retval; /**< return value */
189 IOCTL ConfigureRTR request parameter structure */
190 typedef struct ConfigureRTR_par {
191 unsigned message; /**< CAN message ID */
192 canmsg_t *Tx; /**< CAN message struct */
193 int error; /**< return value for errno */
194 unsigned long retval; /**< return value */
195 } ConfigureRTR_par_t ;
198 ---------- IOCTL Command subcommands and there targets */
203 # define CMD_CLEARBUFFERS 4
209 ---------- IOCTL Configure targets */
211 # define CONF_ACC 0 /* mask and code */
212 # define CONF_ACCM 1 /* mask only */
213 # define CONF_ACCC 2 /* code only */
214 # define CONF_TIMING 3 /* bit timing */
215 # define CONF_OMODE 4 /* output control register */
216 # define CONF_FILTER 5
217 # define CONF_FENABLE 6
218 # define CONF_FDISABLE 7