libopencm3
A free/libre/open-source firmware library for various ARM Cortex-M3 microcontrollers.
fdcan.c
Go to the documentation of this file.
1/** @addtogroup fdcan_file FDCAN peripheral API
2 *
3 * @ingroup peripheral_apis
4 *
5 * @brief <b>libopencm3 STM32 FDCAN</b>
6 *
7 * @version 1.0.0
8 *
9 * @author @htmlonly &copy; @endhtmlonly 2021 Eduard Drusa <ventyl86 at netkosice dot sk>
10 *
11 * Device is equipped with two FDCAN peripherals residing in one FDCAN block. The peripherals
12 * support both CAN 2.0 A and B standard and Bosch FDCAN standard. FDCAN frame format and
13 * bitrate switching is supported. The peripheral has several filters for incoming messages that
14 * can be distributed between two FIFOs and transmit buffer all of configurable amount of
15 * entries. For transmitted messages it is possible to opt for event notification once message
16 * is transmitted.
17 *
18 * The FDCAN peripheral present in STM32 H7 is a superset of FDCAN peripheral found in other MCUs
19 * such as STM32 G4. It allows more fine-grade control over buffer and filter allocation and
20 * supports TTCAN on CAN1, etc. This driver provides source-level backwards compatible
21 * implementation of driver, which allows build of unmodified software originally written for
22 * STM32 G4 on STM32 H7.
23 *
24 * LGPL License Terms @ref lgpl_license
25*/
26
27/*
28 * This file is part of the libopencm3 project.
29 *
30 * Copyright (C) 2021 Eduard Drusa <ventyl86 at netkosice dot sk>
31 *
32 * This library is free software: you can redistribute it and/or modify
33 * it under the terms of the GNU Lesser General Public License as published by
34 * the Free Software Foundation, either version 3 of the License, or
35 * (at your option) any later version.
36 *
37 * This library is distributed in the hope that it will be useful,
38 * but WITHOUT ANY WARRANTY; without even the implied warranty of
39 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
40 * GNU Lesser General Public License for more details.
41 *
42 * You should have received a copy of the GNU Lesser General Public License
43 * along with this library. If not, see <http://www.gnu.org/licenses/>.
44 */
45
48#include <stddef.h>
49
50#define FDCAN_LSS_COUNT(can_base) \
51 ((FDCAN_SIDFC(can_base) >> FDCAN_SIDFC_LSS_SHIFT) & FDCAN_SIDFC_LSS_MASK)
52
53#define FDCAN_LSE_COUNT(can_base) \
54 ((FDCAN_XIDFC(can_base) >> FDCAN_XIDFC_LSE_SHIFT) & FDCAN_XIDFC_LSE_MASK)
55
56/* --- FD-CAN functions ----------------------------------------------------- */
57
58/** @ingroup fdcan_file */
59/**@{
60 * */
61
62/** Returns actual size of FIFO entry in FIFO for given CAN port and FIFO.
63 *
64 * Obtains value of FIFO entry length. This value covers both fixed-size frame
65 * header block and payload buffer. User can configure payload buffer size individually
66 * for each FIFO and designated RX buffer.
67 *
68 * @param [in] canport FDCAN block base address. See @ref fdcan_block.
69 * @param [in] fifo_id ID of FIFO whole length is queried.
70 * @returns Length of FIFO entry length covering frame header and frame payload.
71 */
72unsigned fdcan_get_fifo_element_size(uint32_t canport, unsigned fifo_id)
73{
74 unsigned element_size;
75 if (fifo_id == 0) {
76 element_size = FDCAN_RXESC(canport) >> FDCAN_RXESC_F0DS_SHIFT;
77 } else {
78 element_size = FDCAN_RXESC(canport) >> FDCAN_RXESC_F1DS_SHIFT;
79 }
80
81 /* Mask is unshifted and at this point, element_size is unshifted too */
82 return 8 + fdcan_dlc_to_length((element_size & FDCAN_RXESC_F0DS_MASK) | 0x8);
83}
84
85/** Returns actual size of transmit entry in transmit queue/FIFO for given CAN port.
86 *
87 * Obtains value of entry length in transmit queue/FIFO. This value covers both
88 * fixed-sized frame header block and payload buffer. User can configure payload buffer
89 * size.
90 *
91 * @param [in] canport FDCAN block base address. See @ref fdcan_block.
92 * @returns Length of FIFO entry length covering frame header and frame payload.
93 */
94unsigned fdcan_get_txbuf_element_size(uint32_t canport)
95{
96 unsigned element_size;
97 element_size = (FDCAN_TXESC(canport) >> FDCAN_TXESC_TBDS_SHIFT) & FDCAN_TXESC_TBDS_MASK;
98 return 8 + fdcan_dlc_to_length((element_size & FDCAN_TXESC_TBDS_MASK) | 0x8);
99}
100
101/** Initialize allocation of standard filter block in CAN message RAM.
102 *
103 * Allows specifying size of standard filtering block (in term of available filtering
104 * rules and filter base address within CAN message RAM. Note, that there are no limitations
105 * nor checking on address provided. It is possible to share whole filtering block or
106 * portion of it between multiple CAN interfaces.
107 * @param [in] canport FDCAN block base address. See @ref fdcan_block.
108 * @param [in] flssa standard filtering block start address offset in message RAM
109 * @param [in] lss amount of standard filters
110 */
111void fdcan_init_std_filter_ram(uint32_t canport, uint32_t flssa, uint8_t lss)
112{
113 FDCAN_SIDFC(canport) = flssa << FDCAN_SIDFC_FLSSA_SHIFT
114 | lss << FDCAN_SIDFC_LSS_SHIFT;
115}
116
117/** Initialize allocation of extended filter block in CAN message RAM.
118 *
119 * Allows specifying size of extended filtering block (in term of available filtering
120 * rules and filter base address within CAN message RAM. Note, that there are no limitations
121 * nor checking on address provided. It is possible to share whole filtering block or
122 * portion of it between multiple CAN interfaces.
123 * @param [in] canport FDCAN block base address. See @ref fdcan_block.
124 * @param [in] flesa extended filtering block start address offset in message RAM
125 * @param [in] lse amount of extended filters
126 */
127void fdcan_init_ext_filter_ram(uint32_t canport, uint32_t flesa, uint8_t lse)
128{
129 FDCAN_XIDFC(canport) = flesa << FDCAN_XIDFC_FLESA_SHIFT
130 | lse << FDCAN_XIDFC_LSE_SHIFT;
131}
132
133/** Initialize allocation of FIFO block in CAN message RAM.
134 *
135 * Allows specifying size of FIFO block (in term of available messages in FIFO
136 * and FIFO base address within CAN message RAM. Note, that there are no limitations
137 * nor checking on address provided.
138 * @param [in] canport FDCAN block base address. See @ref fdcan_block.
139 * @param [in] fifo_id ID of fifo being configured
140 * @param [in] fxsa FIFO block start address offset in message RAM
141 * @param [in] fxs number of elements to assign
142 */
143void fdcan_init_fifo_ram(uint32_t canport, unsigned fifo_id, uint32_t fxsa, uint8_t fxs)
144{
145 FDCAN_RXFIC(canport, fifo_id) = (FDCAN_RXFIC(canport, fifo_id)
146 & ~(
149 ))
150 | (fxs << FDCAN_RXFIC_FIS_SHIFT)
152}
153
154/** Initialize allocation of transmit event block in CAN message RAM.
155 *
156 * Allows specifying size of transmit event block (in term of allocated events and block
157 * base address within CAN message RAM. Note, that there are no limitations
158 * nor checking on address provided.
159 * @param [in] canport FDCAN block base address. See @ref fdcan_block.
160 * @param [in] tesa block start address offset in message RAM
161 * @param [in] tes number of elements to assign
162 */
163void fdcan_init_tx_event_ram(uint32_t canport, uint32_t tesa, uint8_t tes)
164{
165 FDCAN_TXEFC(canport) = (FDCAN_TXEFC(canport)
166 & ~(
169 ))
170 | (tes << FDCAN_TXEFC_EFS_SHIFT)
172}
173
174/** Initialize allocation of transmit queue block in CAN message RAM.
175 *
176 * Allows specifying size of transmit queue block (in term of allocated buffers and block
177 * base address within CAN message RAM. Note, that there are no limitations
178 * nor checking on address provided.
179 * @param [in] canport FDCAN block base address. See @ref fdcan_block.
180 * @param [in] tbsa block start address offset in message RAM
181 * @param [in] tbs number of elements to assign
182 */
183void fdcan_init_tx_buffer_ram(uint32_t canport, uint32_t tbsa, uint8_t tbs)
184{
185 FDCAN_TXBC(canport) = (FDCAN_TXBC(canport)
186 & ~(
189 ))
190 | (tbs << FDCAN_TXBC_TFQS_SHIFT)
192}
193
194/** Initialize size of data fields in reception buffers.
195 *
196 * Configures maximum size of message payload, which can be stored in different
197 * reception buffers. Each buffer can have maximum payload size configured independently.
198 * Buffers can only be configured to sizes which are valid sizes of FDCAN payload. Sizes smaller
199 * than 8 are automatically padded to 8.
200 * @note If you change these values, then content of reception buffers is invalidated. You may
201 * also want to recalculate base addresses of objects in message RAM as their size might have
202 * changed.
203 * @param [in] canport FDCAN block base address. See @ref fdcan_block.
204 * @param [in] rxbuf maximum storable payload size of dedicated RX buffer
205 * @param [in] rxfifo0 maximum storable payload size of RX FIFO 0
206 * @param [in] rxfifo1 maximum storable payload size of RX FIFO 1
207 * @returns operation return status. See @ref fdcan_error.
208 */
209int fdcan_set_rx_element_size(uint32_t canport, uint8_t rxbuf, uint8_t rxfifo0, uint8_t rxfifo1)
210{
211 unsigned rxbufdlc = fdcan_length_to_dlc(rxbuf);
212 unsigned rxfifo0dlc = fdcan_length_to_dlc(rxfifo0);
213 unsigned rxfifo1dlc = fdcan_length_to_dlc(rxfifo1);
214
215 if (rxbufdlc == 0xFF || rxfifo0dlc == 0xFF || rxfifo1dlc == 0xFF) {
216 return FDCAN_E_INVALID;
217 }
218
219 /* RXESC fields use format of FDCAN DLC, albeit using only
220 * three LSBs. DLC < 8 is always allocated as 8 bytes and is always
221 * encoded as 0.
222 */
223 if (rxbufdlc <= 8) {
224 rxbufdlc = 0;
225 } else {
226 rxbufdlc &= ~(1 << 4);
227 }
228
229 if (rxfifo0dlc <= 8) {
230 rxfifo0dlc = 0;
231 } else {
232 rxfifo0dlc &= ~(1 << 4);
233 }
234
235 if (rxfifo1dlc <= 8) {
236 rxfifo1dlc = 0;
237 } else {
238 rxfifo1dlc &= ~(1 << 4);
239 }
240
241 FDCAN_RXESC(canport) = rxbufdlc << FDCAN_RXESC_RBDS_SHIFT
242 | rxfifo1dlc << FDCAN_RXESC_F1DS_SHIFT
243 | rxfifo0dlc << FDCAN_RXESC_F0DS_SHIFT;
244
245 return FDCAN_E_OK;
246}
247
248/** Initialize size of data fields in transmit buffers.
249 *
250 * Configures maximum size of message payload, which can be stored either in dedicated
251 * transmit buffer or into transmit queue/FIFO. One size is applied both to transmit buffer
252 * and transmit queue / FIFO. Buffers can only be configured to sizes which are valid sizes
253 * of FDCAN payload. Sizes smaller than 8 are automatically padded to 8 bytes.
254 * @note If you change these values, then content of transmission buffers is invalidated. You may
255 * also want to recalculate base addresses of objects in message RAM as their size might have
256 * changed.
257 * @param [in] canport FDCAN block base address. See @ref fdcan_block.
258 * @param [in] txbuf maximum storable payload size of TX buffer / FIFO / queue
259 * @returns operation return status. See @ref fdcan_error.
260 */
261int fdcan_set_tx_element_size(uint32_t canport, uint8_t txbuf)
262{
263 unsigned txbufdlc = fdcan_length_to_dlc(txbuf);
264
265 if (txbufdlc == 0xFF) {
266 return FDCAN_E_INVALID;
267 }
268
269 if (txbufdlc <= 8) {
270 txbufdlc = 0;
271 } else {
272 txbufdlc &= ~(1 << 4);
273 }
274
275 FDCAN_TXESC(canport) = txbufdlc << FDCAN_TXESC_TBDS_SHIFT;
276
277 return FDCAN_E_OK;
278}
279
280/** Configure amount of filters and initialize filtering block.
281 *
282 * This function allows to configure global amount of filters present.
283 * FDCAN block will only ever check as many filters as this function configures.
284 * Function will also clear all filter blocks to zero values. This function
285 * can be only called after @ref fdcan_init has already been called and
286 * @ref fdcan_start has not been called yet as registers holding filter
287 * count are write-protected unless FDCAN block is in INIT mode. It is possible
288 * to reconfigure filters (@ref fdcan_set_std_filter and @ref fdcan_set_ext_filter)
289 * after FDCAN block has already been started.
290 *
291 * This function is provided for source level compatibility with code written for
292 * STM32G4. As an alternative, you can use @ref fdcan_init_std_filter_ram() and
293 * @ref fdcan_init_ext_filter_ram() to have more control over filtering configuration.
294 * Note that if you do so, your code won't be compatible with STM32G4 controllers.
295 *
296 * @param [in] canport FDCAN block base address. See @ref fdcan_block.
297 * @param [in] std_filt requested amount of standard ID filter rules (0-28)
298 * @param [in] ext_filt requested amount of extended ID filter rules (0-8)
299 */
300void fdcan_init_filter(uint32_t canport, uint8_t std_filt, uint8_t ext_filt)
301{
302 struct fdcan_standard_filter *lfssa;
303 struct fdcan_extended_filter *lfesa;
304
305 int can_id = FDCAN_BLOCK_ID(canport);
306
307 int lfsofs = 0;
308 int lfeofs = 0;
309 int lfssize = std_filt * sizeof(struct fdcan_standard_filter);
310 int lfesize = ext_filt * sizeof(struct fdcan_extended_filter);
311
312 if (can_id == 0) {
313 lfsofs = 0;
314 lfeofs = lfssize;
315 } else {
316 lfsofs = CAN_MSG_BASE + CAN_MSG_SIZE - lfssize;
317 lfeofs = lfsofs - lfesize;
318 }
319
320 fdcan_init_std_filter_ram(canport, lfsofs, 28);
321 fdcan_init_ext_filter_ram(canport, lfeofs, 8);
322
323 lfssa = fdcan_get_flssa_addr(canport);
324 lfesa = fdcan_get_flesa_addr(canport);
325
326 /* Only perform initialization of message RAM if there are
327 * any filters required
328 */
329 if (std_filt > 0) {
330 for (int q = 0; q < 28; ++q) {
331 lfssa[q].type_id1_conf_id2 = 0;
332 }
333 }
334
335 if (ext_filt > 0) {
336 for (int q = 0; q < 8; ++q) {
337 lfesa[q].conf_id1 = 0;
338 lfesa[q].type_id2 = 0;
339 }
340 }
341}
342
343/** Enable FDCAN operation after FDCAN block has been set up.
344 *
345 * This function will disable FDCAN configuration effectively
346 * allowing FDCAN to sync up with the bus. After calling this function
347 * it is not possible to reconfigure amount of filter rules, yet
348 * it is possible to configure rules themselves. FDCAN block operation
349 * state can be checked using @ref fdcan_get_init_state.
350 *
351 * @param [in] canport FDCAN block base address. See @ref fdcan_block.
352 * @param [in] timeout Amount of empty busy loops, which routine should wait for FDCAN
353 * confirming that it left INIT mode. If set to 0, function will return
354 * immediately.
355 * @returns Operation error status. See @ref fdcan_error.
356 * @note If this function returns with timeout, it usually means that
357 * FDCAN_clk is not set up properly.
358 */
359int fdcan_start(uint32_t canport, uint32_t timeout)
360{
361 /* This block detects obviously invalid configuration of
362 * RX FIFOs and TX buffers. Such situation may happen
363 * if code originally targeted for STM32G4 is compiled for
364 * STM32H7. This code is not aware of H7 abilities and
365 * leaves this stuff unconfigured. We pick up here and
366 * assume, that the code wants the FDCAN to behave as if
367 * it was STM32G4. Therefore we will configure two three entry
368 * long RX FIFOs, three entry long TX event buffer and three
369 * entry long TX FIFO/queue here.
370 */
371 if (FDCAN_RXFIFO_OFFSET(canport, 0) == 0
372 && FDCAN_RXFIFO_OFFSET(canport, 1) == 0
373 && FDCAN_TXBUF_OFFSET(canport) == 0
374 && FDCAN_TXEVT_OFFSET(canport) == 0
375 && FDCAN_RXESC(canport) == 0
376 && FDCAN_TXESC(canport) == 0
377 ) {
378 /* These sizes are fixed based on what G4 contains. */
379 int fifo0_size = 3 * sizeof(struct fdcan_rx_fifo_element);
380 int fifo1_size = fifo0_size;
381 int txevt_size = 3 * sizeof(struct fdcan_tx_event_element);
382 int txbuf_size = 3 * sizeof(struct fdcan_tx_buffer_element);
383
384 fdcan_set_rx_element_size(canport, 0, 64, 64);
385 fdcan_set_tx_element_size(canport, 64);
386
387 /* At this point we simply assume that FLSSA and FLESA were
388 * set up by calling fdcan_init_filter(). It they weren't,
389 * there just won't be allocated any space for them.
390 * That's not a problem as after fdcan_start returns, it is
391 * not possible to configure filter amount anymore.
392 *
393 * Default approach is to configure CAN1 to occupy bottom
394 * of message RAM and CAN1 to occupy top of message RAM keeping
395 * large unused space in between. This ensures that even if someone
396 * starts playing with CAN1, "implicit" configuration of CAN2 done
397 * here won't break things magically.
398 */
399 if (FDCAN_BLOCK_ID(canport) == 0) {
400 /* CAN1 will use bottom-up layout with
401 * FLSSA < FLESA < F0SA < F1SA < TXESA < TXBSA
402 * Rx buffer is not used.
403 */
404 fdcan_init_fifo_ram(canport, 0,
405 FDCAN_LFESA_OFFSET(canport)
406 + FDCAN_LSE_COUNT(canport) * sizeof(struct fdcan_extended_filter),
407 3);
408 fdcan_init_fifo_ram(canport, 1,
409 FDCAN_RXFIFO_OFFSET(canport, 0) + fifo0_size, 3);
411 FDCAN_RXFIFO_OFFSET(canport, 1) + fifo1_size, 3);
413 FDCAN_TXEVT_OFFSET(canport) + txevt_size, 3);
414 } else {
415 /* LFESA might be uninitialized. In such case
416 * we forge it's address at the end of MSG RAM
417 */
418 int lfesa_offs = FDCAN_LFESA_OFFSET(canport);
419 if (lfesa_offs == 0) {
420 lfesa_offs = CAN_MSG_SIZE;
421 }
422 /* CAN2 will use top-down layout with
423 * TXBSA < TXESA < F1SA < F0SA < FLESA < FLSSA
424 * Rx buffer is not used.
425 * This arrangement should ensure that even if
426 * CAN1 was configured manually, CAN2 default
427 * configuration should not break CAN1.
428 */
429 fdcan_init_fifo_ram(canport, 0, lfesa_offs - fifo0_size, 3);
430 fdcan_init_fifo_ram(canport, 1,
431 FDCAN_RXFIFO_OFFSET(canport, 0) - fifo1_size, 3);
433 FDCAN_RXFIFO_OFFSET(canport, 1) - txevt_size, 3);
435 FDCAN_TXEVT_OFFSET(canport) - txbuf_size, 3);
436 }
437
438 }
439 /* Error here usually means, that FDCAN_clk is not set up
440 * correctly, or at all. This usually can't be seen above
441 * when INIT is set to 1, because default value for INIT is
442 * 1 as long as one has FDCAN_pclk configured properly.
443 **/
444 if (fdcan_cccr_init_cfg(canport, false, timeout) != 0) {
445 return FDCAN_E_TIMEOUT;
446 }
447
448 return FDCAN_E_OK;
449}
450
451/** Configure FDCAN FIFO lock mode
452 *
453 * This function allows to choose between locked and overewrite mode of FIFOs. In locked mode,
454 * whenever FIFO is full and new frame arrives, which would normally been stored into given
455 * FIFO, then frame is dropped. If overwrite mode is active, then most recent message in FIFO
456 * is rewritten by frame just received.
457 * @param [in] canport FDCAN block base address. See @ref fdcan_block.
458 * @param [in] locked true activates locked mode, false activates overwrite mode
459 */
460void fdcan_set_fifo_locked_mode(uint32_t canport, bool locked)
461{
462 if (locked) {
463 FDCAN_RXF0C(canport) &= ~(FDCAN_RXF0C_F0OM);
464 FDCAN_RXF1C(canport) &= ~(FDCAN_RXF1C_F1OM);
465 } else {
466 FDCAN_RXF0C(canport) |= FDCAN_RXF0C_F0OM;
467 FDCAN_RXF1C(canport) |= FDCAN_RXF1C_F1OM;
468 }
469}
470
471/**@}*/
#define FDCAN_LSE_COUNT(can_base)
Definition: fdcan.c:53
uint8_t fdcan_dlc_to_length(uint32_t dlc)
Converts DLC value into frame payload length.
Definition: fdcan_common.c:221
int fdcan_cccr_init_cfg(uint32_t canport, bool set, uint32_t timeout)
Routine implementing FDCAN_CCCR's INIT bit manipulation.
Definition: fdcan_common.c:41
struct fdcan_standard_filter * fdcan_get_flssa_addr(uint32_t canport)
Returns standard filter start address in message RAM.
Definition: fdcan_common.c:124
struct fdcan_extended_filter * fdcan_get_flesa_addr(uint32_t canport)
Returns extended filter start address in message RAM.
Definition: fdcan_common.c:136
uint32_t fdcan_length_to_dlc(uint8_t length)
Converts frame length to DLC value.
Definition: fdcan_common.c:197
#define FDCAN_RXESC_RBDS_SHIFT
Definition: h7/fdcan.h:195
#define FDCAN_TXEFC_EFSA_SHIFT
Definition: h7/fdcan.h:151
#define FDCAN_SIDFC_LSS_SHIFT
Definition: h7/fdcan.h:124
#define FDCAN_TXBC_TBSA_MASK
TBSA[7:0]: Transmit buffer start address.
Definition: h7/fdcan.h:143
#define FDCAN_TXESC_TBDS_MASK
TBDS[3:0]: TX buffer data field size.
Definition: h7/fdcan.h:206
#define FDCAN_TXEVT_OFFSET(can_base)
Definition: h7/fdcan.h:241
#define FDCAN_RXFIC_FIS_SHIFT
Definition: h7/fdcan.h:159
#define FDCAN_RXFIC_FISA_MASK
Definition: h7/fdcan.h:162
#define FDCAN_SIDFC(can_base)
Definition: h7/fdcan.h:47
#define FDCAN_TXBUF_OFFSET(can_base)
Definition: h7/fdcan.h:238
#define FDCAN_TXEFC_EFS_SHIFT
Definition: h7/fdcan.h:147
#define FDCAN_XIDFC_FLESA_SHIFT
Definition: h7/fdcan.h:136
#define FDCAN_RXF0C_F0OM
Definition: h7/fdcan.h:165
#define FDCAN_TXBC_TFQS_MASK
TFQS[5:0]: Tx FIFO/Queue size.
Definition: h7/fdcan.h:139
#define FDCAN_BLOCK_ID(can_base)
Definition: fdcan.h:42
#define FDCAN_RXESC_F0DS_MASK
F0DS[3:0]: FIFO0 data field size.
Definition: h7/fdcan.h:198
#define FDCAN_RXF1C_F1OM
Definition: h7/fdcan.h:179
#define FDCAN_TXBC_TBSA_SHIFT
Definition: h7/fdcan.h:144
#define FDCAN_XIDFC_LSE_SHIFT
Definition: h7/fdcan.h:132
#define FDCAN_TXEFC_EFSA_MASK
EFSA[7:0]: (Transmit) event FIFO start address.
Definition: h7/fdcan.h:150
#define FDCAN_TXESC_TBDS_SHIFT
Definition: h7/fdcan.h:207
#define FDCAN_SIDFC_FLSSA_SHIFT
Definition: h7/fdcan.h:128
#define FDCAN_TXEFC(can_base)
Definition: h7/fdcan.h:78
#define FDCAN_RXFIFO_OFFSET(can_base, fifo_id)
Definition: h7/fdcan.h:235
#define FDCAN_RXESC_F0DS_SHIFT
Definition: h7/fdcan.h:199
#define FDCAN_RXFIC_FIS_MASK
Definition: h7/fdcan.h:158
#define FDCAN_LFESA_OFFSET(can_base)
Definition: h7/fdcan.h:232
#define FDCAN_TXBC_TFQS_SHIFT
Definition: h7/fdcan.h:140
#define FDCAN_TXESC(can_base)
Definition: h7/fdcan.h:70
#define FDCAN_TXBC(can_base)
Definition: fdcan.h:87
#define FDCAN_RXFIC_FISA_SHIFT
Definition: h7/fdcan.h:163
#define CAN_MSG_SIZE
Definition: h7/fdcan.h:43
#define FDCAN_RXF1C(can_base)
Definition: h7/fdcan.h:62
#define FDCAN_TXEFC_EFS_MASK
Definition: h7/fdcan.h:146
#define FDCAN_RXESC_F1DS_SHIFT
Definition: h7/fdcan.h:203
#define FDCAN_RXFIC(can_base, fifo_id)
Definition: h7/fdcan.h:58
#define FDCAN_RXF0C(can_base)
Definition: h7/fdcan.h:61
#define FDCAN_XIDFC(can_base)
Definition: h7/fdcan.h:48
#define FDCAN_RXESC(can_base)
Definition: h7/fdcan.h:69
#define FDCAN_E_TIMEOUT
Timeout waiting for FDCAN block to accept INIT bit change.
Definition: fdcan.h:739
#define FDCAN_E_OK
No error.
Definition: fdcan.h:733
#define FDCAN_E_INVALID
Value provided was invalid (FIFO index, FDCAN block base address, length, etc.)
Definition: fdcan.h:742
void fdcan_init_tx_event_ram(uint32_t canport, uint32_t tesa, uint8_t tes)
Initialize allocation of transmit event block in CAN message RAM.
Definition: fdcan.c:163
int fdcan_set_rx_element_size(uint32_t canport, uint8_t rxbuf, uint8_t rxfifo0, uint8_t rxfifo1)
Initialize size of data fields in reception buffers.
Definition: fdcan.c:209
void fdcan_init_fifo_ram(uint32_t canport, unsigned fifo_id, uint32_t fxsa, uint8_t fxs)
Initialize allocation of FIFO block in CAN message RAM.
Definition: fdcan.c:143
void fdcan_set_fifo_locked_mode(uint32_t canport, bool locked)
Configure FDCAN FIFO lock mode.
Definition: fdcan.c:460
int fdcan_start(uint32_t canport, uint32_t timeout)
Enable FDCAN operation after FDCAN block has been set up.
Definition: fdcan.c:359
void fdcan_init_std_filter_ram(uint32_t canport, uint32_t flssa, uint8_t lss)
Initialize allocation of standard filter block in CAN message RAM.
Definition: fdcan.c:111
void fdcan_init_tx_buffer_ram(uint32_t canport, uint32_t tbsa, uint8_t tbs)
Initialize allocation of transmit queue block in CAN message RAM.
Definition: fdcan.c:183
int fdcan_set_tx_element_size(uint32_t canport, uint8_t txbuf)
Initialize size of data fields in transmit buffers.
Definition: fdcan.c:261
void fdcan_init_ext_filter_ram(uint32_t canport, uint32_t flesa, uint8_t lse)
Initialize allocation of extended filter block in CAN message RAM.
Definition: fdcan.c:127
unsigned fdcan_get_fifo_element_size(uint32_t canport, unsigned fifo_id)
Returns actual size of FIFO entry in FIFO for given CAN port and FIFO.
Definition: fdcan.c:72
void fdcan_init_filter(uint32_t canport, uint8_t std_filt, uint8_t ext_filt)
Configure amount of filters and initialize filtering block.
Definition: fdcan.c:300
unsigned fdcan_get_txbuf_element_size(uint32_t canport)
Returns actual size of transmit entry in transmit queue/FIFO for given CAN port.
Definition: fdcan.c:94
#define CAN_MSG_BASE
Structure describing extended ID filters.
Definition: fdcan.h:585
uint32_t type_id2
Aggregate of filter type and extended ID or mask.
Definition: fdcan.h:589
uint32_t conf_id1
Aggregate of filter action and extended ID.
Definition: fdcan.h:587
Structure describing receive FIFO element.
Definition: fdcan.h:661
Structure describing standard ID filter.
Definition: fdcan.h:512
uint32_t type_id1_conf_id2
Aggregate of filter type, filter action and two IDs
Definition: fdcan.h:514
Structure describing transmit buffer element.
Definition: fdcan.h:687
Structure describing transmit event element.
Definition: fdcan.h:674