RTEMS  5.1
occan.h
Go to the documentation of this file.
1 
7 /*
8  * COPYRIGHT (c) 2007.
9  * Cobham Gaisler AB.
10  *
11  * The license and distribution terms for this file may be
12  * found in the file LICENSE in this distribution or at
13  * http://www.rtems.org/license/LICENSE.
14  */
15 
16 #ifndef __OCCAN_DRIVER_H__
17 #define __OCCAN_DRIVER_H__
18 
19 #ifdef __cplusplus
20 extern "C" {
21 #endif
22 
23 /* CAN MESSAGE */
24 typedef struct {
25  char extended; /* 1= Extended Frame (29-bit id), 0= STD Frame (11-bit id) */
26  char rtr; /* RTR - Remote Transmission Request */
27  char sshot; /* single shot */
28  unsigned char len;
29  unsigned char data[8];
30  unsigned int id;
31 } CANMsg;
32 
33 typedef struct {
34  /* tx/rx stats */
35  unsigned int rx_msgs;
36  unsigned int tx_msgs;
37 
38  /* Error Interrupt counters */
39  unsigned int err_warn;
40  unsigned int err_dovr;
41  unsigned int err_errp;
42  unsigned int err_arb;
43  unsigned int err_bus;
44 
45  /**** BUS ERRORS (err_arb) ****/
46 
47  /* ALC 4-0 */
48  unsigned int err_arb_bitnum[32]; /* At what bit arbitration is lost */
49 
50  /******************************/
51 
52  /**** BUS ERRORS (err_bus) ****/
53 
54  /* ECC 7-6 */
55  unsigned int err_bus_bit; /* Bit error */
56  unsigned int err_bus_form; /* Form Error */
57  unsigned int err_bus_stuff; /* Stuff Error */
58  unsigned int err_bus_other; /* Other Error */
59 
60  /* ECC 5 */
61  unsigned int err_bus_rx; /* Errors during Reception */
62  unsigned int err_bus_tx; /* Errors during Transmission */
63 
64  /* ECC 4:0 */
65  unsigned int err_bus_segs[32]; /* Segment (Where in frame error occured)
66  * See OCCAN_SEG_* defines for indexes
67  */
68 
69  /******************************/
70 
71 
72  /* total number of interrupts */
73  unsigned int ints;
74 
75  /* software monitoring hw errors */
76  unsigned int tx_buf_error;
77 
78  /* Software fifo overrun */
79  unsigned int rx_sw_dovr;
80 
81 } occan_stats;
82 
83 /* indexes into occan_stats.err_bus_segs[index] */
84 #define OCCAN_SEG_ID28 0x02 /* ID field bit 28:21 */
85 #define OCCAN_SEG_ID20 0x06 /* ID field bit 20:18 */
86 #define OCCAN_SEG_ID17 0x07 /* ID field bit 17:13 */
87 #define OCCAN_SEG_ID12 0x0f /* ID field bit 12:5 */
88 #define OCCAN_SEG_ID4 0x0e /* ID field bit 4:0 */
89 
90 #define OCCAN_SEG_START 0x03 /* Start of Frame */
91 #define OCCAN_SEG_SRTR 0x04 /* Bit SRTR */
92 #define OCCAN_SEG_IDE 0x05 /* Bit IDE */
93 #define OCCAN_SEG_RTR 0x0c /* Bit RTR */
94 #define OCCAN_SEG_RSV0 0x09 /* Reserved bit 0 */
95 #define OCCAN_SEG_RSV1 0x0d /* Reserved bit 1 */
96 
97 #define OCCAN_SEG_DLEN 0x0b /* Data Length code */
98 #define OCCAN_SEG_DFIELD 0x0a /* Data Field */
99 
100 #define OCCAN_SEG_CRC_SEQ 0x08 /* CRC Sequence */
101 #define OCCAN_SEG_CRC_DELIM 0x18 /* CRC Delimiter */
102 
103 #define OCCAN_SEG_ACK_SLOT 0x19 /* Acknowledge slot */
104 #define OCCAN_SEG_ACK_DELIM 0x1b /* Acknowledge delimiter */
105 #define OCCAN_SEG_EOF 0x1a /* End Of Frame */
106 #define OCCAN_SEG_INTERMISSION 0x12 /* Intermission */
107 #define OCCAN_SEG_ACT_ERR 0x11 /* Active error flag */
108 #define OCCAN_SEG_PASS_ERR 0x16 /* Passive error flag */
109 #define OCCAN_SEG_DOMINANT 0x13 /* Tolerate dominant bits */
110 #define OCCAN_SEG_EDELIM 0x17 /* Error delimiter */
111 #define OCCAN_SEG_OVERLOAD 0x1c /* overload flag */
112 
113 
114 #define CANMSG_OPT_RTR 0x40 /* RTR Frame */
115 #define CANMSG_OPT_EXTENDED 0x80 /* Exteneded frame */
116 #define CANMSG_OPT_SSHOT 0x01 /* Single Shot, no retry */
117 
118 #define OCCAN_IOC_START 1
119 #define OCCAN_IOC_STOP 2
120 
121 #define OCCAN_IOC_GET_CONF 3
122 #define OCCAN_IOC_GET_STATS 4
123 #define OCCAN_IOC_GET_STATUS 5
124 
125 #define OCCAN_IOC_SET_SPEED 6
126 #define OCCAN_IOC_SPEED_AUTO 7
127 #define OCCAN_IOC_SET_LINK 8
128 #define OCCAN_IOC_SET_FILTER 9
129 #define OCCAN_IOC_SET_BLK_MODE 10
130 #define OCCAN_IOC_SET_BUFLEN 11
131 #define OCCAN_IOC_SET_BTRS 12
132 
133 
135  unsigned char code[4];
136  unsigned char mask[4];
137  int single_mode;
138 };
139 
140 #define OCCAN_STATUS_RESET 0x01
141 #define OCCAN_STATUS_OVERRUN 0x02
142 #define OCCAN_STATUS_WARN 0x04
143 #define OCCAN_STATUS_ERR_PASSIVE 0x08
144 #define OCCAN_STATUS_ERR_BUSOFF 0x10
145 #define OCCAN_STATUS_QUEUE_ERROR 0x80
146 
147 #define OCCAN_BLK_MODE_RX 0x1
148 #define OCCAN_BLK_MODE_TX 0x2
149 
150 void occan_register_drv (void);
151 
152 
153 #define OCCAN_SPEED_500K 500000
154 #define OCCAN_SPEED_250K 250000
155 #define OCCAN_SPEED_125K 125000
156 #define OCCAN_SPEED_75K 75000
157 #define OCCAN_SPEED_50K 50000
158 #define OCCAN_SPEED_25K 25000
159 #define OCCAN_SPEED_10K 10000
160 
161 #ifdef __cplusplus
162 }
163 #endif
164 
165 #endif
Definition: occan.h:33
Definition: grcan.h:101
Definition: occan.h:134
Definition: inftrees.h:24