RTEMS 6.1-rc6
Loading...
Searching...
No Matches
fsl_flexcan.h
1/*
2 * Copyright (c) 2015, Freescale Semiconductor, Inc.
3 * Copyright 2016-2022 NXP
4 * All rights reserved.
5 *
6 * SPDX-License-Identifier: BSD-3-Clause
7 */
8#ifndef _FSL_FLEXCAN_H_
9#define _FSL_FLEXCAN_H_
10
11#include "fsl_common.h"
12
18/******************************************************************************
19 * Definitions
20 *****************************************************************************/
21
25#define FSL_FLEXCAN_DRIVER_VERSION (MAKE_VERSION(2, 9, 2))
28#if !(defined(FLEXCAN_WAIT_TIMEOUT) && FLEXCAN_WAIT_TIMEOUT)
29/* Define to 1000 means keep waiting 1000 times until the flag is assert/deassert. */
30#define FLEXCAN_WAIT_TIMEOUT (1000U)
31#endif
32
34#if (defined(FSL_FEATURE_FLEXCAN_HAS_FLEXIBLE_DATA_RATE) && FSL_FEATURE_FLEXCAN_HAS_FLEXIBLE_DATA_RATE)
35#define DLC_LENGTH_DECODE(dlc) (((dlc) <= 8U) ? (dlc) : (((dlc) <= 12U) ? (((dlc)-6U) * 4U) : (((dlc)-11U) * 16U)))
36#endif
37
39#define FLEXCAN_ID_STD(id) \
40 (((uint32_t)(((uint32_t)(id)) << CAN_ID_STD_SHIFT)) & CAN_ID_STD_MASK)
41#define FLEXCAN_ID_EXT(id) \
42 (((uint32_t)(((uint32_t)(id)) << CAN_ID_EXT_SHIFT)) & \
43 (CAN_ID_EXT_MASK | CAN_ID_STD_MASK))
46#define FLEXCAN_RX_MB_STD_MASK(id, rtr, ide) \
47 (((uint32_t)((uint32_t)(rtr) << 31) | (uint32_t)((uint32_t)(ide) << 30)) | \
48 FLEXCAN_ID_STD(id))
49#define FLEXCAN_RX_MB_EXT_MASK(id, rtr, ide) \
50 (((uint32_t)((uint32_t)(rtr) << 31) | (uint32_t)((uint32_t)(ide) << 30)) | \
51 FLEXCAN_ID_EXT(id))
54#define FLEXCAN_RX_FIFO_STD_MASK_TYPE_A(id, rtr, ide) \
55 (((uint32_t)((uint32_t)(rtr) << 31) | (uint32_t)((uint32_t)(ide) << 30)) | \
56 (FLEXCAN_ID_STD(id) << 1))
57#define FLEXCAN_RX_FIFO_STD_MASK_TYPE_B_HIGH(id, rtr, ide) \
58 (((uint32_t)((uint32_t)(rtr) << 31) | (uint32_t)((uint32_t)(ide) << 30)) | \
59 (((uint32_t)(id)&0x7FF) << 19))
60#define FLEXCAN_RX_FIFO_STD_MASK_TYPE_B_LOW(id, rtr, ide) \
61 (((uint32_t)((uint32_t)(rtr) << 15) | (uint32_t)((uint32_t)(ide) << 14)) | \
62 (((uint32_t)(id)&0x7FF) << 3))
63#define FLEXCAN_RX_FIFO_STD_MASK_TYPE_C_HIGH(id) \
64 (((uint32_t)(id)&0x7F8) << 21)
65#define FLEXCAN_RX_FIFO_STD_MASK_TYPE_C_MID_HIGH(id) \
66 (((uint32_t)(id)&0x7F8) << 13)
67#define FLEXCAN_RX_FIFO_STD_MASK_TYPE_C_MID_LOW(id) \
68 (((uint32_t)(id)&0x7F8) << 5)
69#define FLEXCAN_RX_FIFO_STD_MASK_TYPE_C_LOW(id) \
70 (((uint32_t)(id)&0x7F8) >> 3)
71#define FLEXCAN_RX_FIFO_EXT_MASK_TYPE_A(id, rtr, ide) \
72 (((uint32_t)((uint32_t)(rtr) << 31) | (uint32_t)((uint32_t)(ide) << 30)) | \
73 (FLEXCAN_ID_EXT(id) << 1))
74#define FLEXCAN_RX_FIFO_EXT_MASK_TYPE_B_HIGH(id, rtr, ide) \
75 ( \
76 ((uint32_t)((uint32_t)(rtr) << 31) | (uint32_t)((uint32_t)(ide) << 30)) | \
77 ((FLEXCAN_ID_EXT(id) & 0x1FFF8000) \
78 << 1))
79#define FLEXCAN_RX_FIFO_EXT_MASK_TYPE_B_LOW(id, rtr, ide) \
80 (((uint32_t)((uint32_t)(rtr) << 15) | (uint32_t)((uint32_t)(ide) << 14)) | \
81 ((FLEXCAN_ID_EXT(id) & 0x1FFF8000) >> \
82 15))
83#define FLEXCAN_RX_FIFO_EXT_MASK_TYPE_C_HIGH(id) \
84 ((FLEXCAN_ID_EXT(id) & 0x1FE00000) << 3)
85#define FLEXCAN_RX_FIFO_EXT_MASK_TYPE_C_MID_HIGH(id) \
86 ((FLEXCAN_ID_EXT(id) & 0x1FE00000) >> \
87 5)
88#define FLEXCAN_RX_FIFO_EXT_MASK_TYPE_C_MID_LOW(id) \
89 ((FLEXCAN_ID_EXT(id) & 0x1FE00000) >> \
90 13)
91#define FLEXCAN_RX_FIFO_EXT_MASK_TYPE_C_LOW(id) \
92 ((FLEXCAN_ID_EXT(id) & 0x1FE00000) >> 21)
95#define FLEXCAN_RX_FIFO_STD_FILTER_TYPE_A(id, rtr, ide) \
96 FLEXCAN_RX_FIFO_STD_MASK_TYPE_A(id, rtr, ide)
97#define FLEXCAN_RX_FIFO_STD_FILTER_TYPE_B_HIGH(id, rtr, ide) \
98 FLEXCAN_RX_FIFO_STD_MASK_TYPE_B_HIGH( \
99 id, rtr, ide)
100#define FLEXCAN_RX_FIFO_STD_FILTER_TYPE_B_LOW(id, rtr, ide) \
101 FLEXCAN_RX_FIFO_STD_MASK_TYPE_B_LOW( \
102 id, rtr, ide)
103#define FLEXCAN_RX_FIFO_STD_FILTER_TYPE_C_HIGH(id) \
104 FLEXCAN_RX_FIFO_STD_MASK_TYPE_C_HIGH( \
105 id)
106#define FLEXCAN_RX_FIFO_STD_FILTER_TYPE_C_MID_HIGH(id) \
107 FLEXCAN_RX_FIFO_STD_MASK_TYPE_C_MID_HIGH( \
108 id)
109#define FLEXCAN_RX_FIFO_STD_FILTER_TYPE_C_MID_LOW(id) \
110 FLEXCAN_RX_FIFO_STD_MASK_TYPE_C_MID_LOW( \
111 id)
112#define FLEXCAN_RX_FIFO_STD_FILTER_TYPE_C_LOW(id) \
113 FLEXCAN_RX_FIFO_STD_MASK_TYPE_C_LOW( \
114 id)
115#define FLEXCAN_RX_FIFO_EXT_FILTER_TYPE_A(id, rtr, ide) \
116 FLEXCAN_RX_FIFO_EXT_MASK_TYPE_A(id, rtr, ide)
117#define FLEXCAN_RX_FIFO_EXT_FILTER_TYPE_B_HIGH(id, rtr, ide) \
118 FLEXCAN_RX_FIFO_EXT_MASK_TYPE_B_HIGH( \
119 id, rtr, ide)
120#define FLEXCAN_RX_FIFO_EXT_FILTER_TYPE_B_LOW(id, rtr, ide) \
121 FLEXCAN_RX_FIFO_EXT_MASK_TYPE_B_LOW( \
122 id, rtr, ide)
123#define FLEXCAN_RX_FIFO_EXT_FILTER_TYPE_C_HIGH(id) \
124 FLEXCAN_RX_FIFO_EXT_MASK_TYPE_C_HIGH( \
125 id)
126#define FLEXCAN_RX_FIFO_EXT_FILTER_TYPE_C_MID_HIGH(id) \
127 FLEXCAN_RX_FIFO_EXT_MASK_TYPE_C_MID_HIGH( \
128 id)
129#define FLEXCAN_RX_FIFO_EXT_FILTER_TYPE_C_MID_LOW(id) \
130 FLEXCAN_RX_FIFO_EXT_MASK_TYPE_C_MID_LOW( \
131 id)
132#define FLEXCAN_RX_FIFO_EXT_FILTER_TYPE_C_LOW(id) \
133 FLEXCAN_RX_FIFO_EXT_MASK_TYPE_C_LOW(id)
135#if (defined(FSL_FEATURE_FLEXCAN_HAS_ENHANCED_RX_FIFO) && FSL_FEATURE_FLEXCAN_HAS_ENHANCED_RX_FIFO)
137#define ENHANCED_RX_FIFO_FSCH(x) (((uint32_t)(((uint32_t)(x)) << 30)) & 0xC0000000U)
138#define RTR_STD_HIGH(x) (((uint32_t)(((uint32_t)(x)) << 27)) & 0x08000000U)
139#define RTR_STD_LOW(x) (((uint32_t)(((uint32_t)(x)) << 11)) & 0x00000800U)
140#define RTR_EXT(x) (((uint32_t)(((uint32_t)(x)) << 29)) & 0x40000000U)
141#define ID_STD_LOW(id) (((uint32_t)id) & 0x7FFU)
142#define ID_STD_HIGH(id) (((uint32_t)(((uint32_t)(id)) << 16)) & 0x07FF0000U)
143#define ID_EXT(id) (((uint32_t)id) & 0x1FFFFFFFU)
146#define FLEXCAN_ENHANCED_RX_FIFO_STD_MASK_AND_FILTER(id, rtr, id_mask, rtr_mask) \
147 (ENHANCED_RX_FIFO_FSCH(0x0) | RTR_STD_HIGH(rtr) | ID_STD_HIGH(id) | RTR_STD_LOW(rtr_mask) | ID_STD_LOW(id_mask))
149#define FLEXCAN_ENHANCED_RX_FIFO_STD_FILTER_WITH_RANGE(id_upper, rtr, id_lower, rtr_mask) \
150 (ENHANCED_RX_FIFO_FSCH(0x1) | RTR_STD_HIGH(rtr) | ID_STD_HIGH(id_upper) | RTR_STD_LOW(rtr_mask) | \
151 ID_STD_LOW(id_lower))
153#define FLEXCAN_ENHANCED_RX_FIFO_STD_TWO_FILTERS(id1, rtr1, id2, rtr2) \
154 (ENHANCED_RX_FIFO_FSCH(0x2) | RTR_STD_HIGH(rtr1) | ID_STD_HIGH(id1) | RTR_STD_LOW(rtr2) | ID_STD_LOW(id2))
156#define FLEXCAN_ENHANCED_RX_FIFO_EXT_MASK_AND_FILTER_LOW(id, rtr) \
157 (ENHANCED_RX_FIFO_FSCH(0x0) | RTR_EXT(rtr) | ID_EXT(id))
159#define FLEXCAN_ENHANCED_RX_FIFO_EXT_MASK_AND_FILTER_HIGH(id_mask, rtr_mask) \
160 (ENHANCED_RX_FIFO_FSCH(0x0) | RTR_EXT(rtr_mask) | ID_EXT(id_mask))
162#define FLEXCAN_ENHANCED_RX_FIFO_EXT_FILTER_WITH_RANGE_LOW(id_upper, rtr) \
163 (ENHANCED_RX_FIFO_FSCH(0x1) | RTR_EXT(rtr) | ID_EXT(id_upper))
165#define FLEXCAN_ENHANCED_RX_FIFO_EXT_FILTER_WITH_RANGE_HIGH(id_lower, rtr_mask) \
166 (ENHANCED_RX_FIFO_FSCH(0x1) | RTR_EXT(rtr_mask) | ID_EXT(id_lower))
168#define FLEXCAN_ENHANCED_RX_FIFO_EXT_TWO_FILTERS_LOW(id2, rtr2) \
169 (ENHANCED_RX_FIFO_FSCH(0x2) | RTR_EXT(rtr2) | ID_EXT(id2))
171#define FLEXCAN_ENHANCED_RX_FIFO_EXT_TWO_FILTERS_HIGH(id1, rtr1) \
172 (ENHANCED_RX_FIFO_FSCH(0x2) | RTR_EXT(rtr1) | ID_EXT(id1))
173#endif
174
175#if (defined(FSL_FEATURE_FLEXCAN_HAS_PN_MODE) && FSL_FEATURE_FLEXCAN_HAS_PN_MODE)
177#define FLEXCAN_PN_STD_MASK(id, rtr) \
178 ((uint32_t)((uint32_t)(rtr) << CAN_FLT_ID1_FLT_RTR_SHIFT) | \
179 FLEXCAN_ID_STD(id))
180#define FLEXCAN_PN_EXT_MASK(id, rtr) \
181 ((uint32_t)CAN_FLT_ID1_FLT_IDE_MASK | (uint32_t)((uint32_t)(rtr) << CAN_FLT_ID1_FLT_RTR_SHIFT) | \
182 FLEXCAN_ID_EXT(id))
183#endif
184
186#if (defined(FSL_FEATURE_FLEXCAN_HAS_PN_MODE) && FSL_FEATURE_FLEXCAN_HAS_PN_MODE)
187#define FLEXCAN_PN_INT_MASK(x) (((uint64_t)(((uint64_t)(x)) << 32)) & 0x3000000000000U)
188#define FLEXCAN_PN_INT_UNMASK(x) (((uint32_t)(((uint64_t)(x)) >> 32)) & 0x00030000U)
189#define FLEXCAN_PN_STATUS_MASK(x) (((uint64_t)(((uint64_t)(x)) << 16)) & 0x300000000U)
190#define FLEXCAN_PN_STATUS_UNMASK(x) (((uint32_t)(((uint64_t)(x)) >> 16)) & 0x00030000U)
191#endif
192#if (defined(FSL_FEATURE_FLEXCAN_HAS_ENHANCED_RX_FIFO) && FSL_FEATURE_FLEXCAN_HAS_ENHANCED_RX_FIFO)
193#define FLEXCAN_EFIFO_INT_MASK(x) (((uint64_t)(((uint64_t)(x)) << 32)) & 0xF000000000000000U)
194#define FLEXCAN_EFIFO_INT_UNMASK(x) (((uint32_t)(((uint64_t)(x)) >> 32)) & 0xF0000000U)
195#define FLEXCAN_EFIFO_STATUS_MASK(x) (((uint64_t)(((uint64_t)(x)) << 32)) & 0xF003000000000000U)
196#define FLEXCAN_EFIFO_STATUS_UNMASK(x) (((uint32_t)(((uint64_t)(x)) >> 32)) & 0xF0030000U)
197#endif
198#if (defined(FSL_FEATURE_FLEXCAN_HAS_MEMORY_ERROR_CONTROL) && FSL_FEATURE_FLEXCAN_HAS_MEMORY_ERROR_CONTROL)
199#define FLEXCAN_MECR_INT_MASK(x) (((uint64_t)(((uint64_t)(x)) << 16)) & 0xD00000000U)
200#define FLEXCAN_MECR_INT_UNMASK(x) (((uint32_t)(((uint64_t)(x)) >> 16)) & 0x000D0000U)
201#define FLEXCAN_MECR_STATUS_MASK(x) (((uint64_t)(((uint64_t)(x)) << 34)) & 0x34003400000000U)
202#define FLEXCAN_MECR_STATUS_UNMASK(x) (((uint32_t)(((uint64_t)(x)) >> 34)) & 0x000D000DU)
203#endif
204
205#if (defined(FSL_FEATURE_FLEXCAN_HAS_FLEXIBLE_DATA_RATE) && FSL_FEATURE_FLEXCAN_HAS_FLEXIBLE_DATA_RATE)
206#define FLEXCAN_ERROR_AND_STATUS_INIT_FLAG \
207 ((uint32_t)kFLEXCAN_ErrorOverrunFlag | (uint32_t)kFLEXCAN_FDErrorIntFlag | (uint32_t)kFLEXCAN_BusoffDoneIntFlag | \
208 (uint32_t)kFLEXCAN_TxWarningIntFlag | (uint32_t)kFLEXCAN_RxWarningIntFlag | (uint32_t)kFLEXCAN_BusOffIntFlag | \
209 (uint32_t)kFLEXCAN_ErrorIntFlag | FLEXCAN_MEMORY_ERROR_INIT_FLAG)
210#else
211#define FLEXCAN_ERROR_AND_STATUS_INIT_FLAG \
212 ((uint32_t)kFLEXCAN_TxWarningIntFlag | (uint32_t)kFLEXCAN_RxWarningIntFlag | (uint32_t)kFLEXCAN_BusOffIntFlag | \
213 (uint32_t)kFLEXCAN_ErrorIntFlag | FLEXCAN_MEMORY_ERROR_INIT_FLAG)
214#endif
215#if (defined(FSL_FEATURE_FLEXCAN_HAS_PN_MODE) && FSL_FEATURE_FLEXCAN_HAS_PN_MODE)
216#define FLEXCAN_WAKE_UP_FLAG \
217 ((uint32_t)kFLEXCAN_WakeUpIntFlag | (uint64_t)kFLEXCAN_PNMatchIntFlag | (uint64_t)kFLEXCAN_PNTimeoutIntFlag)
218#else
219#define FLEXCAN_WAKE_UP_FLAG ((uint32_t)kFLEXCAN_WakeUpIntFlag)
220#endif
221#if (defined(FSL_FEATURE_FLEXCAN_HAS_MEMORY_ERROR_CONTROL) && FSL_FEATURE_FLEXCAN_HAS_MEMORY_ERROR_CONTROL)
222#define FLEXCAN_MEMORY_ERROR_INIT_FLAG ((uint64_t)kFLEXCAN_AllMemoryErrorFlag)
223#else
224#define FLEXCAN_MEMORY_ERROR_INIT_FLAG (0U)
225#endif
226
227#if (defined(FSL_FEATURE_FLEXCAN_HAS_ENHANCED_RX_FIFO) && FSL_FEATURE_FLEXCAN_HAS_ENHANCED_RX_FIFO)
228#define FLEXCAN_MEMORY_ENHANCED_RX_FIFO_INIT_FLAG \
229 ((uint64_t)kFLEXCAN_ERxFifoUnderflowIntFlag | (uint64_t)kFLEXCAN_ERxFifoOverflowIntFlag | \
230 (uint64_t)kFLEXCAN_ERxFifoWatermarkIntFlag | (uint64_t)kFLEXCAN_ERxFifoDataAvlIntFlag)
231#endif
233#if (defined(FSL_FEATURE_FLEXCAN_HAS_ENHANCED_RX_FIFO) && FSL_FEATURE_FLEXCAN_HAS_ENHANCED_RX_FIFO)
234#define E_RX_FIFO(base) ((uint32_t)(base) + 0x2000U)
235#else
236#define FLEXCAN_MEMORY_ENHANCED_RX_FIFO_INIT_FLAG (0U)
237#endif
239enum
240{
258#if (defined(FSL_FEATURE_FLEXCAN_HAS_ENHANCED_RX_FIFO) && FSL_FEATURE_FLEXCAN_HAS_ENHANCED_RX_FIFO)
259 kStatus_FLEXCAN_RxFifoUnderflow =
261#endif
262};
263
265typedef enum _flexcan_frame_format
266{
270
272typedef enum _flexcan_frame_type
273{
277
282typedef enum _flexcan_clock_source
283{
284 kFLEXCAN_ClkSrcOsc = 0x0U,
285 kFLEXCAN_ClkSrcPeri = 0x1U,
286 kFLEXCAN_ClkSrc0 = 0x0U,
287 kFLEXCAN_ClkSrc1 = 0x1U,
289
291typedef enum _flexcan_wake_up_source
292{
296
302 0x1U,
304 0x2U,
308#if (defined(FSL_FEATURE_FLEXCAN_HAS_FLEXIBLE_DATA_RATE) && FSL_FEATURE_FLEXCAN_HAS_FLEXIBLE_DATA_RATE)
312typedef enum _flexcan_mb_size
314 kFLEXCAN_8BperMB = 0x0U,
315 kFLEXCAN_16BperMB = 0x1U,
316 kFLEXCAN_32BperMB = 0x2U,
317 kFLEXCAN_64BperMB = 0x3U,
318} flexcan_mb_size_t;
319
328enum _flexcan_fd_frame_length
330 kFLEXCAN_0BperFrame = 0x0U,
331 kFLEXCAN_1BperFrame,
332 kFLEXCAN_2BperFrame,
333 kFLEXCAN_3BperFrame,
334 kFLEXCAN_4BperFrame,
335 kFLEXCAN_5BperFrame,
336 kFLEXCAN_6BperFrame,
337 kFLEXCAN_7BperFrame,
338 kFLEXCAN_8BperFrame,
339 kFLEXCAN_12BperFrame,
340 kFLEXCAN_16BperFrame,
341 kFLEXCAN_20BperFrame,
342 kFLEXCAN_24Bperrame,
343 kFLEXCAN_32BperFrame,
344 kFLEXCAN_48BperFrame,
345 kFLEXCAN_64BperFrame,
346};
347#endif
349#if (defined(FSL_FEATURE_FLEXCAN_HAS_ENHANCED_RX_FIFO) && FSL_FEATURE_FLEXCAN_HAS_ENHANCED_RX_FIFO)
351typedef enum _flexcan_efifo_dma_per_read_length
353 kFLEXCAN_1WordPerRead = 0x0U,
354 kFLEXCAN_2WordPerRead,
355 kFLEXCAN_3WordPerRead,
356 kFLEXCAN_4WordPerRead,
357 kFLEXCAN_5WordPerRead,
358 kFLEXCAN_6WordPerRead,
359 kFLEXCAN_7WordPerRead,
360 kFLEXCAN_8WordPerRead,
361 kFLEXCAN_9WordPerRead,
362 kFLEXCAN_10WordPerRead,
363 kFLEXCAN_11WordPerRead,
364 kFLEXCAN_12WordPerRead,
365 kFLEXCAN_13WordPerRead,
366 kFLEXCAN_14WordPerRead,
367 kFLEXCAN_15WordPerRead,
368 kFLEXCAN_16WordPerRead,
369 kFLEXCAN_17WordPerRead,
370 kFLEXCAN_18WordPerRead,
371 kFLEXCAN_19WordPerRead
372} flexcan_efifo_dma_per_read_length_t;
373#endif
374
382typedef enum _flexcan_rx_fifo_priority
383{
387
395{
396 kFLEXCAN_BusOffInterruptEnable = CAN_CTRL1_BOFFMSK_MASK,
397 kFLEXCAN_ErrorInterruptEnable = CAN_CTRL1_ERRMSK_MASK,
398 kFLEXCAN_TxWarningInterruptEnable = CAN_CTRL1_TWRNMSK_MASK,
399 kFLEXCAN_RxWarningInterruptEnable = CAN_CTRL1_RWRNMSK_MASK,
400 kFLEXCAN_WakeUpInterruptEnable = CAN_MCR_WAKMSK_MASK,
401#if (defined(FSL_FEATURE_FLEXCAN_HAS_FLEXIBLE_DATA_RATE) && FSL_FEATURE_FLEXCAN_HAS_FLEXIBLE_DATA_RATE)
402 kFLEXCAN_FDErrorInterruptEnable = CAN_CTRL2_ERRMSK_FAST_MASK,
403#endif
404#if (defined(FSL_FEATURE_FLEXCAN_HAS_PN_MODE) && FSL_FEATURE_FLEXCAN_HAS_PN_MODE)
406 kFLEXCAN_PNMatchWakeUpInterruptEnable = FLEXCAN_PN_INT_MASK(CAN_CTRL1_PN_WTOF_MSK_MASK),
408 kFLEXCAN_PNTimeoutWakeUpInterruptEnable = FLEXCAN_PN_INT_MASK(CAN_CTRL1_PN_WUMF_MSK_MASK),
409#endif
410#if (defined(FSL_FEATURE_FLEXCAN_HAS_ENHANCED_RX_FIFO) && FSL_FEATURE_FLEXCAN_HAS_ENHANCED_RX_FIFO)
412 kFLEXCAN_ERxFifoUnderflowInterruptEnable = FLEXCAN_EFIFO_INT_MASK(CAN_ERFIER_ERFUFWIE_MASK),
414 kFLEXCAN_ERxFifoOverflowInterruptEnable = FLEXCAN_EFIFO_INT_MASK(CAN_ERFIER_ERFOVFIE_MASK),
416 kFLEXCAN_ERxFifoWatermarkInterruptEnable = FLEXCAN_EFIFO_INT_MASK(CAN_ERFIER_ERFWMIIE_MASK),
418 kFLEXCAN_ERxFifoDataAvlInterruptEnable = FLEXCAN_EFIFO_INT_MASK(CAN_ERFIER_ERFDAIE_MASK),
419#endif
420#if (defined(FSL_FEATURE_FLEXCAN_HAS_MEMORY_ERROR_CONTROL) && FSL_FEATURE_FLEXCAN_HAS_MEMORY_ERROR_CONTROL)
422 kFLEXCAN_HostAccessNCErrorInterruptEnable = FLEXCAN_MECR_INT_MASK(CAN_MECR_HANCEI_MSK_MASK),
424 kFLEXCAN_FlexCanAccessNCErrorInterruptEnable = FLEXCAN_MECR_INT_MASK(CAN_MECR_FANCEI_MSK_MASK),
426 kFLEXCAN_HostOrFlexCanCErrorInterruptEnable = FLEXCAN_MECR_INT_MASK(CAN_MECR_CEI_MSK_MASK),
427#endif
428};
429
438{
439#if (defined(FSL_FEATURE_FLEXCAN_HAS_FLEXIBLE_DATA_RATE) && FSL_FEATURE_FLEXCAN_HAS_FLEXIBLE_DATA_RATE)
440 kFLEXCAN_ErrorOverrunFlag = CAN_ESR1_ERROVR_MASK,
441 kFLEXCAN_FDErrorIntFlag = CAN_ESR1_ERRINT_FAST_MASK,
442 kFLEXCAN_BusoffDoneIntFlag = CAN_ESR1_BOFFDONEINT_MASK,
443#endif
444 kFLEXCAN_SynchFlag = CAN_ESR1_SYNCH_MASK,
445 kFLEXCAN_TxWarningIntFlag = CAN_ESR1_TWRNINT_MASK,
446 kFLEXCAN_RxWarningIntFlag = CAN_ESR1_RWRNINT_MASK,
447 kFLEXCAN_IdleFlag = CAN_ESR1_IDLE_MASK,
448 kFLEXCAN_FaultConfinementFlag = CAN_ESR1_FLTCONF_MASK,
449 kFLEXCAN_TransmittingFlag = CAN_ESR1_TX_MASK,
450 kFLEXCAN_ReceivingFlag = CAN_ESR1_RX_MASK,
451 kFLEXCAN_BusOffIntFlag = CAN_ESR1_BOFFINT_MASK,
452 kFLEXCAN_ErrorIntFlag = CAN_ESR1_ERRINT_MASK,
453 kFLEXCAN_WakeUpIntFlag = CAN_ESR1_WAKINT_MASK,
454 kFLEXCAN_ErrorFlag =
455 (uint32_t)(
456#if (defined(FSL_FEATURE_FLEXCAN_HAS_FLEXIBLE_DATA_RATE) && FSL_FEATURE_FLEXCAN_HAS_FLEXIBLE_DATA_RATE)
457 CAN_ESR1_STFERR_FAST_MASK | CAN_ESR1_FRMERR_FAST_MASK | CAN_ESR1_CRCERR_FAST_MASK |
458 CAN_ESR1_BIT0ERR_FAST_MASK | CAN_ESR1_BIT1ERR_FAST_MASK | CAN_ESR1_ERROVR_MASK |
459#endif
460 CAN_ESR1_TXWRN_MASK | CAN_ESR1_RXWRN_MASK | CAN_ESR1_BIT1ERR_MASK | CAN_ESR1_BIT0ERR_MASK |
461 CAN_ESR1_ACKERR_MASK | CAN_ESR1_CRCERR_MASK | CAN_ESR1_FRMERR_MASK | CAN_ESR1_STFERR_MASK),
462#if (defined(FSL_FEATURE_FLEXCAN_HAS_PN_MODE) && FSL_FEATURE_FLEXCAN_HAS_PN_MODE)
463 kFLEXCAN_PNMatchIntFlag = FLEXCAN_PN_STATUS_MASK(CAN_WU_MTC_WUMF_MASK),
464 kFLEXCAN_PNTimeoutIntFlag = FLEXCAN_PN_STATUS_MASK(CAN_WU_MTC_WTOF_MASK),
465#endif
466#if (defined(FSL_FEATURE_FLEXCAN_HAS_ENHANCED_RX_FIFO) && FSL_FEATURE_FLEXCAN_HAS_ENHANCED_RX_FIFO)
467 kFLEXCAN_ERxFifoUnderflowIntFlag =
468 FLEXCAN_EFIFO_STATUS_MASK(CAN_ERFSR_ERFUFW_MASK),
469 kFLEXCAN_ERxFifoOverflowIntFlag =
470 FLEXCAN_EFIFO_STATUS_MASK(CAN_ERFSR_ERFOVF_MASK),
471 kFLEXCAN_ERxFifoWatermarkIntFlag =
472 FLEXCAN_EFIFO_STATUS_MASK(CAN_ERFSR_ERFWMI_MASK),
473 kFLEXCAN_ERxFifoDataAvlIntFlag =
474 FLEXCAN_EFIFO_STATUS_MASK(CAN_ERFSR_ERFDA_MASK),
475 kFLEXCAN_ERxFifoEmptyFlag = FLEXCAN_EFIFO_STATUS_MASK(CAN_ERFSR_ERFE_MASK),
476 kFLEXCAN_ERxFifoFullFlag = FLEXCAN_EFIFO_STATUS_MASK(CAN_ERFSR_ERFF_MASK),
477#endif
478#if (defined(FSL_FEATURE_FLEXCAN_HAS_MEMORY_ERROR_CONTROL) && FSL_FEATURE_FLEXCAN_HAS_MEMORY_ERROR_CONTROL)
480 kFLEXCAN_HostAccessNonCorrectableErrorIntFlag = FLEXCAN_MECR_INT_MASK(CAN_ERRSR_HANCEIF_MASK),
482 kFLEXCAN_FlexCanAccessNonCorrectableErrorIntFlag = FLEXCAN_MECR_INT_MASK(CAN_ERRSR_FANCEIF_MASK),
484 kFLEXCAN_CorrectableErrorIntFlag = FLEXCAN_MECR_INT_MASK(CAN_ERRSR_CEIF_MASK),
486 kFLEXCAN_HostAccessNonCorrectableErrorOverrunFlag = FLEXCAN_MECR_INT_MASK(CAN_ERRSR_HANCEIOF_MASK),
488 kFLEXCAN_FlexCanAccessNonCorrectableErrorOverrunFlag = FLEXCAN_MECR_INT_MASK(CAN_ERRSR_FANCEIOF_MASK),
490 kFLEXCAN_CorrectableErrorOverrunFlag = FLEXCAN_MECR_INT_MASK(CAN_ERRSR_CEIOF_MASK),
492 kFLEXCAN_AllMemoryErrorFlag =
493 (kFLEXCAN_HostAccessNonCorrectableErrorIntFlag | kFLEXCAN_FlexCanAccessNonCorrectableErrorIntFlag |
494 kFLEXCAN_CorrectableErrorIntFlag | kFLEXCAN_HostAccessNonCorrectableErrorOverrunFlag |
495 kFLEXCAN_FlexCanAccessNonCorrectableErrorOverrunFlag | kFLEXCAN_CorrectableErrorOverrunFlag)
496#endif
497};
498
508#if (defined(FSL_FEATURE_FLEXCAN_HAS_FLEXIBLE_DATA_RATE) && FSL_FEATURE_FLEXCAN_HAS_FLEXIBLE_DATA_RATE)
509 kFLEXCAN_FDStuffingError = CAN_ESR1_STFERR_FAST_MASK,
510 kFLEXCAN_FDFormError = CAN_ESR1_FRMERR_FAST_MASK,
511 kFLEXCAN_FDCrcError = CAN_ESR1_CRCERR_FAST_MASK,
512 kFLEXCAN_FDBit0Error = CAN_ESR1_BIT0ERR_FAST_MASK,
513 kFLEXCAN_FDBit1Error = (int)CAN_ESR1_BIT1ERR_FAST_MASK,
514#endif
515 kFLEXCAN_TxErrorWarningFlag = CAN_ESR1_TXWRN_MASK,
516 kFLEXCAN_RxErrorWarningFlag = CAN_ESR1_RXWRN_MASK,
517 kFLEXCAN_StuffingError = CAN_ESR1_STFERR_MASK,
518 kFLEXCAN_FormError = CAN_ESR1_FRMERR_MASK,
519 kFLEXCAN_CrcError = CAN_ESR1_CRCERR_MASK,
520 kFLEXCAN_AckError = CAN_ESR1_ACKERR_MASK,
521 kFLEXCAN_Bit0Error = CAN_ESR1_BIT0ERR_MASK,
522 kFLEXCAN_Bit1Error = CAN_ESR1_BIT1ERR_MASK,
523};
524
533enum
534{
535 kFLEXCAN_RxFifoOverflowFlag = CAN_IFLAG1_BUF7I_MASK,
536 kFLEXCAN_RxFifoWarningFlag = CAN_IFLAG1_BUF6I_MASK,
537 kFLEXCAN_RxFifoFrameAvlFlag = CAN_IFLAG1_BUF5I_MASK,
538};
539
540#if (defined(FSL_FEATURE_FLEXCAN_HAS_MEMORY_ERROR_CONTROL) && FSL_FEATURE_FLEXCAN_HAS_MEMORY_ERROR_CONTROL)
544typedef enum _flexcan_memory_error_type
545{
546 kFLEXCAN_CorrectableError = 0U,
547 kFLEXCAN_NonCorrectableError
548} flexcan_memory_error_type_t;
549
553typedef enum _flexcan_memory_access_type
554{
555 kFLEXCAN_MoveOutFlexCanAccess = 0U,
556 kFLEXCAN_MoveInAccess,
557 kFLEXCAN_TxArbitrationAccess,
558 kFLEXCAN_RxMatchingAccess,
559 kFLEXCAN_MoveOutHostAccess
560} flexcan_memory_access_type_t;
561
565typedef enum _flexcan_byte_error_syndrome
566{
567 kFLEXCAN_NoError = 0U,
568 kFLEXCAN_ParityBits0Error = 1U,
569 kFLEXCAN_ParityBits1Error = 2U,
570 kFLEXCAN_ParityBits2Error = 4U,
571 kFLEXCAN_ParityBits3Error = 8U,
572 kFLEXCAN_ParityBits4Error = 16U,
573 kFLEXCAN_DataBits0Error = 28U,
574 kFLEXCAN_DataBits1Error = 22U,
575 kFLEXCAN_DataBits2Error = 19U,
576 kFLEXCAN_DataBits3Error = 25U,
577 kFLEXCAN_DataBits4Error = 26U,
578 kFLEXCAN_DataBits5Error = 7U,
579 kFLEXCAN_DataBits6Error = 21U,
580 kFLEXCAN_DataBits7Error = 14U,
581 kFLEXCAN_AllZeroError = 6U,
582 kFLEXCAN_AllOneError = 31U,
583 kFLEXCAN_NonCorrectableErrors
584} flexcan_byte_error_syndrome_t;
585
593typedef struct _flexcan_memory_error_report_status
595 flexcan_memory_error_type_t errorType;
596 flexcan_memory_access_type_t accessType;
597 uint16_t accessAddress;
598 uint32_t errorData;
599 struct
600 {
601 bool byteIsRead;
603 flexcan_byte_error_syndrome_t bitAffected;
604 } byteStatus[4];
605} flexcan_memory_error_report_status_t;
606#endif
607
608#if defined(__CC_ARM)
609#pragma anon_unions
610#endif
612typedef struct _flexcan_frame
613{
614 struct
615 {
616 uint32_t timestamp : 16;
617 uint32_t length : 4;
618 uint32_t type : 1;
619 uint32_t format : 1;
620 uint32_t : 1;
621 uint32_t idhit : 9;
622 };
623 struct
624 {
625 uint32_t id : 29;
626 uint32_t : 3;
627 };
628 union
629 {
630 struct
631 {
632 uint32_t dataWord0;
633 uint32_t dataWord1;
634 };
635 struct
636 {
637 uint8_t dataByte3;
638 uint8_t dataByte2;
639 uint8_t dataByte1;
640 uint8_t dataByte0;
641 uint8_t dataByte7;
642 uint8_t dataByte6;
643 uint8_t dataByte5;
644 uint8_t dataByte4;
645 };
646 };
648
649#if (defined(FSL_FEATURE_FLEXCAN_HAS_FLEXIBLE_DATA_RATE) && FSL_FEATURE_FLEXCAN_HAS_FLEXIBLE_DATA_RATE)
655typedef struct _flexcan_fd_frame
656{
657 struct
658 {
659 uint32_t timestamp : 16;
660 uint32_t length : 4;
664 uint32_t type : 1;
665 uint32_t format : 1;
666 uint32_t srr : 1;
667 uint32_t : 6;
668 uint32_t esi : 1;
669 uint32_t brs : 1;
670 uint32_t edl : 1;
671 };
672 struct
674 uint32_t id : 29;
675 uint32_t : 3;
676 };
677 union
679 struct
680 {
681 uint32_t dataWord[16];
682 };
683 /* Note: the maximum databyte* below is actually 64, user can add them if needed,
684 or just use dataWord[*] instead. */
685 struct
686 {
687 uint8_t dataByte3;
688 uint8_t dataByte2;
689 uint8_t dataByte1;
690 uint8_t dataByte0;
691 uint8_t dataByte7;
692 uint8_t dataByte6;
693 uint8_t dataByte5;
694 uint8_t dataByte4;
695 };
696 };
697#if (defined(FSL_FEATURE_FLEXCAN_HAS_ENHANCED_RX_FIFO) && FSL_FEATURE_FLEXCAN_HAS_ENHANCED_RX_FIFO)
701 uint32_t idhit;
703#endif
704} flexcan_fd_frame_t;
705#endif
706
708typedef struct _flexcan_timing_config
709{
710 uint16_t preDivider;
711 uint8_t rJumpwidth;
712 uint8_t phaseSeg1;
713 uint8_t phaseSeg2;
714 uint8_t propSeg;
715#if (defined(FSL_FEATURE_FLEXCAN_HAS_FLEXIBLE_DATA_RATE) && FSL_FEATURE_FLEXCAN_HAS_FLEXIBLE_DATA_RATE)
716 uint16_t fpreDivider;
717 uint8_t frJumpwidth;
718 uint8_t fphaseSeg1;
719 uint8_t fphaseSeg2;
720 uint8_t fpropSeg;
721#endif
723
728typedef struct _flexcan_config
729{
730 union
731 {
732 struct
733 {
734 uint32_t baudRate;
735#if (defined(FSL_FEATURE_FLEXCAN_HAS_FLEXIBLE_DATA_RATE) && FSL_FEATURE_FLEXCAN_HAS_FLEXIBLE_DATA_RATE)
736 uint32_t baudRateFD;
737#endif
738 };
739 struct
740 {
741 uint32_t bitRate;
742#if (defined(FSL_FEATURE_FLEXCAN_HAS_FLEXIBLE_DATA_RATE) && FSL_FEATURE_FLEXCAN_HAS_FLEXIBLE_DATA_RATE)
743 uint32_t bitRateFD;
744#endif
745 };
746 };
749 uint8_t maxMbNum;
750 bool enableLoopBack;
751 bool enableTimerSync;
752 bool enableSelfWakeup;
753 bool enableIndividMask;
756#if !(defined(FSL_FEATURE_FLEXCAN_HAS_NO_SUPV_SUPPORT) && FSL_FEATURE_FLEXCAN_HAS_NO_SUPV_SUPPORT)
759#endif
760#if (defined(FSL_FEATURE_FLEXCAN_HAS_DOZE_MODE_SUPPORT) && FSL_FEATURE_FLEXCAN_HAS_DOZE_MODE_SUPPORT)
761 bool enableDoze;
762#endif
763#if (defined(FSL_FEATURE_FLEXCAN_HAS_PN_MODE) && FSL_FEATURE_FLEXCAN_HAS_PN_MODE)
764 bool enablePretendedeNetworking;
765#endif
766#if (defined(FSL_FEATURE_FLEXCAN_HAS_MEMORY_ERROR_CONTROL) && FSL_FEATURE_FLEXCAN_HAS_MEMORY_ERROR_CONTROL)
767 bool enableMemoryErrorControl;
768 bool enableNonCorrectableErrorEnterFreeze;
770#endif
771#if (defined(FSL_FEATURE_FLEXCAN_HAS_ENHANCED_BIT_TIMING_REG) && FSL_FEATURE_FLEXCAN_HAS_ENHANCED_BIT_TIMING_REG)
772 bool enableTransceiverDelayMeasure;
775#endif
776 flexcan_timing_config_t timingConfig; /* Protocol timing . */
778
788typedef struct _flexcan_rx_mb_config
789{
790 uint32_t id;
795
796#if (defined(FSL_FEATURE_FLEXCAN_HAS_PN_MODE) && FSL_FEATURE_FLEXCAN_HAS_PN_MODE)
798typedef enum _flexcan_pn_match_source
799{
800 kFLEXCAN_PNMatSrcID = 0U,
801 kFLEXCAN_PNMatSrcIDAndData,
802} flexcan_pn_match_source_t;
803
805typedef enum _flexcan_pn_match_mode
807 kFLEXCAN_PNMatModeEqual = 0x0U,
808 kFLEXCAN_PNMatModeGreater,
810 kFLEXCAN_PNMatModeSmaller,
812 kFLEXCAN_PNMatModeRange,
814} flexcan_pn_match_mode_t;
815
822typedef struct _flexcan_pn_config
823{
824 bool enableTimeout;
825 uint16_t timeoutValue;
827 bool enableMatch;
828 flexcan_pn_match_source_t matchSrc;
829 uint8_t matchNum;
831 flexcan_pn_match_mode_t idMatchMode;
832 flexcan_pn_match_mode_t dataMatchMode;
833 uint32_t idLower;
835 uint32_t idUpper;
837 uint8_t lengthLower;
839 uint8_t lengthUpper;
841 union
842 {
846 struct
848 uint32_t lowerWord0;
849 uint32_t lowerWord1;
850 };
851 struct
852 {
853 uint8_t lowerByte3;
854 uint8_t lowerByte2;
855 uint8_t lowerByte1;
856 uint8_t lowerByte0;
857 uint8_t lowerByte7;
858 uint8_t lowerByte6;
859 uint8_t lowerByte5;
860 uint8_t lowerByte4;
861 };
862 };
863 union
864 {
867 struct
868 {
869 uint32_t upperWord0;
870 uint32_t upperWord1;
871 };
872 struct
873 {
874 uint8_t upperByte3;
875 uint8_t upperByte2;
876 uint8_t upperByte1;
877 uint8_t upperByte0;
878 uint8_t upperByte7;
879 uint8_t upperByte6;
880 uint8_t upperByte5;
881 uint8_t upperByte4;
882 };
883 };
884} flexcan_pn_config_t;
885#endif
886
888typedef struct _flexcan_rx_fifo_config
889{
890 uint32_t *idFilterTable;
891 uint8_t idFilterNum;
895
896#if (defined(FSL_FEATURE_FLEXCAN_HAS_ENHANCED_RX_FIFO) && FSL_FEATURE_FLEXCAN_HAS_ENHANCED_RX_FIFO)
898typedef struct _flexcan_enhanced_rx_fifo_std_id_filter
899{
900 uint32_t filterType : 2;
901 uint32_t : 2;
902 uint32_t rtr1 : 1;
906 uint32_t std1 : 11;
907 uint32_t : 4;
908 uint32_t rtr2 : 1;
909 uint32_t std2 : 11;
910} flexcan_enhanced_rx_fifo_std_id_filter_t;
911
913typedef struct _flexcan_enhanced_rx_fifo_ext_id_filter
914{
915 uint32_t filterType : 2;
916 uint32_t rtr1 : 1;
920 uint32_t std1 : 29;
921 uint32_t : 2;
922 uint32_t rtr2 : 1;
923 uint32_t std2 : 29;
924} flexcan_enhanced_rx_fifo_ext_id_filter_t;
926typedef struct _flexcan_enhanced_rx_fifo_config
927{
928 uint32_t *idFilterTable;
933 uint8_t idFilterPairNum;
936 uint8_t extendIdFilterNum;
939 uint8_t fifoWatermark;
941 flexcan_efifo_dma_per_read_length_t dmaPerReadLength;
944} flexcan_enhanced_rx_fifo_config_t;
945#endif
946
950#if (defined(FSL_FEATURE_FLEXCAN_HAS_FLEXIBLE_DATA_RATE) && FSL_FEATURE_FLEXCAN_HAS_FLEXIBLE_DATA_RATE)
951 flexcan_fd_frame_t *framefd;
952#endif
954 uint8_t mbIdx;
956
958typedef struct _flexcan_fifo_transfer
959{
960#if (defined(FSL_FEATURE_FLEXCAN_HAS_ENHANCED_RX_FIFO) && FSL_FEATURE_FLEXCAN_HAS_ENHANCED_RX_FIFO)
961 flexcan_fd_frame_t *framefd;
962#endif
964 size_t frameNum;
966
968typedef struct _flexcan_handle flexcan_handle_t;
969
980#if (defined(FSL_FEATURE_FLEXCAN_HAS_PN_MODE) && FSL_FEATURE_FLEXCAN_HAS_PN_MODE) || \
981 (defined(FSL_FEATURE_FLEXCAN_HAS_MEMORY_ERROR_CONTROL) && FSL_FEATURE_FLEXCAN_HAS_MEMORY_ERROR_CONTROL)
982#define FLEXCAN_CALLBACK(x) \
983 void(x)(CAN_Type * base, flexcan_handle_t * handle, status_t status, uint64_t result, void *userData)
984typedef void (*flexcan_transfer_callback_t)(
985 CAN_Type *base, flexcan_handle_t *handle, status_t status, uint64_t result, void *userData);
986#else
987#define FLEXCAN_CALLBACK(x) \
988 void(x)(CAN_Type * base, flexcan_handle_t * handle, status_t status, uint32_t result, void *userData)
989typedef void (*flexcan_transfer_callback_t)(
990 CAN_Type *base, flexcan_handle_t *handle, status_t status, uint32_t result, void *userData);
991#endif
992
994struct _flexcan_handle
995{
996 flexcan_transfer_callback_t callback;
997 void *userData;
999 *volatile mbFrameBuf[CAN_WORD1_COUNT];
1000#if (defined(FSL_FEATURE_FLEXCAN_HAS_FLEXIBLE_DATA_RATE) && FSL_FEATURE_FLEXCAN_HAS_FLEXIBLE_DATA_RATE)
1001 flexcan_fd_frame_t
1002 *volatile mbFDFrameBuf[CAN_WORD1_COUNT];
1003#endif
1005#if (defined(FSL_FEATURE_FLEXCAN_HAS_ENHANCED_RX_FIFO) && FSL_FEATURE_FLEXCAN_HAS_ENHANCED_RX_FIFO)
1006 flexcan_fd_frame_t *volatile rxFifoFDFrameBuf;
1007#endif
1008 size_t rxFifoFrameNum;
1009 size_t rxFifoTransferTotalNum;
1010 volatile uint8_t mbState[CAN_WORD1_COUNT];
1011 volatile uint8_t rxFifoState;
1012 volatile uint32_t timestamp[CAN_WORD1_COUNT];
1013};
1014
1015/******************************************************************************
1016 * API
1017 *****************************************************************************/
1018
1019#if defined(__cplusplus)
1020extern "C" {
1021#endif
1036
1045
1052uint32_t FLEXCAN_GetInstance(CAN_Type *base);
1069 uint32_t bitRate,
1070 uint32_t sourceClock_Hz,
1071 flexcan_timing_config_t *pTimingConfig);
1072
1098void FLEXCAN_Init(CAN_Type *base, const flexcan_config_t *pConfig, uint32_t sourceClock_Hz);
1099
1100#if (defined(FSL_FEATURE_FLEXCAN_HAS_FLEXIBLE_DATA_RATE) && FSL_FEATURE_FLEXCAN_HAS_FLEXIBLE_DATA_RATE)
1117bool FLEXCAN_FDCalculateImprovedTimingValues(CAN_Type *base,
1118 uint32_t bitRate,
1119 uint32_t bitRateFD,
1120 uint32_t sourceClock_Hz,
1121 flexcan_timing_config_t *pTimingConfig);
1151void FLEXCAN_FDInit(
1152 CAN_Type *base, const flexcan_config_t *pConfig, uint32_t sourceClock_Hz, flexcan_mb_size_t dataSize, bool brs);
1153#endif
1154
1163void FLEXCAN_Deinit(CAN_Type *base);
1164
1187
1188/* @} */
1189
1206void FLEXCAN_SetTimingConfig(CAN_Type *base, const flexcan_timing_config_t *pConfig);
1207
1221status_t FLEXCAN_SetBitRate(CAN_Type *base, uint32_t sourceClock_Hz, uint32_t bitRate_Bps);
1222
1223#if (defined(FSL_FEATURE_FLEXCAN_HAS_FLEXIBLE_DATA_RATE) && FSL_FEATURE_FLEXCAN_HAS_FLEXIBLE_DATA_RATE)
1237void FLEXCAN_SetFDTimingConfig(CAN_Type *base, const flexcan_timing_config_t *pConfig);
1238
1251status_t FLEXCAN_SetFDBitRate(CAN_Type *base, uint32_t sourceClock_Hz, uint32_t bitRateN_Bps, uint32_t bitRateD_Bps);
1252#endif
1253
1263void FLEXCAN_SetRxMbGlobalMask(CAN_Type *base, uint32_t mask);
1264
1273void FLEXCAN_SetRxFifoGlobalMask(CAN_Type *base, uint32_t mask);
1274
1289void FLEXCAN_SetRxIndividualMask(CAN_Type *base, uint8_t maskIdx, uint32_t mask);
1290
1303void FLEXCAN_SetTxMbConfig(CAN_Type *base, uint8_t mbIdx, bool enable);
1304
1305#if (defined(FSL_FEATURE_FLEXCAN_HAS_FLEXIBLE_DATA_RATE) && FSL_FEATURE_FLEXCAN_HAS_FLEXIBLE_DATA_RATE)
1318void FLEXCAN_SetFDTxMbConfig(CAN_Type *base, uint8_t mbIdx, bool enable);
1319#endif
1320
1334void FLEXCAN_SetRxMbConfig(CAN_Type *base, uint8_t mbIdx, const flexcan_rx_mb_config_t *pRxMbConfig, bool enable);
1335
1336#if (defined(FSL_FEATURE_FLEXCAN_HAS_FLEXIBLE_DATA_RATE) && FSL_FEATURE_FLEXCAN_HAS_FLEXIBLE_DATA_RATE)
1350void FLEXCAN_SetFDRxMbConfig(CAN_Type *base, uint8_t mbIdx, const flexcan_rx_mb_config_t *pRxMbConfig, bool enable);
1351#endif
1352
1366void FLEXCAN_SetRxFifoConfig(CAN_Type *base, const flexcan_rx_fifo_config_t *pRxFifoConfig, bool enable);
1367
1368#if (defined(FSL_FEATURE_FLEXCAN_HAS_ENHANCED_RX_FIFO) && FSL_FEATURE_FLEXCAN_HAS_ENHANCED_RX_FIFO)
1383void FLEXCAN_SetEnhancedRxFifoConfig(CAN_Type *base, const flexcan_enhanced_rx_fifo_config_t *pConfig, bool enable);
1384#endif
1385
1386#if (defined(FSL_FEATURE_FLEXCAN_HAS_PN_MODE) && FSL_FEATURE_FLEXCAN_HAS_PN_MODE)
1395void FLEXCAN_SetPNConfig(CAN_Type *base, const flexcan_pn_config_t *pConfig);
1396#endif
1397/* @} */
1398
1414#if (defined(FSL_FEATURE_FLEXCAN_HAS_PN_MODE) && FSL_FEATURE_FLEXCAN_HAS_PN_MODE) || \
1415 (defined(FSL_FEATURE_FLEXCAN_HAS_ENHANCED_RX_FIFO) && FSL_FEATURE_FLEXCAN_HAS_ENHANCED_RX_FIFO) || \
1416 (defined(FSL_FEATURE_FLEXCAN_HAS_MEMORY_ERROR_CONTROL) && FSL_FEATURE_FLEXCAN_HAS_MEMORY_ERROR_CONTROL)
1417static inline uint64_t FLEXCAN_GetStatusFlags(CAN_Type *base)
1418{
1419 uint64_t tempflag = (uint64_t)base->ESR1;
1420#if (defined(FSL_FEATURE_FLEXCAN_HAS_PN_MODE) && FSL_FEATURE_FLEXCAN_HAS_PN_MODE)
1421 /* Get PN Wake Up status. */
1422 tempflag |= FLEXCAN_PN_STATUS_MASK(base->WU_MTC);
1423#endif
1424#if (defined(FSL_FEATURE_FLEXCAN_HAS_ENHANCED_RX_FIFO) && FSL_FEATURE_FLEXCAN_HAS_ENHANCED_RX_FIFO)
1425 /* Get Enhanced Rx FIFO status. */
1426 tempflag |= FLEXCAN_EFIFO_STATUS_MASK(base->ERFSR);
1427#endif
1428#if (defined(FSL_FEATURE_FLEXCAN_HAS_MEMORY_ERROR_CONTROL) && FSL_FEATURE_FLEXCAN_HAS_MEMORY_ERROR_CONTROL)
1429 /* Get Memory Error status. */
1430 tempflag |= FLEXCAN_MECR_STATUS_MASK(base->ERRSR);
1431#endif
1432 return tempflag;
1433}
1434#else
1435static inline uint32_t FLEXCAN_GetStatusFlags(CAN_Type *base)
1436{
1437 return base->ESR1;
1438}
1439#endif
1449#if (defined(FSL_FEATURE_FLEXCAN_HAS_PN_MODE) && FSL_FEATURE_FLEXCAN_HAS_PN_MODE) || \
1450 (defined(FSL_FEATURE_FLEXCAN_HAS_ENHANCED_RX_FIFO) && FSL_FEATURE_FLEXCAN_HAS_ENHANCED_RX_FIFO) || \
1451 (defined(FSL_FEATURE_FLEXCAN_HAS_MEMORY_ERROR_CONTROL) && FSL_FEATURE_FLEXCAN_HAS_MEMORY_ERROR_CONTROL)
1452static inline void FLEXCAN_ClearStatusFlags(CAN_Type *base, uint64_t mask)
1453{
1454#if (defined(FSL_FEATURE_FLEXCAN_HAS_PN_MODE) && FSL_FEATURE_FLEXCAN_HAS_PN_MODE)
1455 /* Clear PN Wake Up status. */
1456 base->WU_MTC = FLEXCAN_PN_STATUS_UNMASK(mask);
1457#endif
1458#if (defined(FSL_FEATURE_FLEXCAN_HAS_ENHANCED_RX_FIFO) && FSL_FEATURE_FLEXCAN_HAS_ENHANCED_RX_FIFO)
1459 /* Clear Enhanced Rx FIFO status. */
1460 base->ERFSR = FLEXCAN_EFIFO_STATUS_UNMASK(mask);
1461#endif
1462#if (defined(FSL_FEATURE_FLEXCAN_HAS_MEMORY_ERROR_CONTROL) && FSL_FEATURE_FLEXCAN_HAS_MEMORY_ERROR_CONTROL)
1463 /* Clear Memory Error status. */
1464 base->ERRSR = FLEXCAN_MECR_STATUS_UNMASK(mask);
1465#endif
1466 base->ESR1 = (uint32_t)(mask & 0xFFFFFFFFU);
1467}
1468#else
1469static inline void FLEXCAN_ClearStatusFlags(CAN_Type *base, uint32_t mask)
1470{
1471 /* Write 1 to clear status flag. */
1472 base->ESR1 = mask;
1473}
1474#endif
1485static inline void FLEXCAN_GetBusErrCount(CAN_Type *base, uint8_t *txErrBuf, uint8_t *rxErrBuf)
1486{
1487 if (NULL != txErrBuf)
1488 {
1489 *txErrBuf = (uint8_t)((base->ECR & CAN_ECR_TXERRCNT_MASK) >> CAN_ECR_TXERRCNT_SHIFT);
1490 }
1491
1492 if (NULL != rxErrBuf)
1493 {
1494 *rxErrBuf = (uint8_t)((base->ECR & CAN_ECR_RXERRCNT_MASK) >> CAN_ECR_RXERRCNT_SHIFT);
1495 }
1496}
1497
1507#if (defined(FSL_FEATURE_FLEXCAN_HAS_EXTENDED_FLAG_REGISTER)) && (FSL_FEATURE_FLEXCAN_HAS_EXTENDED_FLAG_REGISTER > 0)
1508static inline uint64_t FLEXCAN_GetMbStatusFlags(CAN_Type *base, uint64_t mask)
1509#else
1510static inline uint32_t FLEXCAN_GetMbStatusFlags(CAN_Type *base, uint32_t mask)
1511#endif
1512{
1513#if (defined(FSL_FEATURE_FLEXCAN_HAS_EXTENDED_FLAG_REGISTER)) && (FSL_FEATURE_FLEXCAN_HAS_EXTENDED_FLAG_REGISTER > 0)
1514 uint64_t tempflag = (uint64_t)base->IFLAG1;
1515 return (tempflag | (((uint64_t)base->IFLAG2) << 32)) & mask;
1516#else
1517 return (base->IFLAG1 & mask);
1518#endif
1519}
1520
1529#if (defined(FSL_FEATURE_FLEXCAN_HAS_EXTENDED_FLAG_REGISTER)) && (FSL_FEATURE_FLEXCAN_HAS_EXTENDED_FLAG_REGISTER > 0)
1530static inline void FLEXCAN_ClearMbStatusFlags(CAN_Type *base, uint64_t mask)
1531#else
1532static inline void FLEXCAN_ClearMbStatusFlags(CAN_Type *base, uint32_t mask)
1533#endif
1534{
1535#if (defined(FSL_FEATURE_FLEXCAN_HAS_EXTENDED_FLAG_REGISTER)) && (FSL_FEATURE_FLEXCAN_HAS_EXTENDED_FLAG_REGISTER > 0)
1536 base->IFLAG1 = (uint32_t)(mask & 0xFFFFFFFFU);
1537 base->IFLAG2 = (uint32_t)(mask >> 32);
1538#else
1539 base->IFLAG1 = mask;
1540#endif
1541}
1542
1543#if (defined(FSL_FEATURE_FLEXCAN_HAS_MEMORY_ERROR_CONTROL) && FSL_FEATURE_FLEXCAN_HAS_MEMORY_ERROR_CONTROL)
1552void FLEXCAN_GetMemoryErrorReportStatus(CAN_Type *base, flexcan_memory_error_report_status_t *errorStatus);
1553#endif
1554
1555#if (defined(FSL_FEATURE_FLEXCAN_HAS_PN_MODE) && FSL_FEATURE_FLEXCAN_HAS_PN_MODE)
1565static inline uint8_t FLEXCAN_GetPNMatchCount(CAN_Type *base)
1566{
1567 return (uint8_t)((base->WU_MTC & CAN_WU_MTC_MCOUNTER_MASK) >> CAN_WU_MTC_MCOUNTER_SHIFT);
1568}
1569#endif
1570
1571#if (defined(FSL_FEATURE_FLEXCAN_HAS_ENHANCED_RX_FIFO) && FSL_FEATURE_FLEXCAN_HAS_ENHANCED_RX_FIFO)
1580static inline uint32_t FLEXCAN_GetEnhancedFifoDataCount(CAN_Type *base)
1581{
1582 return (base->ERFSR & CAN_ERFSR_ERFEL_MASK);
1583}
1584#endif
1585/* @} */
1586
1601#if (defined(FSL_FEATURE_FLEXCAN_HAS_PN_MODE) && FSL_FEATURE_FLEXCAN_HAS_PN_MODE) || \
1602 (defined(FSL_FEATURE_FLEXCAN_HAS_ENHANCED_RX_FIFO) && FSL_FEATURE_FLEXCAN_HAS_ENHANCED_RX_FIFO) || \
1603 (defined(FSL_FEATURE_FLEXCAN_HAS_MEMORY_ERROR_CONTROL) && FSL_FEATURE_FLEXCAN_HAS_MEMORY_ERROR_CONTROL)
1604static inline void FLEXCAN_EnableInterrupts(CAN_Type *base, uint64_t mask)
1605#else
1606static inline void FLEXCAN_EnableInterrupts(CAN_Type *base, uint32_t mask)
1607#endif
1608{
1609 /* Solve Self Wake Up interrupt. */
1610 base->MCR |= (uint32_t)(mask & (uint32_t)kFLEXCAN_WakeUpInterruptEnable);
1611
1612#if (defined(FSL_FEATURE_FLEXCAN_HAS_FLEXIBLE_DATA_RATE) && FSL_FEATURE_FLEXCAN_HAS_FLEXIBLE_DATA_RATE)
1613 if (0 != FSL_FEATURE_FLEXCAN_INSTANCE_HAS_FLEXIBLE_DATA_RATEn(base))
1614 {
1615 /* Solve CAN FD frames data phase error interrupt. */
1616 base->CTRL2 |= (uint32_t)(mask & (uint32_t)kFLEXCAN_FDErrorInterruptEnable);
1617 }
1618#endif
1619
1620#if (defined(FSL_FEATURE_FLEXCAN_HAS_PN_MODE) && FSL_FEATURE_FLEXCAN_HAS_PN_MODE)
1621 /* Solve PN Wake Up interrupt. */
1622 base->CTRL1_PN |= FLEXCAN_PN_INT_UNMASK(mask);
1623#endif
1624
1625#if (defined(FSL_FEATURE_FLEXCAN_HAS_ENHANCED_RX_FIFO) && FSL_FEATURE_FLEXCAN_HAS_ENHANCED_RX_FIFO)
1626 /* Solve Enhanced Rx FIFO interrupt. */
1627 base->ERFIER |= FLEXCAN_EFIFO_INT_UNMASK(mask);
1628#endif
1629
1630#if (defined(FSL_FEATURE_FLEXCAN_HAS_MEMORY_ERROR_CONTROL) && FSL_FEATURE_FLEXCAN_HAS_MEMORY_ERROR_CONTROL)
1631 /* Solve Memory Error interrupt. */
1632 base->MECR |= FLEXCAN_MECR_INT_UNMASK(mask);
1633#endif
1634
1635 /* Solve interrupt enable bits in CTRL1 register. */
1636 base->CTRL1 |=
1637 (uint32_t)(mask & ((uint32_t)kFLEXCAN_BusOffInterruptEnable | (uint32_t)kFLEXCAN_ErrorInterruptEnable |
1639}
1640
1650#if (defined(FSL_FEATURE_FLEXCAN_HAS_PN_MODE) && FSL_FEATURE_FLEXCAN_HAS_PN_MODE) || \
1651 (defined(FSL_FEATURE_FLEXCAN_HAS_MEMORY_ERROR_CONTROL) && FSL_FEATURE_FLEXCAN_HAS_MEMORY_ERROR_CONTROL)
1652static inline void FLEXCAN_DisableInterrupts(CAN_Type *base, uint64_t mask)
1653#else
1654static inline void FLEXCAN_DisableInterrupts(CAN_Type *base, uint32_t mask)
1655#endif
1656{
1657 /* Solve Wake Up Interrupt. */
1658 base->MCR &= ~(uint32_t)(mask & (uint32_t)kFLEXCAN_WakeUpInterruptEnable);
1659
1660#if (defined(FSL_FEATURE_FLEXCAN_HAS_FLEXIBLE_DATA_RATE) && FSL_FEATURE_FLEXCAN_HAS_FLEXIBLE_DATA_RATE)
1661 if (0 != FSL_FEATURE_FLEXCAN_INSTANCE_HAS_FLEXIBLE_DATA_RATEn(base))
1662 {
1663 /* Solve CAN FD frames data phase error interrupt. */
1664 base->CTRL2 &= ~(uint32_t)(mask & (uint32_t)kFLEXCAN_FDErrorInterruptEnable);
1665 }
1666#endif
1667
1668#if (defined(FSL_FEATURE_FLEXCAN_HAS_PN_MODE) && FSL_FEATURE_FLEXCAN_HAS_PN_MODE)
1669 /* Solve PN Wake Up Interrupt. */
1670 base->CTRL1_PN &= ~FLEXCAN_PN_STATUS_UNMASK(mask);
1671#endif
1672
1673#if (defined(FSL_FEATURE_FLEXCAN_HAS_ENHANCED_RX_FIFO) && FSL_FEATURE_FLEXCAN_HAS_ENHANCED_RX_FIFO)
1674 /* Solve Enhanced Rx FIFO interrupt. */
1675 base->ERFIER &= ~FLEXCAN_EFIFO_INT_UNMASK(mask);
1676#endif
1677
1678#if (defined(FSL_FEATURE_FLEXCAN_HAS_MEMORY_ERROR_CONTROL) && FSL_FEATURE_FLEXCAN_HAS_MEMORY_ERROR_CONTROL)
1679 /* Solve Memory Error Interrupt. */
1680 base->MECR &= ~FLEXCAN_MECR_STATUS_UNMASK(mask);
1681#endif
1682
1683 /* Solve interrupt enable bits in CTRL1 register. */
1684 base->CTRL1 &=
1685 ~(uint32_t)(mask & ((uint32_t)kFLEXCAN_BusOffInterruptEnable | (uint32_t)kFLEXCAN_ErrorInterruptEnable |
1687}
1688
1697#if (defined(FSL_FEATURE_FLEXCAN_HAS_EXTENDED_FLAG_REGISTER)) && (FSL_FEATURE_FLEXCAN_HAS_EXTENDED_FLAG_REGISTER > 0)
1698static inline void FLEXCAN_EnableMbInterrupts(CAN_Type *base, uint64_t mask)
1699#else
1700static inline void FLEXCAN_EnableMbInterrupts(CAN_Type *base, uint32_t mask)
1701#endif
1702{
1703#if (defined(FSL_FEATURE_FLEXCAN_HAS_EXTENDED_FLAG_REGISTER)) && (FSL_FEATURE_FLEXCAN_HAS_EXTENDED_FLAG_REGISTER > 0)
1704 base->IMASK1 |= (uint32_t)(mask & 0xFFFFFFFFU);
1705 base->IMASK2 |= (uint32_t)(mask >> 32);
1706#else
1707 base->IMASK1 |= mask;
1708#endif
1709}
1710
1719#if (defined(FSL_FEATURE_FLEXCAN_HAS_EXTENDED_FLAG_REGISTER)) && (FSL_FEATURE_FLEXCAN_HAS_EXTENDED_FLAG_REGISTER > 0)
1720static inline void FLEXCAN_DisableMbInterrupts(CAN_Type *base, uint64_t mask)
1721#else
1722static inline void FLEXCAN_DisableMbInterrupts(CAN_Type *base, uint32_t mask)
1723#endif
1724{
1725#if (defined(FSL_FEATURE_FLEXCAN_HAS_EXTENDED_FLAG_REGISTER)) && (FSL_FEATURE_FLEXCAN_HAS_EXTENDED_FLAG_REGISTER > 0)
1726 base->IMASK1 &= ~((uint32_t)(mask & 0xFFFFFFFFU));
1727 base->IMASK2 &= ~((uint32_t)(mask >> 32));
1728#else
1729 base->IMASK1 &= ~mask;
1730#endif
1731}
1732
1733/* @} */
1734
1735#if (defined(FSL_FEATURE_FLEXCAN_HAS_RX_FIFO_DMA) && FSL_FEATURE_FLEXCAN_HAS_RX_FIFO_DMA)
1749void FLEXCAN_EnableRxFifoDMA(CAN_Type *base, bool enable);
1750
1759static inline uintptr_t FLEXCAN_GetRxFifoHeadAddr(CAN_Type *base)
1760{
1761 return (uintptr_t) & (base->MB[0].CS);
1762}
1763
1764/* @} */
1765#endif /* FSL_FEATURE_FLEXCAN_HAS_RX_FIFO_DMA */
1766
1780static inline void FLEXCAN_Enable(CAN_Type *base, bool enable)
1781{
1782 if (enable)
1783 {
1784 base->MCR &= ~CAN_MCR_MDIS_MASK;
1785
1786 /* Wait FlexCAN exit from low-power mode. */
1787 while (0U != (base->MCR & CAN_MCR_LPMACK_MASK))
1788 {
1789 }
1790 }
1791 else
1792 {
1793 base->MCR |= CAN_MCR_MDIS_MASK;
1794
1795 /* Wait FlexCAN enter low-power mode. */
1796 while (0U == (base->MCR & CAN_MCR_LPMACK_MASK))
1797 {
1798 }
1799 }
1800}
1801
1815status_t FLEXCAN_WriteTxMb(CAN_Type *base, uint8_t mbIdx, const flexcan_frame_t *pTxFrame);
1816
1832status_t FLEXCAN_ReadRxMb(CAN_Type *base, uint8_t mbIdx, flexcan_frame_t *pRxFrame);
1833
1834#if (defined(FSL_FEATURE_FLEXCAN_HAS_FLEXIBLE_DATA_RATE) && FSL_FEATURE_FLEXCAN_HAS_FLEXIBLE_DATA_RATE)
1848status_t FLEXCAN_WriteFDTxMb(CAN_Type *base, uint8_t mbIdx, const flexcan_fd_frame_t *pTxFrame);
1849
1865status_t FLEXCAN_ReadFDRxMb(CAN_Type *base, uint8_t mbIdx, flexcan_fd_frame_t *pRxFrame);
1866#endif
1867
1879
1880#if (defined(FSL_FEATURE_FLEXCAN_HAS_ENHANCED_RX_FIFO) && FSL_FEATURE_FLEXCAN_HAS_ENHANCED_RX_FIFO)
1891status_t FLEXCAN_ReadEnhancedRxFifo(CAN_Type *base, flexcan_fd_frame_t *pRxFrame);
1892#endif
1893
1894#if (defined(FSL_FEATURE_FLEXCAN_HAS_PN_MODE) && FSL_FEATURE_FLEXCAN_HAS_PN_MODE)
1908status_t FLEXCAN_ReadPNWakeUpMB(CAN_Type *base, uint8_t mbIdx, flexcan_frame_t *pRxFrame);
1909#endif
1910/* @} */
1911
1917#if (defined(FSL_FEATURE_FLEXCAN_HAS_FLEXIBLE_DATA_RATE) && FSL_FEATURE_FLEXCAN_HAS_FLEXIBLE_DATA_RATE)
1929status_t FLEXCAN_TransferFDSendBlocking(CAN_Type *base, uint8_t mbIdx, flexcan_fd_frame_t *pTxFrame);
1930
1943status_t FLEXCAN_TransferFDReceiveBlocking(CAN_Type *base, uint8_t mbIdx, flexcan_fd_frame_t *pRxFrame);
1944
1958status_t FLEXCAN_TransferFDSendNonBlocking(CAN_Type *base, flexcan_handle_t *handle, flexcan_mb_transfer_t *pMbXfer);
1959
1972status_t FLEXCAN_TransferFDReceiveNonBlocking(CAN_Type *base, flexcan_handle_t *handle, flexcan_mb_transfer_t *pMbXfer);
1973
1983void FLEXCAN_TransferFDAbortSend(CAN_Type *base, flexcan_handle_t *handle, uint8_t mbIdx);
1984
1994void FLEXCAN_TransferFDAbortReceive(CAN_Type *base, flexcan_handle_t *handle, uint8_t mbIdx);
1995#endif
1996
2008status_t FLEXCAN_TransferSendBlocking(CAN_Type *base, uint8_t mbIdx, flexcan_frame_t *pTxFrame);
2009
2022status_t FLEXCAN_TransferReceiveBlocking(CAN_Type *base, uint8_t mbIdx, flexcan_frame_t *pRxFrame);
2023
2035
2036#if (defined(FSL_FEATURE_FLEXCAN_HAS_ENHANCED_RX_FIFO) && FSL_FEATURE_FLEXCAN_HAS_ENHANCED_RX_FIFO)
2047status_t FLEXCAN_TransferReceiveEnhancedFifoBlocking(CAN_Type *base, flexcan_fd_frame_t *pRxFrame);
2048#endif
2049
2063 flexcan_handle_t *handle,
2064 flexcan_transfer_callback_t callback,
2065 void *userData);
2066
2081
2095
2109 flexcan_handle_t *handle,
2110 flexcan_fifo_transfer_t *pFifoXfer);
2111
2123
2124#if (defined(FSL_FEATURE_FLEXCAN_HAS_ENHANCED_RX_FIFO) && FSL_FEATURE_FLEXCAN_HAS_ENHANCED_RX_FIFO)
2137status_t FLEXCAN_TransferReceiveEnhancedFifoNonBlocking(CAN_Type *base,
2138 flexcan_handle_t *handle,
2139 flexcan_fifo_transfer_t *pFifoXfer);
2140
2151static inline status_t FLEXCAN_TransferGetReceiveEnhancedFifoCount(CAN_Type *base,
2152 flexcan_handle_t *handle,
2153 size_t *count)
2154{
2155 return FLEXCAN_TransferGetReceiveFifoCount(base, handle, count);
2156}
2157#endif
2158
2177uint32_t FLEXCAN_GetTimeStamp(flexcan_handle_t *handle, uint8_t mbIdx);
2178
2188void FLEXCAN_TransferAbortSend(CAN_Type *base, flexcan_handle_t *handle, uint8_t mbIdx);
2189
2199void FLEXCAN_TransferAbortReceive(CAN_Type *base, flexcan_handle_t *handle, uint8_t mbIdx);
2200
2210
2211#if (defined(FSL_FEATURE_FLEXCAN_HAS_ENHANCED_RX_FIFO) && FSL_FEATURE_FLEXCAN_HAS_ENHANCED_RX_FIFO)
2220void FLEXCAN_TransferAbortReceiveEnhancedFifo(CAN_Type *base, flexcan_handle_t *handle);
2221#endif
2222
2232
2233/* @} */
2234
2235#if defined(__cplusplus)
2236}
2237#endif
2238
2241#endif /* _FSL_FLEXCAN_H_ */
uint8_t dataByte4
Definition: fsl_flexcan.h:701
flexcan_rx_fifo_filter_type_t idFilterType
Definition: fsl_flexcan.h:949
void FLEXCAN_Deinit(CAN_Type *base)
De-initializes a FlexCAN instance.
Definition: fsl_flexcan.c:1109
uint16_t preDivider
Definition: fsl_flexcan.h:767
void FLEXCAN_ExitFreezeMode(CAN_Type *base)
Exit FlexCAN Freeze Mode.
Definition: fsl_flexcan.c:519
status_t FLEXCAN_TransferReceiveFifoNonBlocking(CAN_Type *base, flexcan_handle_t *handle, flexcan_fifo_transfer_t *pFifoXfer)
Receives a message from Rx FIFO using IRQ.
Definition: fsl_flexcan.c:3686
status_t FLEXCAN_TransferSendBlocking(CAN_Type *base, uint8_t mbIdx, flexcan_frame_t *pTxFrame)
Performs a polling send transaction on the CAN bus.
Definition: fsl_flexcan.c:3139
flexcan_frame_t * frame
Definition: fsl_flexcan.h:1010
flexcan_frame_type_t type
Definition: fsl_flexcan.h:850
bool enableTimerSync
Definition: fsl_flexcan.h:808
uint8_t dataByte0
Definition: fsl_flexcan.h:697
uint8_t maxMbNum
Definition: fsl_flexcan.h:806
void FLEXCAN_SetRxFifoConfig(CAN_Type *base, const flexcan_rx_fifo_config_t *pRxFifoConfig, bool enable)
Configures the FlexCAN Legacy Rx FIFO.
Definition: fsl_flexcan.c:2313
flexcan_rx_fifo_priority_t priority
Definition: fsl_flexcan.h:950
size_t frameNum
Definition: fsl_flexcan.h:1021
status_t FLEXCAN_TransferSendNonBlocking(CAN_Type *base, flexcan_handle_t *handle, flexcan_mb_transfer_t *pMbXfer)
Sends a message using IRQ.
Definition: fsl_flexcan.c:3452
uint32_t bitRate
Definition: fsl_flexcan.h:798
void FLEXCAN_EnterFreezeMode(CAN_Type *base)
Enter FlexCAN Freeze Mode.
Definition: fsl_flexcan.c:501
flexcan_frame_t *volatile mbFrameBuf[CAN_WORD1_COUNT]
Definition: fsl_flexcan.h:1056
uint32_t timestamp
Definition: fsl_flexcan.h:673
_flexcan_frame_format
FlexCAN frame format.
Definition: fsl_flexcan.h:323
_flexcan_interrupt_enable
FlexCAN interrupt enable enumerations.
Definition: fsl_flexcan.h:452
size_t rxFifoFrameNum
Definition: fsl_flexcan.h:1065
void FLEXCAN_GetDefaultConfig(flexcan_config_t *pConfig)
Gets the default configuration structure.
Definition: fsl_flexcan.c:1154
void FLEXCAN_SetRxIndividualMask(CAN_Type *base, uint8_t maskIdx, uint32_t mask)
Sets the FlexCAN receive individual mask.
Definition: fsl_flexcan.c:1501
bool enableListenOnlyMode
Definition: fsl_flexcan.h:812
void FLEXCAN_SetRxMbGlobalMask(CAN_Type *base, uint32_t mask)
Sets the FlexCAN receive message buffer global mask.
Definition: fsl_flexcan.c:1453
uint32_t dataWord0
Definition: fsl_flexcan.h:689
uint8_t dataByte1
Definition: fsl_flexcan.h:696
uint32_t id
Definition: fsl_flexcan.h:847
bool enableSelfWakeup
Definition: fsl_flexcan.h:809
uint8_t dataByte3
Definition: fsl_flexcan.h:694
status_t FLEXCAN_ReadRxFifo(CAN_Type *base, flexcan_frame_t *pRxFrame)
Reads a FlexCAN Message from Legacy Rx FIFO.
Definition: fsl_flexcan.c:3029
uint8_t mbIdx
Definition: fsl_flexcan.h:1011
uint8_t dataByte5
Definition: fsl_flexcan.h:700
uint8_t propSeg
Definition: fsl_flexcan.h:771
uint8_t idFilterNum
Definition: fsl_flexcan.h:948
bool FLEXCAN_CalculateImprovedTimingValues(CAN_Type *base, uint32_t bitRate, uint32_t sourceClock_Hz, flexcan_timing_config_t *pTimingConfig)
Calculates the improved timing values by specific bit Rates for classical CAN.
Definition: fsl_flexcan.c:1685
_flexcan_clock_source
FlexCAN clock source.
Definition: fsl_flexcan.h:340
enum _flexcan_rx_fifo_filter_type flexcan_rx_fifo_filter_type_t
FlexCAN Rx Fifo Filter type.
void FLEXCAN_SetTimingConfig(CAN_Type *base, const flexcan_timing_config_t *pConfig)
Sets the FlexCAN classical CAN protocol timing characteristic.
Definition: fsl_flexcan.c:1327
uint32_t FLEXCAN_GetInstance(CAN_Type *base)
Get the FlexCAN instance from peripheral base address.
Definition: fsl_flexcan.c:345
enum _flexcan_wake_up_source flexcan_wake_up_source_t
FlexCAN wake up source.
uint32_t idhit
Definition: fsl_flexcan.h:678
enum _flexcan_frame_format flexcan_frame_format_t
FlexCAN frame format.
status_t FLEXCAN_TransferReceiveBlocking(CAN_Type *base, uint8_t mbIdx, flexcan_frame_t *pRxFrame)
Performs a polling receive transaction on the CAN bus.
Definition: fsl_flexcan.c:3188
status_t FLEXCAN_TransferReceiveNonBlocking(CAN_Type *base, flexcan_handle_t *handle, flexcan_mb_transfer_t *pMbXfer)
Receives a message using IRQ.
Definition: fsl_flexcan.c:3516
uint32_t length
Definition: fsl_flexcan.h:674
uint32_t baudRate
Definition: fsl_flexcan.h:791
size_t rxFifoTransferTotalNum
Definition: fsl_flexcan.h:1066
void * userData
Definition: fsl_flexcan.h:1054
void FLEXCAN_SetRxMbConfig(CAN_Type *base, uint8_t mbIdx, const flexcan_rx_mb_config_t *pRxMbConfig, bool enable)
Configures a FlexCAN Receive Message Buffer.
Definition: fsl_flexcan.c:2191
flexcan_wake_up_source_t wakeupSrc
Definition: fsl_flexcan.h:805
uint32_t type
Definition: fsl_flexcan.h:675
uint8_t dataByte2
Definition: fsl_flexcan.h:695
uint8_t dataByte6
Definition: fsl_flexcan.h:699
volatile uint8_t mbState[CAN_WORD1_COUNT]
Definition: fsl_flexcan.h:1067
void FLEXCAN_TransferHandleIRQ(CAN_Type *base, flexcan_handle_t *handle)
FlexCAN IRQ handle function.
Definition: fsl_flexcan.c:4422
bool disableSelfReception
Definition: fsl_flexcan.h:811
uint8_t dataByte7
Definition: fsl_flexcan.h:698
void FLEXCAN_TransferAbortReceive(CAN_Type *base, flexcan_handle_t *handle, uint8_t mbIdx)
Aborts the interrupt driven message receive process.
Definition: fsl_flexcan.c:3939
status_t FLEXCAN_WriteTxMb(CAN_Type *base, uint8_t mbIdx, const flexcan_frame_t *pTxFrame)
Writes a FlexCAN Message to the Transmit Message Buffer.
Definition: fsl_flexcan.c:2682
status_t FLEXCAN_TransferReceiveFifoBlocking(CAN_Type *base, flexcan_frame_t *pRxFrame)
Performs a polling receive transaction from Legacy Rx FIFO on the CAN bus.
Definition: fsl_flexcan.c:3310
struct _flexcan_rx_mb_config flexcan_rx_mb_config_t
FlexCAN Receive Message Buffer configuration structure.
enum _flexcan_clock_source flexcan_clock_source_t
FlexCAN clock source.
void FLEXCAN_TransferAbortReceiveFifo(CAN_Type *base, flexcan_handle_t *handle)
Aborts the interrupt driven message receive from Rx FIFO process.
Definition: fsl_flexcan.c:3970
flexcan_transfer_callback_t callback
Definition: fsl_flexcan.h:1053
volatile uint8_t rxFifoState
Definition: fsl_flexcan.h:1068
flexcan_clock_source_t clkSrc
Definition: fsl_flexcan.h:804
_flexcan_rx_fifo_filter_type
FlexCAN Rx Fifo Filter type.
Definition: fsl_flexcan.h:356
struct _flexcan_config flexcan_config_t
FlexCAN module configuration structure.
uint32_t format
Definition: fsl_flexcan.h:676
void FLEXCAN_TransferAbortSend(CAN_Type *base, flexcan_handle_t *handle, uint8_t mbIdx)
Aborts the interrupt driven message send process.
Definition: fsl_flexcan.c:3823
bool enableLoopBack
Definition: fsl_flexcan.h:807
_flexcan_wake_up_source
FlexCAN wake up source.
Definition: fsl_flexcan.h:349
struct _flexcan_timing_config flexcan_timing_config_t
FlexCAN protocol timing characteristic configuration structure.
uint8_t phaseSeg1
Definition: fsl_flexcan.h:769
_flexcan_frame_type
FlexCAN frame type.
Definition: fsl_flexcan.h:330
enum _flexcan_frame_type flexcan_frame_type_t
FlexCAN frame type.
bool enableSupervisorMode
Definition: fsl_flexcan.h:814
void FLEXCAN_TransferCreateHandle(CAN_Type *base, flexcan_handle_t *handle, flexcan_transfer_callback_t callback, void *userData)
Initializes the FlexCAN handle.
Definition: fsl_flexcan.c:3367
volatile uint32_t timestamp[CAN_WORD1_COUNT]
Definition: fsl_flexcan.h:1069
struct _flexcan_frame flexcan_frame_t
FlexCAN message frame structure.
void FLEXCAN_SetRxFifoGlobalMask(CAN_Type *base, uint32_t mask)
Sets the FlexCAN receive FIFO global mask.
Definition: fsl_flexcan.c:1475
flexcan_frame_t *volatile rxFifoFrameBuf
Definition: fsl_flexcan.h:1061
status_t FLEXCAN_ReadRxMb(CAN_Type *base, uint8_t mbIdx, flexcan_frame_t *pRxFrame)
Reads a FlexCAN Message from Receive Message Buffer.
Definition: fsl_flexcan.c:2854
struct _flexcan_fifo_transfer flexcan_fifo_transfer_t
FlexCAN Rx FIFO transfer.
struct _flexcan_rx_fifo_config flexcan_rx_fifo_config_t
FlexCAN Legacy Rx FIFO configuration structure.
status_t FLEXCAN_TransferGetReceiveFifoCount(CAN_Type *base, flexcan_handle_t *handle, size_t *count)
Gets the Legacy Rx Fifo transfer status during a interrupt non-blocking receive.
Definition: fsl_flexcan.c:3736
flexcan_frame_format_t format
Definition: fsl_flexcan.h:849
void FLEXCAN_SetTxMbConfig(CAN_Type *base, uint8_t mbIdx, bool enable)
Configures a FlexCAN transmit message buffer.
Definition: fsl_flexcan.c:1527
uint32_t FLEXCAN_GetTimeStamp(flexcan_handle_t *handle, uint8_t mbIdx)
Gets the detail index of Mailbox's Timestamp by handle.
Definition: fsl_flexcan.c:4044
uint32_t id
Definition: fsl_flexcan.h:682
_flexcan_error_flags
FlexCAN error status flags.
Definition: fsl_flexcan.h:564
enum _flexcan_rx_fifo_priority flexcan_rx_fifo_priority_t
FlexCAN Enhanced/Legacy Rx FIFO priority.
uint32_t * idFilterTable
Definition: fsl_flexcan.h:947
uint8_t phaseSeg2
Definition: fsl_flexcan.h:770
uint32_t dataWord1
Definition: fsl_flexcan.h:690
uint8_t rJumpwidth
Definition: fsl_flexcan.h:768
flexcan_frame_t * frame
Definition: fsl_flexcan.h:1020
void FLEXCAN_Init(CAN_Type *base, const flexcan_config_t *pConfig, uint32_t sourceClock_Hz)
Initializes a FlexCAN instance.
Definition: fsl_flexcan.c:780
struct _flexcan_mb_transfer flexcan_mb_transfer_t
FlexCAN Message Buffer transfer.
status_t FLEXCAN_SetBitRate(CAN_Type *base, uint32_t sourceClock_Hz, uint32_t bitRate_Bps)
Set bit rate of FlexCAN classical CAN frame or CAN FD frame nominal phase.
Definition: fsl_flexcan.c:713
_flexcan_rx_fifo_priority
FlexCAN Enhanced/Legacy Rx FIFO priority.
Definition: fsl_flexcan.h:440
_flexcan_flags
FlexCAN status flags.
Definition: fsl_flexcan.h:495
bool enableIndividMask
Definition: fsl_flexcan.h:810
@ kFLEXCAN_FrameFormatExtend
Definition: fsl_flexcan.h:325
@ kFLEXCAN_FrameFormatStandard
Definition: fsl_flexcan.h:324
@ kFLEXCAN_ErrorInterruptEnable
Definition: fsl_flexcan.h:454
@ kFLEXCAN_RxWarningInterruptEnable
Definition: fsl_flexcan.h:456
@ kFLEXCAN_TxWarningInterruptEnable
Definition: fsl_flexcan.h:455
@ kFLEXCAN_WakeUpInterruptEnable
Definition: fsl_flexcan.h:457
@ kFLEXCAN_BusOffInterruptEnable
Definition: fsl_flexcan.h:453
@ kFLEXCAN_ClkSrc0
Definition: fsl_flexcan.h:343
@ kFLEXCAN_ClkSrc1
Definition: fsl_flexcan.h:344
@ kFLEXCAN_ClkSrcPeri
Definition: fsl_flexcan.h:342
@ kFLEXCAN_ClkSrcOsc
Definition: fsl_flexcan.h:341
@ kStatus_FLEXCAN_TxBusy
Definition: fsl_flexcan.h:298
@ kStatus_FLEXCAN_ErrorStatus
Definition: fsl_flexcan.h:311
@ kStatus_FLEXCAN_TxSwitchToRx
Definition: fsl_flexcan.h:300
@ kStatus_FLEXCAN_RxFifoOverflow
Definition: fsl_flexcan.h:307
@ kStatus_FLEXCAN_RxFifoDisabled
Definition: fsl_flexcan.h:309
@ kStatus_FLEXCAN_RxFifoWarning
Definition: fsl_flexcan.h:308
@ kStatus_FLEXCAN_RxBusy
Definition: fsl_flexcan.h:302
@ kStatus_FLEXCAN_RxFifoIdle
Definition: fsl_flexcan.h:306
@ kStatus_FLEXCAN_RxFifoBusy
Definition: fsl_flexcan.h:305
@ kStatus_FLEXCAN_UnHandled
Definition: fsl_flexcan.h:313
@ kStatus_FLEXCAN_RxOverflow
Definition: fsl_flexcan.h:304
@ kStatus_FLEXCAN_TxIdle
Definition: fsl_flexcan.h:299
@ kStatus_FLEXCAN_RxRemote
Definition: fsl_flexcan.h:314
@ kStatus_FLEXCAN_WakeUp
Definition: fsl_flexcan.h:312
@ kStatus_FLEXCAN_RxIdle
Definition: fsl_flexcan.h:303
@ kFLEXCAN_RxFifoFrameAvlFlag
Definition: fsl_flexcan.h:594
@ kFLEXCAN_RxFifoWarningFlag
Definition: fsl_flexcan.h:593
@ kFLEXCAN_RxFifoOverflowFlag
Definition: fsl_flexcan.h:592
@ kFLEXCAN_RxFifoFilterTypeB
Definition: fsl_flexcan.h:358
@ kFLEXCAN_RxFifoFilterTypeA
Definition: fsl_flexcan.h:357
@ kFLEXCAN_RxFifoFilterTypeD
Definition: fsl_flexcan.h:362
@ kFLEXCAN_RxFifoFilterTypeC
Definition: fsl_flexcan.h:360
@ kFLEXCAN_WakeupSrcFiltered
Definition: fsl_flexcan.h:351
@ kFLEXCAN_WakeupSrcUnfiltered
Definition: fsl_flexcan.h:350
@ kFLEXCAN_FrameTypeData
Definition: fsl_flexcan.h:331
@ kFLEXCAN_FrameTypeRemote
Definition: fsl_flexcan.h:332
@ kFLEXCAN_AckError
Definition: fsl_flexcan.h:577
@ kFLEXCAN_FormError
Definition: fsl_flexcan.h:575
@ kFLEXCAN_CrcError
Definition: fsl_flexcan.h:576
@ kFLEXCAN_Bit1Error
Definition: fsl_flexcan.h:579
@ kFLEXCAN_RxErrorWarningFlag
Definition: fsl_flexcan.h:573
@ kFLEXCAN_TxErrorWarningFlag
Definition: fsl_flexcan.h:572
@ kFLEXCAN_StuffingError
Definition: fsl_flexcan.h:574
@ kFLEXCAN_Bit0Error
Definition: fsl_flexcan.h:578
@ kFLEXCAN_RxFifoPrioLow
Definition: fsl_flexcan.h:441
@ kFLEXCAN_RxFifoPrioHigh
Definition: fsl_flexcan.h:442
@ kFLEXCAN_TransmittingFlag
Definition: fsl_flexcan.h:506
@ kFLEXCAN_RxWarningIntFlag
Definition: fsl_flexcan.h:503
@ kFLEXCAN_ReceivingFlag
Definition: fsl_flexcan.h:507
@ kFLEXCAN_FaultConfinementFlag
Definition: fsl_flexcan.h:505
@ kFLEXCAN_SynchFlag
Definition: fsl_flexcan.h:501
@ kFLEXCAN_IdleFlag
Definition: fsl_flexcan.h:504
@ kFLEXCAN_BusOffIntFlag
Definition: fsl_flexcan.h:508
@ kFLEXCAN_WakeUpIntFlag
Definition: fsl_flexcan.h:510
@ kFLEXCAN_TxWarningIntFlag
Definition: fsl_flexcan.h:502
@ kFLEXCAN_ErrorIntFlag
Definition: fsl_flexcan.h:509
int32_t status_t
Type used for all status and error return values.
Definition: fsl_common.h:225
#define MAKE_STATUS(group, code)
Construct a status code value from a group and code number.
Definition: fsl_common.h:47
@ kStatusGroup_FLEXCAN
Definition: fsl_common.h:125
Definition: MIMXRT1052.h:4122
FlexCAN module configuration structure.
Definition: fsl_flexcan.h:786
FlexCAN Rx FIFO transfer.
Definition: fsl_flexcan.h:1016
FlexCAN message frame structure.
Definition: fsl_flexcan.h:670
FlexCAN handle structure.
Definition: fsl_flexcan.h:1052
FlexCAN Message Buffer transfer.
Definition: fsl_flexcan.h:1006
FlexCAN Legacy Rx FIFO configuration structure.
Definition: fsl_flexcan.h:946
FlexCAN Receive Message Buffer configuration structure.
Definition: fsl_flexcan.h:846
FlexCAN protocol timing characteristic configuration structure.
Definition: fsl_flexcan.h:766
Definition: mknod-pack_dev.c:254