1 |
786 |
skrzyp |
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
2 |
|
|
|
3 |
|
|
<html>
|
4 |
|
|
|
5 |
|
|
<head>
|
6 |
|
|
<meta http-equiv="content-type" content="text/html;charset=iso-8859-1">
|
7 |
|
|
<title>IO/CAN Doc</title>
|
8 |
|
|
</head>
|
9 |
|
|
|
10 |
|
|
<body bgcolor="#ffffff">
|
11 |
|
|
<h2>CAN driver details</h2>
|
12 |
|
|
<p>A raw CAN driver is is provided as a standard part of the eCos system. Use the include file <code><cyg/io/canio.h></code> for this driver. The CAN driver is capable of sending single CAN messages and receiving single CAN events to a CAN device. Controls are provided to configure the actual hardware, but there is no manipulation of the data by this driver. There may be many instances of this driver in a given system, one for each CAN channel. Each channel corresponds to a physical device and there will typically be a device module created for this purpose. The device modules themselves are configurable, allowing specification of the actual hardware details.</p>
|
13 |
|
|
<h3>User API</h3>
|
14 |
|
|
<p>The CAN driver uses the standard eCos I/O API functions. All functions except <code>cyg_io_lookup()</code> require an I/O "handle".</p>
|
15 |
|
|
<p>All functions return a value of the type <code>Cyg_ErrNo</code>. If an error condition is detected, this value will be negative and the absolute value indicates the actual error, as specified in <code>cyg/error/codes.h</code>. The only other legal return value will be <code>ENOERR</code> , <code>-EINTR </code>and<code> -EAGAIN</code>. All other function arguments are pointers (references). This allows the drivers to pass information efficiently, both into and out of the driver. The most striking example of this is the <i>len </i>value passed to the read and write functions. This parameter contains the desired length of data on input to the function and the actual transferred length on return.</p>
|
16 |
|
|
<h4>Lookup a CAN device</h4>
|
17 |
|
|
<p><code>Cyg_ErrNo cyg_io_lookup(<br> const char *name,<br> cyg_io_handle_t *handle )</code></p>
|
18 |
|
|
<p>This function maps a device name onto an appropriate handle. If the named device is not in the system, then the error -<code>ENOENT</code> is returned. If the device is found, then the handle for the device is returned by way of the handle pointer <i>*handle</i>.</p>
|
19 |
|
|
<h4>Send a CAN message</h4>
|
20 |
|
|
<p><code>Cyg_ErrNo cyg_io_write(<br>
|
21 |
|
|
cyg_io_handle_t handle,<br>
|
22 |
|
|
const void *buf,<br>
|
23 |
|
|
cyg_uint32 *len )<br>
|
24 |
|
|
</code></p>
|
25 |
|
|
<p>This function sends <b>one single</b> CAN message (not a buffer of CAN messages) to a device. The size of data to send is contained in <i>*len</i> and the actual size sent will be returned in the same place. A pointer to a <code>cyg_can_message</code> is contained in <i>*buf</i> . The driver maintains a buffer to hold the data. The size of the intermediate buffer is configurable within the interface module. The data is not modified at all while it is being buffered. On return,<i> *len</i> contains the amount of characters actually consumed - that means <i>*len</i> always contains <code>sizeof(cyg_can_message)</code>.</p>
|
26 |
|
|
<p>It is possible to configure the write call to be blocking (default) or non-blocking. Non-blocking mode requires both the configuration option <code>CYGOPT_IO_CAN_SUPPORT_NONBLOCKING</code> to be enabled, and the specific device to be set to non-blocking mode for writes (see <code>cyg_io_set_config()</code>). In blocking mode, the call will not return until there is space in the buffer and the content of the CAN message has been consumed. In non-blocking mode, if there is no space in buffer for the CAN message, <code>-EAGAIN</code> is returned and the caller must try again.</p>
|
27 |
|
|
<p>It is possible to configure the write call to be non-blocking with timeout. None-blocking mode with timeout requires the configuration option <code>CYGOPT_IO_CAN_SUPPORT_NONBLOCKING </code>and<code> CYGOPT_IO_CAN_SUPPORT_TIMEOUTS </code>to be enabled, requires the eCos kernel package to be included and the specific device to be set to non-blocking mode for writes (see <code>cyg_io_set_config()</code>). In non-blocking mode with timeouts, if there is no space in buffer for the CAN message, the driver waits a certain amount of time (the timeout time) for space in the buffer. If there is still no space in buffer after expiration of the timeout time, <code> -EINTR</code> is returned and the caller must try again.</p>
|
28 |
|
|
<p>If a message was sucessfully sent, the function returns <code>ENOERR</code>. </p>
|
29 |
|
|
<p><code>typedef struct can_message<br>
|
30 |
|
|
|
31 |
|
|
{<br>
|
32 |
|
|
|
33 |
|
|
|
34 |
|
|
cyg_uint32 id;<br>
|
35 |
|
|
|
36 |
|
|
|
37 |
|
|
cyg_uint8 data[8];<br>
|
38 |
|
|
|
39 |
|
|
|
40 |
|
|
cyg_can_id_type ext;<br>
|
41 |
|
|
|
42 |
|
|
|
43 |
|
|
cyg_can_frame_type rtr;<br>
|
44 |
|
|
|
45 |
|
|
|
46 |
|
|
cyg_uint8 dlc;<br>
|
47 |
|
|
|
48 |
|
|
} cyg_can_message;</code></p>
|
49 |
|
|
<p>The type <code>cyg_can_message</code> provides a device independent type of CAN message. Before calling the write function this message should be setup properly. The<i> id</i> field contains the 11 Bit or 29 bit CAN message identifier depending on the value of the <i>ext</i> field. The <i>data</i> field contains the 8 data bytes of one CAN message. The <i>ext</i> field configures the type of CAN message identifier (<code>CYGNUM_CAN_ID_STD</code> = standard 11 Bit id,<i> </i><code>CYGNUM_CAN_ID_EXT</code> = extended 29 Bit id). The <i>rtr</i> field contains the frame type. (<code>CYGNUM_CAN_FRAME_DATA</code> = data frame, <code>CYGNUM_CAN_FRAME_RTR</code> = remote transmission request). The <i>dlc</i> field (data length code) contains the number of valid data bytes (0 - 8) in the <i>data</i> field.</p>
|
50 |
|
|
<p>Example code for sending one single CAN message:</p>
|
51 |
|
|
<p><code>cyg_can_message tx_msg;<br>cyg_uint32 len;<br>
|
52 |
|
|
Cyg_ErrNo ret;<br>
|
53 |
|
|
<br>
|
54 |
|
|
|
55 |
|
|
|
56 |
|
|
tx_msg.id = 0x100;<br>
|
57 |
|
|
|
58 |
|
|
|
59 |
|
|
tx_msg.ext = CYGNUM_CAN_ID_EXT;<br>
|
60 |
|
|
|
61 |
|
|
tx_msg.rtr = CYGNUM_CAN_FRAME_DATA;<br>
|
62 |
|
|
|
63 |
|
|
tx_msg.dlc = 1;<br>
|
64 |
|
|
|
65 |
|
|
tx_msg.data[0] = 0xF1;<br>
|
66 |
|
|
<br>
|
67 |
|
|
|
68 |
|
|
len = sizeof(tx_msg);<br>
|
69 |
|
|
ret = cyg_io_write(hDrvCAN, &tx_msg, &len);</code></p>
|
70 |
|
|
<h4>Read a CAN event</h4>
|
71 |
|
|
<p><code>Cyg_ErrNo cyg_io_read(<br>
|
72 |
|
|
cyg_io_handle_t handle,<br>
|
73 |
|
|
|
74 |
|
|
void *buf,<br>
|
75 |
|
|
|
76 |
|
|
cyg_uint32 *len )<br>
|
77 |
|
|
</code></p>
|
78 |
|
|
<p>This function receives one single event from a device. The desired size of data to receive is contained in <i>*len</i> and the actual size obtained will be returned in the same place. A pointer to a<code> cyg_can_event</code> is contained in <i>*buf</i>. No manipulation of the data is performed before being transferred. Again, this buffering is completely configurable. On return, <i>*len</i> contains <code>sizeof(cyg_can_event)</code><br>
|
79 |
|
|
</p>
|
80 |
|
|
<p>It is possible to configure the read call to be blocking (default) or non-blocking. Non-blocking mode requires both the configuration option <code>CYGOPT_IO_CAN_SUPPORT_NONBLOCKING</code> to be enabled, and the specific device to be set to non-blocking mode for reads (<code>see cyg_io_set_config()</code>). In blocking mode, the call will not return until one single CAN event has been read. In<i> </i>non-blocking mode, if there is no CAN event in buffer, the call returns immediately with <code>-EAGAIN</code> and the caller must try again.</p>
|
81 |
|
|
<p>It is possible to configure the write call to be non-blocking with timeout. None-blocking mode with timeout requires the configuration option <code>CYGOPT_IO_CAN_SUPPORT_NONBLOCKING </code>and<code> CYGOPT_IO_CAN_SUPPORT_TIMEOUTS </code>to be enabled, requires the eCos kernel package to be included and the specific device to be set to non-blocking mode for reads (see <code>cyg_io_set_config()</code>). In non-blocking mode with timeouts, if there is no CAN event in receive buffer, the driver waits a certain amound of time (the timeout time) for a CAN event to arrive. If there is still no CAN event in buffer after expiration of the timeout time, <code> -EINTR</code> is returned and the caller must try again.</p>
|
82 |
|
|
<p>If an event was sucessfully received, the function returns <code>ENOERR</code>.</p>
|
83 |
|
|
<p><code>typedef struct cyg_can_event_st<br>
|
84 |
|
|
{<br>
|
85 |
|
|
cyg_uint32 timestamp;<br>
|
86 |
|
|
|
87 |
|
|
cyg_can_message msg;<br>
|
88 |
|
|
|
89 |
|
|
cyg_uint16 flags;<br>
|
90 |
|
|
} cyg_can_event;<br>
|
91 |
|
|
</code></p>
|
92 |
|
|
<p>A <code>cyg_can_event</code> provides a generic device independent type for handling CAN events that may occur. If the driver supports timestamps then the <i>timestamp</i> field my contain a timestamp value for an event that occured. The <i>msg</i> field contains a CAN message if an RX or TX event occured. The <i>flags</i> field contains 16 bits that indicate which kind of events occured. The following events are supported and after receiving an event the flag field should be checked against these values:</p>
|
93 |
|
|
<p><code>typedef enum <br>
|
94 |
|
|
{<br>
|
95 |
|
|
|
96 |
|
|
CYGNUM_CAN_EVENT_RX = 0x0001, // message received<br>
|
97 |
|
|
|
98 |
|
|
CYGNUM_CAN_EVENT_TX = 0x0002, // mesage transmitted<br>
|
99 |
|
|
|
100 |
|
|
CYGNUM_CAN_EVENT_WARNING_RX = 0x0004, // tx error counter (TEC) reached warning level (>96)<br>
|
101 |
|
|
|
102 |
|
|
CYGNUM_CAN_EVENT_WARNING_TX = 0x0008, // rx error counter (REC) reached warning level (>96)<br>
|
103 |
|
|
|
104 |
|
|
CYGNUM_CAN_EVENT_ERR_PASSIVE = 0x0010, // CAN "error passive" occured<br>
|
105 |
|
|
|
106 |
|
|
CYGNUM_CAN_EVENT_BUS_OFF = 0x0020, // CAN "bus off" error occured<br>
|
107 |
|
|
|
108 |
|
|
CYGNUM_CAN_EVENT_OVERRUN_RX = 0x0040, // overrun in RX queue or hardware occured<br>
|
109 |
|
|
|
110 |
|
|
CYGNUM_CAN_EVENT_OVERRUN_TX = 0x0080, // overrun in TX queue occured<br>
|
111 |
|
|
|
112 |
|
|
CYGNUM_CAN_EVENT_CAN_ERR = 0x0100, // a CAN bit or frame error occured<br>
|
113 |
|
|
|
114 |
|
|
CYGNUM_CAN_EVENT_LEAVING_STANDBY = 0x0200, // CAN hardware leaves standby / power don mode or is waked up<br>
|
115 |
|
|
|
116 |
|
|
CYGNUM_CAN_EVENT_ENTERING_STANDBY = 0x0400, // CAN hardware enters standby / power down mode<br>
|
117 |
|
|
|
118 |
|
|
CYGNUM_CAN_EVENT_ARBITRATION_LOST = 0x0800, // arbitration lost<br>
|
119 |
|
|
CYGNUM_CAN_EVENT_DEVICE_CHANGED = 0x1000, // device changed event<br>
|
120 |
|
|
</code><code>CYGNUM_CAN_EVENT_PHY_FAULT = 0x2000, // General failure of physical layer detected (if supported by hardware)<br>
|
121 |
|
|
</code><code>CYGNUM_CAN_EVENT_PHY_H = 0x4000, // Fault on CAN-H detected (Low Speed CAN)<br>
|
122 |
|
|
</code><code>CYGNUM_CAN_EVENT_PHY_L = 0x8000, // Fault on CAN-L detected (Low Speed CAN)<br>
|
123 |
|
|
} cyg_can_event_flags;</code></p>
|
124 |
|
|
<p>Often the flags field will contain only one single set flag. But it is possible that a number of flags is set and so the flag field should always be checked by a receiver. I.e. if the <code>CYGNUM_CAN_EVENT_RX </code>is set then also the <code>CYGNUM_CAN_EVENT_OVERRUN_RX </code>may be set if the received message caused an RX overrun.</p>
|
125 |
|
|
<p>The internal receive buffers of the CAN device driver a circular buffers. That means that even if the buffers are completely filled new messages will be received. In this case the newest message will always overwrite the oldest message in receive buffer. If this happens the <code>CYGNUM_CAN_EVENT_OVERRUN_RX </code>flag will be set for this new message that caused overwriting of the old one. The <code>CYGNUM_CAN_EVENT_OVERRUN_RX </code>flag will be set also if a overrun occures in hardware message buffers of the CAN device.</p>
|
126 |
|
|
<p>Example code for receiving one single CAN event:</p>
|
127 |
|
|
<p><code>cyg_can_event rx_event;<br>
|
128 |
|
|
cyg_uint32 len;<br>
|
129 |
|
|
Cyg_ErrNo ret;<br>
|
130 |
|
|
<br>
|
131 |
|
|
|
132 |
|
|
len = sizeof(rx_event);<br>
|
133 |
|
|
|
134 |
|
|
ret = cyg_io_read(hDrvCAN, &rx_event, &len);<br>
|
135 |
|
|
<br>
|
136 |
|
|
|
137 |
|
|
if (ENOERR == ret)<br>
|
138 |
|
|
|
139 |
|
|
{<br>
|
140 |
|
|
|
141 |
|
|
if (rx_event.flags & CYGNUM_CAN_EVENT_RX)<br>
|
142 |
|
|
|
143 |
|
|
{<br>
|
144 |
|
|
|
145 |
|
|
// handle RX event<br>
|
146 |
|
|
|
147 |
|
|
}<br>
|
148 |
|
|
|
149 |
|
|
<br>
|
150 |
|
|
|
151 |
|
|
if (rx_event.flags & ~CYGNUM_CAN_EVENT_RX)<br>
|
152 |
|
|
|
153 |
|
|
{<br>
|
154 |
|
|
|
155 |
|
|
// handle other events<br>
|
156 |
|
|
|
157 |
|
|
}<br>
|
158 |
|
|
|
159 |
|
|
}<br>
|
160 |
|
|
|
161 |
|
|
else if (-EINTR == ret)<br>
|
162 |
|
|
|
163 |
|
|
{<br>
|
164 |
|
|
|
165 |
|
|
// handle timeout<br>
|
166 |
|
|
|
167 |
|
|
}<br>
|
168 |
|
|
</code></p>
|
169 |
|
|
<h4>Read configuration of a CAN device</h4>
|
170 |
|
|
<p><code>Cyg_ErrNo cyg_io_get_config(<br>
|
171 |
|
|
cyg_io_handle_t handle,<br>
|
172 |
|
|
cyg_uint32 key,<br>
|
173 |
|
|
void *buf,<br>
|
174 |
|
|
cyg_uint32 *len )<br>
|
175 |
|
|
</code></p>
|
176 |
|
|
<p>This function is used to obtain run-time configuration about a device. The type of information retrieved is specified by the key. The data will be returned in the given buffer. The value of <i>*len</i> should contain the amount of data requested, which must be at least as large as the size appropriate to the selected key. The actual size of data retrieved is placed in <i>*len</i>. The appropriate key values are all listed in the file<code> <cyg/io/config_keys.h></code>.</p>
|
177 |
|
|
<p>The following config keys are currently supported:</p>
|
178 |
|
|
<p><code>CYG_IO_GET_CONFIG_READ_BLOCKING<br>
|
179 |
|
|
CYG_IO_GET_CONFIG_WRITE_BLOCKING<br>
|
180 |
|
|
CYG_IO_GET_CONFIG_CAN_INFO<br>
|
181 |
|
|
CYG_IO_GET_CONFIG_CAN_BUFFER_INFO<br>CYG_IO_GET_CONFIG_CAN_MSGBUF_INFO<br>
|
182 |
|
|
|
183 |
|
|
CYG_IO_GET_CONFIG_CAN_TIMEOUT<br>
|
184 |
|
|
CYG_IO_GET_CONFIG_CAN_HDI<br>
|
185 |
|
|
CYG_IO_GET_CONFIG_CAN_STATE<br>
|
186 |
|
|
</code></p>
|
187 |
|
|
<h4>Change configuration of a CAN device</h4>
|
188 |
|
|
<p><code>Cyg_ErrNo cyg_io_set_config(<br>
|
189 |
|
|
cyg_io_handle_t handle,<br>
|
190 |
|
|
|
191 |
|
|
cyg_uint32 key,<br>
|
192 |
|
|
|
193 |
|
|
const void *buf,<br>
|
194 |
|
|
|
195 |
|
|
cyg_uint32 *len)<br>
|
196 |
|
|
</code></p>
|
197 |
|
|
<p>This function is used to manipulate or change the run-time configuration of a device. The type of information is specified by the key. The data will be obtained from the given buffer. The value of <i>*len</i> should contain the amount of data provided, which must match the size appropriate to the selected key. The appropriate key values are all listed in the file <code><cyg/io/config_keys.h></code>.</p>
|
198 |
|
|
<p>The following config keys are currently supported:</p>
|
199 |
|
|
<p><code>CYG_IO_SET_CONFIG_READ_BLOCKING<br>
|
200 |
|
|
CYG_IO_SET_CONFIG_WRITE_BLOCKING<br>
|
201 |
|
|
CYG_IO_SET_CONFIG_CAN_INFO<br>
|
202 |
|
|
CYG_IO_SET_CONFIG_CAN_OUTPUT_DRAIN<br>
|
203 |
|
|
CYG_IO_SET_CONFIG_CAN_OUTPUT_FLUSH<br>
|
204 |
|
|
CYG_IO_SET_CONFIG_CAN_INPUT_FLUSH<br>
|
205 |
|
|
|
206 |
|
|
|
207 |
|
|
CYG_IO_SET_CONFIG_CAN_TIMEOUT<br>CYG_IO_SET_CONFIG_CAN_MSGBUF<br>
|
208 |
|
|
</code><code>CYG_IO_SET_CONFIG_CAN_MODE<br>
|
209 |
|
|
<br>
|
210 |
|
|
</code></p>
|
211 |
|
|
<h3>Runtime Configuration</h3>
|
212 |
|
|
<p>Runtime configuration is achieved by exchanging data structures with the driver via the <code>cyg_io_set_config()</code> and <code>cyg_io_get_config()</code> functions.</p>
|
213 |
|
|
<h4>Device configuration</h4>
|
214 |
|
|
<p><code>typedef struct cyg_can_info_st {<br>
|
215 |
|
|
cyg_can_baud_rate_t baud;<br>
|
216 |
|
|
} cyg_can_info_t;</code></p>
|
217 |
|
|
<p>Device configuration is achieved by by exchanging <code>cyg_can_info_t </code>data structures with the driver via the <code>cyg_io_set_config()</code> and <code>cyg_io_get_config()</code> functions using the config keys <code>CYG_IO_GET_CONFIG_CAN_INFO </code>and<code> CYG_IO_SET_CONFIG_CAN_INFO</code>. The field <i>baud</i> contains a baud rate selection. This must be one of the follwing values:</p>
|
218 |
|
|
<p><code>CYGNUM_CAN_KBAUD_10<br>
|
219 |
|
|
CYGNUM_CAN_KBAUD_20<br>
|
220 |
|
|
CYGNUM_CAN_KBAUD_50<br>
|
221 |
|
|
CYGNUM_CAN_KBAUD_100<br>
|
222 |
|
|
CYGNUM_CAN_KBAUD_125<br>
|
223 |
|
|
CYGNUM_CAN_KBAUD_250<br>
|
224 |
|
|
CYGNUM_CAN_KBAUD_500<br>
|
225 |
|
|
CYGNUM_CAN_KBAUD_800<br>
|
226 |
|
|
CYGNUM_CAN_KBAUD_1000<br>
|
227 |
|
|
</code></p>
|
228 |
|
|
<h4>Timeout configuration</h4>
|
229 |
|
|
<p><code>typedef struct cyg_can_timeout_info_st<br>
|
230 |
|
|
{<br>
|
231 |
|
|
|
232 |
|
|
cyg_uint32 rx_timeout; <br>
|
233 |
|
|
|
234 |
|
|
cyg_uint32 tx_timeout;<br>
|
235 |
|
|
} cyg_can_timeout_info_t;<br>
|
236 |
|
|
</code></p>
|
237 |
|
|
<p>Timeout configuration is achieved by by exchanging <code>cyg_can_timeout_info_t </code>data structures with the driver via the <code>cyg_io_set_config()</code> and <code>cyg_io_get_config()</code> functions using the config keys <code>CYG_IO_SET_CONFIG_CAN_TIMEOUT </code>and<code> CYG_IO_SET_CONFIG_CAN_TIMEOUT</code>. The field <i>rx_timeout</i> contains the timeout value for <code>cyg_io_read </code>calls and <i>tx_timeout</i> contains the timeout value for <code>cyg_io_write </code>calls. This call is only available if the configuration options <code>CYGOPT_IO_CAN_SUPPORT_NONBLOCKING </code>and <code>CYGOPT_IO_CAN_SUPPORT_TIMEOUTS</code> are enabled.</p>
|
238 |
|
|
<h4>Reading buffer configuration</h4>
|
239 |
|
|
<p><code>typedef struct cyg_can_buf_info_st<br>
|
240 |
|
|
{ <br>
|
241 |
|
|
cyg_int32 rx_bufsize; <br>
|
242 |
|
|
cyg_int32 rx_count;<br>
|
243 |
|
|
cyg_int32 tx_bufsize;<br>
|
244 |
|
|
cyg_int32 tx_count;<br>
|
245 |
|
|
} cyg_can_buf_info_t;<br>
|
246 |
|
|
</code></p>
|
247 |
|
|
<p><code>CYG_IO_GET_CONFIG_CAN_BUFFER_INFO - </code>This function retrieves the current state of the software buffers in the serial drivers. For the transmit buffer it returns the the total number of <code>cyg_can_message </code>objects in buffer and the current number of <code>cyg_can_message </code>objects occupied in the buffer. For the recieve buffer it returns the total number of <code>cyg_can_event </code>objects in receive buffer and the current number of <code>cyg_can_event </code>objects occupied in the buffer. It does not take into account any buffering such as FIFOs or holding registers that the CAN hardware device itself may have.</p>
|
248 |
|
|
<h4>Reading hardware description information</h4>
|
249 |
|
|
<p><code>typedef struct cyg_can_hdi_st<br>
|
250 |
|
|
{<br>
|
251 |
|
|
cyg_uint8 support_flags;<br>
|
252 |
|
|
cyg_uint8 controller_type;<br>
|
253 |
|
|
} cyg_can_hdi;</code></p>
|
254 |
|
|
<p><code>CYG_IO_GET_CONFIG_CAN_HDI - </code>This function retrieves information about the used hardware. The Hardware Description Interface provides a method to gather information about the CAN hardware and the functionality of the driver. For this purpose the structure <code>cyg_can_hdi </code>is defined. The field support_flags contains information about the capabilities of the used CAN hardware. The following flags are available:</p>
|
255 |
|
|
<table width="600" border="0" cellspacing="2" cellpadding="0">
|
256 |
|
|
<tr>
|
257 |
|
|
<td align="center" valign="middle" bgcolor="#c6c6c6" width="70">7</td>
|
258 |
|
|
<td align="center" valign="middle" bgcolor="#c6c6c6" width="70">6</td>
|
259 |
|
|
<td align="center" valign="middle" bgcolor="#c6c6c6" width="70">5</td>
|
260 |
|
|
<td align="center" valign="middle" bgcolor="#c6c6c6" width="70">4</td>
|
261 |
|
|
<td align="center" valign="middle" bgcolor="#c6c6c6" width="70">3</td>
|
262 |
|
|
<td align="center" valign="middle" bgcolor="#c6c6c6" width="70">2</td>
|
263 |
|
|
<td align="center" valign="middle" bgcolor="#c6c6c6" width="70">1</td>
|
264 |
|
|
<td align="center" valign="middle" bgcolor="#c6c6c6" width="70">0</td>
|
265 |
|
|
</tr>
|
266 |
|
|
<tr>
|
267 |
|
|
<td align="center" valign="middle" width="70">res</td>
|
268 |
|
|
<td align="center" valign="middle" width="70">res</td>
|
269 |
|
|
<td align="center" valign="middle" width="70">res</td>
|
270 |
|
|
<td align="center" valign="middle" width="70">timest.</td>
|
271 |
|
|
<td align="center" valign="middle" width="70">SW-Filt</td>
|
272 |
|
|
<td align="center" valign="middle" width="70">FullCAN</td>
|
273 |
|
|
<td colspan="2" align="center" valign="middle" width="142">Frametype</td>
|
274 |
|
|
</tr>
|
275 |
|
|
</table>
|
276 |
|
|
<p><i>Frametype:<br>
|
277 |
|
|
</i>Bit 0 and Bit 1 of the structure describe the<i> </i>possibilities of the CAN controller. The following values are defined:</p>
|
278 |
|
|
<p><code>CYGNUM_CAN_HDI_FRAMETYPE_STD // receives only standard frame<br>
|
279 |
|
|
CYGNUM_CAN_HDI_FRAMETYPE_EXT_PASSIVE // can recieve but not send extended frames<br>
|
280 |
|
|
CYGNUM_CAN_HDI_FRAMETYPE_EXT_ACTIVE // can send and receive extended frames<br>
|
281 |
|
|
</code></p>
|
282 |
|
|
<p><i>FullCAN:<br>
|
283 |
|
|
</i>If the Bit 2 is set to one, the CAN controller supports more than one message buffer.</p>
|
284 |
|
|
<p><code>CYGNUM_CAN_HDI_FULLCAN // supports more than one message buffer<br>
|
285 |
|
|
</code></p>
|
286 |
|
|
<p><i>SW-Filter:<br>
|
287 |
|
|
</i>If Bit3 is set to one then the CAN driver supports some kind of software message filtering.</p>
|
288 |
|
|
<p><code>CYGNUM_CAN_HDI_FILT_SW // software message filtering supported<br>
|
289 |
|
|
</code></p>
|
290 |
|
|
<p><i>Timestamp:<br>
|
291 |
|
|
</i>If Bit 4 is set to one then the CAN hardware supports timestamps for CAN messages</p>
|
292 |
|
|
<p><code>CYGNUM_CAN_HDI_TIMESTAMP // CAN hardware supports timestamps<br>
|
293 |
|
|
</code></p>
|
294 |
|
|
<h4>Reading message buffer configuration</h4>
|
295 |
|
|
<p><code>typedef struct cyg_can_msgbox_info_st<br>
|
296 |
|
|
</code><code>{<br>
|
297 |
|
|
c</code><code>yg_uint8 count; // number of message buffers available for this device<br>
|
298 |
|
|
</code><code>cyg_uint8 free; // number of free message buffers<br>
|
299 |
|
|
</code><code>} cyg_can_msgbuf_info;</code></p>
|
300 |
|
|
<p><code>CYG_IO_GET_CONFIG_CAN_MSGBUF_INFO</code> - If the CAN hardware supports more than one message buffer for reception of CAN message (flag <code>CYGNUM_CAN_HDI_FULLCAN </code>is set after reading hardware description interface with <code>CYG_IO_GET_CONFIG_CAN_HDI</code>) then this function reads the number of message buffers the CAN hardware supports and the number of free message buffers. The field<i> count</i> contains the number of message buffers supported by device and the field <i>free</i> contains the number of free message buffers. The free message buffers are available for setting up remote buffers (<code>CYG_IO_SET_CONFIG_CAN_REMOTE_BUF)</code> and message filters (<code>CYG_IO_SET_CONFIG_CAN_FILTER_MSG</code>).</p>
|
301 |
|
|
<h4>Reading state of CAN hardware</h4>
|
302 |
|
|
<p><code>typedef enum<br>
|
303 |
|
|
{<br> CYGNUM_CAN_STATE_ACTIVE, // CAN controller is active, no errors<br>
|
304 |
|
|
</code><code>CYGNUM_CAN_STATE_STOPPED, // CAN controller is in stopped mode<br>
|
305 |
|
|
</code><code>CYGNUM_CAN_STATE_STANDBY, // CAN controller is in Sleep mode<br>
|
306 |
|
|
</code><code>CYGNUM_CAN_STATE_BUS_WARN, // CAN controller is active, warning level is reached<br>
|
307 |
|
|
</code><code>CYGNUM_CAN_STATE_ERR_PASSIVE, // CAN controller went into error passive mode<br>
|
308 |
|
|
</code><code>CYGNUM_CAN_STATE_BUS_OFF, // CAN controller went into bus off mode<br>
|
309 |
|
|
</code><code>CYGNUM_CAN_STATE_PHY_FAULT, // General failure of physical layer detected (if supported by hardware)<br>
|
310 |
|
|
</code><code>CYGNUM_CAN_STATE_PHY_H, // Fault on CAN-H detected (Low Speed CAN)<br>
|
311 |
|
|
</code><code>CYGNUM_CAN_STATE_PHY_L, // Fault on CAN-L detected (Low Speed CAN)<br>
|
312 |
|
|
</code><code>} cyg_can_state;</code></p>
|
313 |
|
|
<p><code>CYG_IO_GET_CONFIG_CAN_STATE</code> - This function retrieves the present state of the CAN controller. Possible values are defined in the <code>cyg_can_state</code> enumeration.</p>
|
314 |
|
|
<h4>Drain output buffers</h4>
|
315 |
|
|
<p><code>CYG_IO_SET_CONFIG_CAN_OUTPUT_DRAIN</code> - This function waits for any buffered output to complete. This function only completes when there is no more data remaining to be sent to the device.</p>
|
316 |
|
|
<h4>Flush output buffers</h4>
|
317 |
|
|
<p><code>CYG_IO_SET_CONFIG_CAN_OUTPUT_FLUSH</code> - This function discards any buffered output for the device.</p>
|
318 |
|
|
<h4>Flush input buffers</h4>
|
319 |
|
|
<p><code>CYG_IO_SET_CONFIG_CAN_INPUT_FLUSH</code> - This function discards any buffered input for the device.</p>
|
320 |
|
|
<h4>Configuring blocking/nonblocking calls</h4>
|
321 |
|
|
|
322 |
|
|
|
323 |
|
|
|
324 |
|
|
|
325 |
|
|
By default all calls to <code>cyg_io_read()</code> and<code> cyg_io_write()</code> are blocking calls. The config keys<br>
|
326 |
|
|
<br>
|
327 |
|
|
<code>CYG_IO_GET_CONFIG_READ_BLOCKING<br>
|
328 |
|
|
CYG_IO_GET_CONFIG_WRITE_BLOCKING<br>
|
329 |
|
|
<br>
|
330 |
|
|
</code>and<br>
|
331 |
|
|
<br>
|
332 |
|
|
<code>CYG_IO_GET_CONFIG_READ_BLOCKING<br>
|
333 |
|
|
CYG_IO_GET_CONFIG_WRITE_BLOCKING<br>
|
334 |
|
|
<br>
|
335 |
|
|
</code>enable switching between blocking and nonblocking calls separatly for read and write calls. If blocking calls are configured then the read/write functions return only if a message was stored into TX buffer or an event was received from RX buffer. If nonblocking calls are enabled and there is no space in TX buffer or RX buffer is empty then the function returns immediatelly with <code>-EAGAIN</code>. If nonblocking calls are enabled and additionally timeouts are supported by driver, then the read/write functions wait until timeout value is expired and then return witn <code>-EINTR</code>. If the read/write operation succeeds during the timed wait then the functions return succesfully with<code> ENOERR</code>.
|
336 |
|
|
|
337 |
|
|
<h4>Message buffer configuration</h4>
|
338 |
|
|
<p><code>typedef struct cyg_can_msgbox_cfg_st<br>
|
339 |
|
|
</code><code>{<br>
|
340 |
|
|
</code><code>cyg_can_msgbuf_cfg_id cfg_id; // configuration id - cfg. what to do with message buffer<br>
|
341 |
|
|
</code><code>cyg_can_msgbuf_handle handle; // handle to message buffer<br>
|
342 |
|
|
</code><code>cyg_can_message msg; // CAN message - for configuration of buffer<br>
|
343 |
|
|
</code><code>} cyg_can_msgbuf_cfg;</code></p>
|
344 |
|
|
<p>Full CAN controllers often support more the one message buffer. These message buffers are often configurable for transmission or reception of certain CAN messages or as a remote buffer. If a CAN hardware supports more than one message buffer then it is possible to configure the CAN hardware to receive only CAN messages with certain identifiers or to configure hardware support for remote buffers. If message filtering is done by hardware, the number of received CAN messages decreases and so also the time for processing received CAN messages and the memory required for buffering received messages decreases. This saves valuable memory and processing time. The eCos CAN driver supports a generic way of adding message filters or remote buffers. By default the CAN driver is configured for reception of any kind of CAN standard and extended frames. Configuration of message buffers is done by calling <code>cyg_io_set_config() </code>with the config key:</p>
|
345 |
|
|
<p><code>CYG_IO_SET_CONFIG_CAN_MSGBUF<br>
|
346 |
|
|
</code></p>
|
347 |
|
|
<p>and exchanging <code>cyg_can_msgbuf_cfg </code>data structures. The <i>cfg_id</i> field contains the configuration ID that tells the driver what to do with a message buffer, the <i>handle</i> field contains a reference to a certain message buffer and the <i>msg</i> field is necessary for configuration of message buffer parameters. The following configuration identifiers are supported:</p>
|
348 |
|
|
<p><code>CYGNUM_CAN_MSGBUF_RESET_ALL // clears all message buffers, no message will be received, all remote buffers deleted<br>
|
349 |
|
|
</code><code>CYGNUM_CAN_MSGBUF_RX_FILTER_ALL // cfg driver for reception of all can messges<br>
|
350 |
|
|
</code><code>CYGNUM_CAN_MSGBUF_RX_FILTER_ADD // add single message filter<br>
|
351 |
|
|
</code><code>CYGNUM_CAN_MSGBUF_REMOTE_BUF_ADD // add new remote response buffer<br>
|
352 |
|
|
</code><code>CYGNUM_CAN_MSGBUF_REMOTE_BUF_WRITE // stores data into existing remote buffer (remote buf handle required)</code></p>
|
353 |
|
|
<p>Example code for resetting all message buffers:</p>
|
354 |
|
|
<p><code>cyg_can_msgbuf_cfg msgbox_cfg;</code></p>
|
355 |
|
|
<p><code>msgbox_cfg.cfg_id = CYGNUM_CAN_MSGBUF_RESET_ALL;<br>
|
356 |
|
|
</code><code>len = sizeof(msgbox_cfg);<br>
|
357 |
|
|
</code><code>if (ENOERR != cyg_io_set_config(hDrvFlexCAN, CYG_IO_SET_CONFIG_CAN_MSGBUF ,&msgbox_cfg, &len))<br>
|
358 |
|
|
</code><code>{<br>
|
359 |
|
|
</code><code>// handle configuration error<br>
|
360 |
|
|
</code><code>} </code></p>
|
361 |
|
|
<h4>Remote frame response buffer configuration</h4>
|
362 |
|
|
<p>The remote frame is a message frame which is transmitted to request a data frame. Some CAN hardware generates receive interrupts when a remote transmission request arrives. Other CAN hardware, i.e. the FlexCAN module, does not generate any receive interrupt. These CAN hardware chips, i.e. the FlexCAN module, can be configured to transmit a data frame automatically in response to a remote frame. In oder to support any kind of CAN hardware the eCos CAN driver provides a generic handling of remote transmission requests.</p>
|
363 |
|
|
<p>The transmission of the data frame in response to a remote frame is completely handled by the CAN driver. If the hardware driver, like the driver for the FlexCAN modul, supports harware message buffers, then the response frame is automatically transmitted if a remote transmission request with a matching ID arrives. If a CAN hardware does not provide hardware support for sending data frames in response to a remote frame, then this need to be implemented in software by the hardware device driver.</p>
|
364 |
|
|
<p>It is always possible to add remote response buffers. It does not matter if the driver is configured for reception of all CAN messages or if message filtering is used. As long as there are free message buffers available, it is possible to add remote response buffers.</p>
|
365 |
|
|
<p>In order to respond to a remote frame, a remote frame reponse buffer need to be initialized before a data frame can be sent in response to a remote frame. This is achieved by by exchanging <code>cyg_can_remote_buf </code>data structures with the driver via the <code>cyg_io_set_config()</code> function using the config key <code>CYG_IO_SET_CONFIG_CAN_MSGBUF</code>. Once the buffer is initialized, the CAN data can be changed at any time by the application.</p>
|
366 |
|
|
<p><code>typedef struct cyg_can_msgbuf_cfg_st<br>
|
367 |
|
|
</code><code>{<br> cyg_can_msgbuf_cfg_id cfg_id; // configuration id - cfg. what to do with message buffer<br>
|
368 |
|
|
</code><code>cyg_can_msgbuf_handle handle; // handle to message buffer<br>
|
369 |
|
|
</code><code>cyg_can_message msg; // CAN message - for configuration of buffer<br>
|
370 |
|
|
} cyg_can_remote_buf;<br>
|
371 |
|
|
</code></p>
|
372 |
|
|
<p>The CAN frame that should be transmitted in response to a remote frame is stored in the<i> msg</i> field of the <code>cyg_can_remote_buf </code>data structure. If there is no buffer initialized for this data, the value of the <i>handle</i> field need to be set to <code>CYGNUM_CAN_MSGBUF_INIT</code>. After the call to <code>cyg_io_set_config()</code> the <i>handle</i> field contains a valid value ( >= 0) or the value <code>CYGNUM_CAN_MSGBUF_NA</code> ( < 0) if no free buffer is available. With the valid handle value the CAN data can be changed later by calling <code>cyg_io_set_config(). </code>Before adding remote buffers the device should be stopped and after configuration it should be set into operational mode again</p>
|
373 |
|
|
<p>Example code for setting up a remote response buffer:</p>
|
374 |
|
|
<p><code>cyg_can_remote_buf rtr_buf;<br>
|
375 |
|
|
<br>
|
376 |
|
|
// prepare the remote response buffer<br>rtr_buf.cfg_id = CYGNUM_CAN_MSGBUF_REMOTE_BUF_ADD;<br>
|
377 |
|
|
</code><code>rtr_buf.handle = CYGNUM_CAN_MSGBUF_INIT;<br>
|
378 |
|
|
</code><code>rtr_buf.msg.id = 0x7FF;<br>
|
379 |
|
|
</code><code>rtr_buf.msg.ext = CYGNUM_CAN_ID_STD;<br>
|
380 |
|
|
</code><code>rtr_buf.msg.rtr = CYGNUM_CAN_FRAME_DATA;<br>
|
381 |
|
|
</code><code>rtr_buf.msg.dlc = 1;<br>
|
382 |
|
|
</code><code>rtr_buf.msg.data[0] = 0xAB;<br>
|
383 |
|
|
<br>
|
384 |
|
|
|
385 |
|
|
len = sizeof(rtr_buf);<br>
|
386 |
|
|
</code><code>if (ENOERR != cyg_io_set_config(hDrvFlexCAN, <br>
|
387 |
|
|
CYG_IO_SET_CONFIG_CAN_MSGBUF,<br>
|
388 |
|
|
|
389 |
|
|
|
390 |
|
|
&rtr_buf, &len))<br>
|
391 |
|
|
</code><code>{<br>
|
392 |
|
|
|
393 |
|
|
|
394 |
|
|
// handle configuration error<br>
|
395 |
|
|
</code><code>} <br>
|
396 |
|
|
</code><code><br>
|
397 |
|
|
</code><code>if (rtr_buf.handle == CYGNUM_CAN_MSGBUF_NA)<br>
|
398 |
|
|
</code><code>{<br>
|
399 |
|
|
|
400 |
|
|
|
401 |
|
|
// no free message buffer available - handle this problem here<br>
|
402 |
|
|
</code><code>}<br>
|
403 |
|
|
<br>
|
404 |
|
|
<br>
|
405 |
|
|
|
406 |
|
|
// change CAN data for a buffer that is already initialized<br>
|
407 |
|
|
</code><code>rtr_buf.cfg_id = CYGNUM_CAN_MSGBUF_REMOTE_BUF_WRITE;<br>
|
408 |
|
|
|
409 |
|
|
|
410 |
|
|
rtr_buf.msg.data[0] = 0x11;<br>
|
411 |
|
|
<br>
|
412 |
|
|
|
413 |
|
|
|
414 |
|
|
len = sizeof(rtr_buf);<br>
|
415 |
|
|
</code><code>if (ENOERR != cyg_io_set_config(hDrvFlexCAN, <br>
|
416 |
|
|
|
417 |
|
|
CYG_IO_SET_CONFIG_CAN_MSGBUF,<br>
|
418 |
|
|
|
419 |
|
|
|
420 |
|
|
|
421 |
|
|
&rtr_buf, &len))<br>
|
422 |
|
|
</code><code>{<br>
|
423 |
|
|
|
424 |
|
|
|
425 |
|
|
|
426 |
|
|
// handle configuration error<br>
|
427 |
|
|
</code><code>} <br>
|
428 |
|
|
</code></p>
|
429 |
|
|
<h4>Message filter configuration</h4>
|
430 |
|
|
<p> If message filtering is done by hardware the number of received CAN messages decreases and so also the time for processing received CAN messages and the memory required for buffering received messages decreases. This saves valuable memory and processing time. The eCos CAN driver supports a generic way of adding message filters. By default the CAN driver is configured for reception of any kind of CAN standard and extended frames. As soon as a message filter is added, the CAN driver will only receive the CAN frames with the identifier of the CAN filter. By adding a number of message filters it is possible for the CAN hardware to receive an number of different CAN messages.</p>
|
431 |
|
|
<p>Adding message filters is only possible if driver is not configured for reception of all available CAN messages. If driver is configured for recption of all CAN messages then message buffers neet to be reset before adding single message filters.</p>
|
432 |
|
|
<p>In order to add a message filter, a message buffer need to be initialized. This is achieved by by exchanging <code>cyg_can_filter </code>data structures with the driver via the <code>cyg_io_set_config()</code> function using the config key <code>CYG_IO_SET_CONFIG_CAN_MSGBUF</code>. Once the buffer is initialized, the CAN hardware can recive messages with the identifier of the filter.</p>
|
433 |
|
|
<p><code>typedef struct cyg_can_msgbox_cfg_st<br>
|
434 |
|
|
</code><code>{<br>
|
435 |
|
|
cyg_can_msgbuf_cfg_id cfg_id;<br>
|
436 |
|
|
</code><code>cyg_can_msgbuf_handle handle;<br>
|
437 |
|
|
|
438 |
|
|
</code><code>cyg_can_message msg;<br>
|
439 |
|
|
</code><code>} cyg_can_filter;</code></p>
|
440 |
|
|
<p>After the call to <code>cyg_io_set_config()</code> the <i>handle</i> field contains a valid value ( >= 0) or the value <code>CYGNUM_CAN_MSGBUF_NA</code> ( < 0) if no free buffer is available. Before adding message filters the device should be stopped and after configuration it should be set into operational mode again</p>
|
441 |
|
|
<p>Example code for setting up a message filter:</p>
|
442 |
|
|
<p><code>cyg_can_msgbuf_cfg msgbox_cfg;<br>
|
443 |
|
|
cyg_can_filter rx_filter;<br>
|
444 |
|
|
<br>
|
445 |
|
|
// reset all message buffers</code><br>
|
446 |
|
|
<code>msgbox_cfg.cfg_id = CYGNUM_CAN_MSGBUF_RESET_ALL;<br>
|
447 |
|
|
</code><code>len = sizeof(msgbox_cfg);<br>
|
448 |
|
|
</code><code>if (ENOERR != cyg_io_set_config(hDrvFlexCAN, CYG_IO_SET_CONFIG_CAN_MSGBUF ,&msgbox_cfg, &len))<br>
|
449 |
|
|
</code><code>{<br>
|
450 |
|
|
</code><code>// handle configuration error<br>
|
451 |
|
|
</code><code>} <br>
|
452 |
|
|
<br>
|
453 |
|
|
</code><code>// prepare the message filter<br>
|
454 |
|
|
rx_filter.cfg_id = CYGNUM_CAN_MSGBUF_RX_FILTER_ADD<br>
|
455 |
|
|
</code><code>rx_filter.msg.id = 0x800;<br>
|
456 |
|
|
rx_filter.msg.ext = CYGNUM_CAN_ID_EXT;<br>
|
457 |
|
|
<br>
|
458 |
|
|
len = sizeof(rx_filter);<br>
|
459 |
|
|
if (ENOERR != cyg_io_set_config(hDrvFlexCAN,<br>
|
460 |
|
|
CYG_IO_SET_CONFIG_CAN_MSGBUF,<br>
|
461 |
|
|
&rx_filter, &len))<br>
|
462 |
|
|
</code><code>{<br>
|
463 |
|
|
</code><code>// handle configuration error;<br>
|
464 |
|
|
</code><code>}<br>
|
465 |
|
|
</code><code>else if (CYGNUM_CAN_MSGBUF_NA == rx_filter.handle)<br>
|
466 |
|
|
</code><code>{<br>
|
467 |
|
|
// no free message buffer available - handle this problem here<br>
|
468 |
|
|
}</code></p>
|
469 |
|
|
<h4>Receive all CAN messages</h4>After startup of your device the CAN driver is configured for reception of all available CAN messages. If you change this configuration by adding single message filters then you can reset this default state with the configuration ID: <p><code>CYGNUM_CAN_MSGBUF_RX_FILTER_ALL</code> </p>
|
470 |
|
|
<p>A call to this function will clear all message filters and remote buffers and prepares the CAN hardware for recption of any kind of CAN standard and extended frames. It is not neccesary to reset the message buffer configuration before this configuration is setup because this should be done by device driver.</p>
|
471 |
|
|
<p>Example code for setup of a receive all CAN frames configuration:</p>
|
472 |
|
|
<p><code>cyg_can_filter rx_filter;<br>
|
473 |
|
|
<br>
|
474 |
|
|
// now setup a RX all configuration<br>
|
475 |
|
|
</code><code>rx_filter.cfg_id = CYGNUM_CAN_MSGBUF_RX_FILTER_ALL;<br>
|
476 |
|
|
</code><code>len = sizeof(rx_filter);<br>
|
477 |
|
|
</code><code>if (ENOERR != cyg_io_set_config(hDrvFlexCAN, CYG_IO_SET_CONFIG_CAN_MSGBUF , &rx_filter, &len))<br>
|
478 |
|
|
</code><code>{<br>
|
479 |
|
|
</code><code>CYG_TEST_FAIL_FINISH("Error writing config of /dev/can0");<br>
|
480 |
|
|
</code><code>}</code></p>
|
481 |
|
|
<h4>Set mode of CAN hardware</h4>
|
482 |
|
|
<p><code>typedef enum <br>
|
483 |
|
|
</code><code>{<br>
|
484 |
|
|
CYGNUM_CAN_MODE_STOP, // set controller into stop mode<br>
|
485 |
|
|
</code><code>CYGNUM_CAN_MODE_START, // set controller into operational mode<br>
|
486 |
|
|
</code><code>CYGNUM_CAN_MODE_STANDBY // set controller into standby / sleep mode<br>
|
487 |
|
|
} cyg_can_mode;</code></p>
|
488 |
|
|
<p><code>CYG_IO_SET_CONFIG_CAN_MODE</code> - This function changes the operating mode of the CAN controller. Possible values for mode are defined in the <code>cyg_can_mode</code> enumeration. Befor the hardware configuration of the device is changed, that means if baudrate is changed or the message buffer and filter configuration is changed, the CAN hardware should be set into stop mode and if configuration is finished, then device should be set back into operational mode. Before the device is set into standby mode, the output buffers should be flushed or drained because transmission of a CAN message may wake up the CAN hardware. If a received message wakes up the CAN hardware from standby mode then a <code>CYGNUM_CAN_EVENT_LEAVING_STANDBY</code> event will be inserted into receive message buffer or the <code>CYGNUM_CAN_EVENT_LEAVING_STANDBY </code>flag will be set for the message that caused wake up of CAN hardware.</p>
|
489 |
|
|
<h2>FlexCAN device driver</h2>
|
490 |
|
|
<p>The FlexCAN module is a communication controller implementing the controller area network (CAN) protocol, an asynchronous communications protocol used in automotive and industrial control systems. It is a high speed (1 Mbit/sec), short distance, priority based protocol which can communicate using a variety of mediums (for example, fiber optic cable or an unshielded twisted pair of wires). The FlexCAN supports both the standard and extended identifier (ID) message formats specified in the CAN protocol specification, revision 2.0, part B.</p>
|
491 |
|
|
<p>It supports up to 16 flexible flexible message buffers of 0-8 bytes data length, each configurable as Rx or Tx, all supporting standard and extended messages.</p>
|
492 |
|
|
<p>The message buffer 16 of the FlexCAN modul is reserved for transmission of CAN messages. Message buffers 1 - 15 are available for configuration of remote buffers and message filters. If the FlexCAN modul is configured for reception of all CAN frames, then the user can select the number of buffers used for reception of CAN frames. The interrupt priority of each message box is configurable.</p>
|
493 |
|
|
</body>
|
494 |
|
|
|
495 |
|
|
</html>
|