Lines Matching +full:start +full:- +full:of +full:- +full:frame
13 Controller Area Network is a two-wire serial bus specified by the
14 Bosch CAN Specification, Bosch CAN with Flexible Data-Rate specification and the
15 ISO 11898-1:2003 standard.
26 The bit-timing as defined in ISO 11898-1:2003 looks as following:
35 * Sync_Seg: The nodes synchronize at the edge of the Sync_Seg. It is always one time quantum in len…
37 * Prop_Seg: The signal propagation delay of the bus and other delays of the transceiver and node.
39 * Phase_Seg1 and Phase_Seg2 :Define the sampling point. The bit is sampled at the end of Phase_Seg1.
41 The bit-rate is calculated from the time of a time quantum and the values
43 A bit has the length of Sync_Seg plus Prop_Seg plus Phase_Seg1 plus Phase_Seg2
44 multiplied by the time of single time quantum.
45 The bit-rate is the inverse of the length of a single bit.
50 The CiA recommends setting the sample point to 87.5% of the bit.
52 The resynchronization jump width (SJW) defines the amount of time quantum the
57 Phase_Seg1and Phase_Seg2) are initially set from the device-tree and can be
58 changed at run-time from the timing-API.
60 CAN uses so-called identifiers to identify the frame instead of addresses to
62 This identifier can either have 11-bit width (Standard or Basic Frame) or
63 29-bit in case of an Extended Frame. The Zephyr CAN API supports both Standard
64 and Extended identifiers concurrently. A CAN frame starts with a dominant
65 Start Of Frame bit. After that, the identifiers follow. This phase is called the
73 Filters are used to whitelist identifiers that are of interest for the specific
75 Filters can either match exactly or a specified part of the identifier.
80 Most CAN controllers implement a limited number of filters in hardware.
81 The number of filters is also limited in Kconfig to save memory.
83 Errors may occur during transmission. In case a node detects an erroneous frame,
84 it partially overrides the current frame with an error-frame.
85 Error-frames can either be error passive or error active, depending on the state
86 of the controller.
88 dominant bits, which is a violation of the stuffing rule that all nodes can
89 detect. The sender may resend the frame right after.
91 An initialized node can be in one of the following states:
93 * Error-active
94 * Error-passive
95 * Bus-off
97 After initialization, the node is in the error-active state. In this state, the
99 Every node has a receive- and transmit-error counter.
100 If either the receive- or the transmit-error counter exceeds 127,
101 the node changes to error-passive state.
102 In this state, the node is not allowed to send error-active frames anymore.
103 If the transmit-error counter increases further to 255, the node changes to the
104 bus-off state. In this state, the node is not allowed to send any dominant bits
105 to the bus. Nodes in the bus-off state may recover after receiving 128
106 occurrences of 11 concurrent recessive bits.
124 This basic sample sends a CAN frame with standard identifier 0x123 and eight
125 bytes of data. When passing NULL as the callback, as shown in this example,
126 the send function blocks until the frame is sent and acknowledged by at least
130 .. code-block:: C
132 struct can_frame frame = {
141 ret = can_send(can_dev, &frame, K_MSEC(100), NULL, NULL);
147 This example shows how to send a frame with extended identifier 0x1234567 and
148 two bytes of data. The provided callback is called when the message is sent, or
150 function to block until a transfer mailbox is assigned to the frame or an error
153 .. code-block:: C
166 struct can_frame frame = {
172 frame.data[0] = 1;
173 frame.data[1] = 2;
175 return can_send(can_dev, &frame, K_FOREVER, tx_callback, "Sender 1");
188 .. code-block:: C
190 void rx_callback_function(const struct device *dev, struct can_frame *frame, void *user_data)
192 ... do something with the frame ...
203 .. code-block:: C
220 called from userspace context. The size of the message queue should be as big
226 .. code-block:: C
246 ... do something with the frame ...
251 .. code-block:: C
264 .. code-block:: C
272 LOG_INF("Sample-Point error: %d", ret);
292 LOG_ERR("Failed to start CAN controller");
301 Zephyr additionally supports SocketCAN, a BSD socket implementation of the
303 SocketCAN brings the convenience of the well-known BSD Socket API to
305 implementation, where many other high-level CAN projects build on top.
306 Note that frames are routed to the network stack instead of passed directly,
312 We have two ready-to-build samples demonstrating use of the Zephyr CAN API:
313 :zephyr:code-sample:`Zephyr CAN counter sample <can-counter>` and
314 :zephyr:code-sample:`SocketCAN sample <socket-can>`.