CAN.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2023-2024, Texas Instruments Incorporated
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  *
9  * * Redistributions of source code must retain the above copyright
10  * notice, this list of conditions and the following disclaimer.
11  *
12  * * Redistributions in binary form must reproduce the above copyright
13  * notice, this list of conditions and the following disclaimer in the
14  * documentation and/or other materials provided with the distribution.
15  *
16  * * Neither the name of Texas Instruments Incorporated nor the names of
17  * its contributors may be used to endorse or promote products derived
18  * from this software without specific prior written permission.
19  *
20  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
22  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
23  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
24  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
25  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
26  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
27  * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
28  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
29  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
30  * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31  */
32 /*!*****************************************************************************
33  * @file CAN.h
34  *
35  * @brief Controller Area Network (CAN) Driver Interface
36  *
37  * @anchor ti_drivers_CAN_Overview
38  * # Overview
39  * The Controller Area Network (CAN) driver is a single instance driver
40  * that provides a simple interface to transmit and receive messages on a CAN bus.
41  * Messages are broadcast to the entire CAN network and each device is responsible
42  * for filtering and handling the received messages as necessary.
43  * The application is responsible for interpreting the received data.
44  *
45  * # Power Management
46  * For devices with an integrated CAN controller, the CAN driver sets a power
47  * constraint when the driver is opened to prevent the device from entering
48  * standby when all tasks are blocked. This is required to allow the CAN
49  * controller and its clock source to remain powered to receive CAN messages
50  * from the external CAN transceiver. When the driver is closed, the power
51  * constraint is released. The application should close the CAN driver whenever
52  * the CAN transceiver enters sleep mode and re-open the CAN driver when the CAN
53  * transceiver wakes from sleep mode.
54  *
55  * <hr>
56  * @anchor ti_drivers_CAN_Usage
57  * # Usage
58  *
59  * To use the CAN driver to send and receive messages over the CAN bus, the
60  * application calls the following APIs:
61  * - CAN_open(): Open the CAN driver instance and configure the CAN
62  * controller, placing it in normal operational mode.
63  * - CAN_write(): Transmit a message using the Tx FIFO/Queue. This is the
64  * typical method of transmission.
65  * - CAN_writeBuffer(): Transmit a message using a dedicated Tx Buffer. This
66  * method of transmission requires a custom message RAM configuration and
67  * should only be used if there is an application-specific need that cannot
68  * be met by using the Tx FIFO/Queue.
69  * - CAN_read(): Receive a message. This should be called in a task context
70  * and triggered by the event callback when CAN_EVENT_RX_DATA_AVAIL occurs.
71  * - CAN_close(): Close the CAN driver instance and reset the CAN controller,
72  * placing it in standby operational mode.
73  *
74  * @anchor ti_drivers_CAN_Synopsis
75  * ## Synopsis
76  * The following code example initializes the CAN driver with the default
77  * configuration, transmits a CAN FD message, and waits to read any received
78  * messages.
79  *
80  * @code
81  * // Payload data size indexed by Data Length Code (DLC) field.
82  * static const uint32_t dlcToDataSize[16] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 12, 16, 20, 24, 32, 48, 64};
83  *
84  * // Rx semaphore.
85  * static SemaphoreP_Handle rxSemHandle;
86  *
87  * void eventCallback(CAN_Handle handle, uint32_t event, uint32_t data, void *userArg)
88  * {
89  * if (event == CAN_EVENT_RX_DATA_AVAIL)
90  * {
91  * SemaphoreP_post(rxSemHandle);
92  * }
93  * // Handle more events here if enabled via the event mask...
94  * }
95  *
96  * void thread(arg0, arg1)
97  * {
98  * int_fast16_t status;
99  * CAN_RxBufElement rxElem;
100  * CAN_TxBufElement txElem;
101  *
102  * // Initialize driver(s).
103  * CAN_init();
104  *
105  * // Create callback semaphore.
106  * SemaphoreP_Params semParams;
107  * SemaphoreP_Params_init(&semParams);
108  * semParams.mode = SemaphoreP_Mode_BINARY;
109  * callbackSemHandle = SemaphoreP_create(0, &(semParams));
110  *
111  * if (callbackSemHandle == NULL)
112  * {
113  * // SemaphoreP_create() failed.
114  * while (1) {}
115  * }
116  *
117  * // Open CAN driver with default configuration.
118  * CAN_Params_init(&canParams);
119  * canParams.eventCbk = eventCallback;
120  * // Setup event mask for events the application is interested in receiving
121  * // the callback for. Typically, only the CAN_EVENT_RX_DATA_AVAIL is required.
122  * canParams.eventMask = CAN_EVENT_RX_DATA_AVAIL;
123  *
124  * canHandle = CAN_open(CONFIG_CAN_0, &canParams);
125  * if (canHandle == NULL)
126  * {
127  * // CAN_open() failed.
128  * while (1) {}
129  * }
130  *
131  * // Setup Tx buffer element:
132  * // CAN FD without Bit Rate Switching
133  * // Extended Message ID = 0x12345678
134  * // Data Length of 64-bytes
135  * // Message marker = 5
136  * txElem.id = 0x12345678U;
137  * txElem.rtr = 0U;
138  * txElem.xtd = 1U;
139  * txElem.esi = 0U;
140  * txElem.brs = 1U;
141  * txElem.dlc = CAN_DLC_64B;
142  * txElem.fdf = 1U;
143  * txElem.efc = 0U;
144  * txElem.mm = 5U;
145  *
146  * // Fill data payload with incrementing values.
147  * for (i = 0; i < dlcToDataSize[txElem.dlc]; i++)
148  * {
149  * txElem.data[i] = i;
150  * }
151  *
152  * // Transmit message.
153  * CAN_write(canHandle, &txElem);
154  *
155  * while (1)
156  * {
157  * // Wait for Rx data available event.
158  * SemaphoreP_pend(rxSemHandle, (uint32_t)SemaphoreP_WAIT_FOREVER);
159  *
160  * // Read all available messages.
161  * while (CAN_read(canHandle, &rxElem) == CAN_STATUS_SUCCESS)
162  * {
163  * // Process received message.
164  * }
165  * }
166  * }
167  *
168  * @endcode
169  *
170  * More details on usage are provided in the following subsections.
171  *
172  * @anchor ti_drivers_CAN_Examples
173  * ## Examples #
174  * * @ref ti_drivers_CAN_Synopsis "Usage Synopsis"
175  * * @ref ti_drivers_CAN_Example_initMsgRam "Initialize with custom message RAM configuration"
176  * * @ref ti_drivers_CAN_Example_initRawBitRate "Initialize with raw bit rate timing"
177  *
178  * ## Initializing the CAN Driver
179  *
180  * CAN_init() must be called before any other CAN APIs. This function
181  * initializes common driver resources and calls the device-specific
182  * initialization function to configure the bit rate and message RAM.
183  *
184  * ## Opening the CAN Driver
185  * After initializing the CAN driver by calling CAN_init(), the application
186  * can open a CAN instance by calling CAN_open(). This function
187  * takes an index into the @p CAN_config[] array, and a CAN parameters data
188  * structure. The CAN instance is specified by the index of the CAN in
189  * @p CAN_config[]. Calling CAN_open() a second time with the same index
190  * previously passed to CAN_open() will result in an error. You can,
191  * though, re-use the index if the instance is closed via CAN_close().
192  *
193  * If no #CAN_Params structure is passed to CAN_open(), default values are
194  * used. If the open call is successful, it returns a non-NULL value.
195  * The CAN driver APIs are non-blocking; there is no configurable return behavior.
196  *
197  * @anchor ti_drivers_CAN_Example_initMsgRam
198  * Example initializing the CAN driver with a custom message RAM configuration
199  * to receive only filtered message IDs:
200  *
201  * @note CAN driver SysConfig must be setup with 'Reject Non-Matching Messages' enabled.
202  *
203  * @code
204  * #define STD_MSG_FILTER_NUM 2U
205  * #define EXT_MSG_FILTER_NUM 1U
206  *
207  * static MCAN_StdMsgIDFilterElement stdMsgIDFilter[STD_MSG_FILTER_NUM] =
208  * {{.sfid1 = 0x555, .sfid2 = 0x444, .sfec = CAN_FEC_STORE_RXFIFO0, .sft = CAN_FILTER_DUAL_ID},
209  * {.sfid1 = 0x123, .sfid2 = 0U, .sfec = CAN_FEC_STORE_RXBUF, .sft = 0U}};
210  *
211  * static MCAN_ExtMsgIDFilterElement extMsgIDFilter[EXT_MSG_FILTER_NUM] =
212  * {{.efid1 = 0x1234578, .efid2 = 0x1234600, .efec = CAN_FEC_STORE_RXFIFO1, .eft = CAN_FILTER_RANGE}};
213  *
214  * const CAN_MsgRamConfig msgRamConfig = {
215  * .stdFilterNum = STD_MSG_FILTER_NUM,
216  * .extFilterNum = EXT_MSG_FILTER_NUM,
217  * .stdMsgIDFilterList = &stdMsgIDFilter[0],
218  * .extMsgIDFilterList = &extMsgIDFilter[0],
219  *
220  * .rxFifoNum[0] = 10U,
221  * .rxFifoNum[1] = 2U,
222  * .rxBufNum = 1U,
223  * .txBufNum = 1U,
224  * .txFifoQNum = 5U,
225  * .txFifoQMode = 1U,
226  * };
227  *
228  * int_fast16_t status;
229  *
230  * // Initialize driver(s).
231  * CAN_init();
232  *
233  * // Open CAN driver with custom message filters.
234  * CAN_Params_init(&canParams);
235  * canParams.msgRamConfig = &msgRamConfig;
236  * canParams.eventCbk = eventCallback;
237  * // Setup event mask for events the application is interested in receiving
238  * // the callback for. Typically, only the CAN_EVENT_RX_DATA_AVAIL is required.
239  * canParams.eventMask = CAN_EVENT_RX_DATA_AVAIL;
240  *
241  * canHandle = CAN_open(CONFIG_CAN_0, &canParams);
242  * if (canHandle == NULL)
243  * {
244  * // CAN_open() failed.
245  * while (1) {}
246  * }
247  * @endcode
248  *
249  * @anchor ti_drivers_CAN_Example_initRawBitRate
250  * Example initializing the CAN driver with a specific raw bit rate timing:
251  * @note For this example, CAN driver SysConfig should be setup with 'CAN FD
252  * Operation' and 'Bit Rate Switching' enabled. The nominal and data bit rates
253  * selected in SysConfig will be ignored since raw bit rate timing parameters
254  * are provided to CAN_open().
255  *
256  * @code
257  * const CAN_DataBitRateTimingRaw rawDataBitRateTiming = {
258  * // 1Mbps with 40MHz clk and 80% sample point ((40E6 / 2) / (15 + 4 + 1) = 1E6)
259  * // Add 1 to each programmed bit time to get functional value and +1 for for prop segment
260  * .dbrp = 1U,
261  * .dtSeg1 = 14U,
262  * .dtSeg2 = 3U,
263  * .dsjw = 3U,
264  * .tdcOffset = 14U,
265  * .tdcFilterWinLen = 0U
266  * };
267  *
268  * const CAN_BitRateTimingRaw rawBitTiming = {
269  * // 500kbps nominal with 40MHz clk and 87.5% sample point ((40E6 / 1) / (69 + 10 + 1) = 500E3)
270  * // Add 1 to each programmed bit time to get functional value and +1 for for prop segment
271  * .nbrp = 0U,
272  * .ntSeg1 = 68U,
273  * .ntSeg2 = 9U,
274  * .nsjw = 9U,
275  * .dataTiming = &rawDataBitRateTiming
276  * };
277  *
278  * int_fast16_t status;
279  *
280  * // Initialize driver(s).
281  * CAN_init();
282  *
283  * // Open CAN with specific raw bit timing.
284  * CAN_Params_init(&canParams);
285  * canParams.bitTiming = &rawBitTiming;
286  * canParams.eventCbk = eventCallback;
287  * // Setup event mask for events the application is interested in receiving
288  * // the callback for. Typically, only the CAN_EVENT_RX_DATA_AVAIL is required.
289  * canParams.eventMask = CAN_EVENT_RX_DATA_AVAIL;
290  *
291  * canHandle = CAN_open(CONFIG_CAN_0, &canParams);
292  * if (canHandle == NULL)
293  * {
294  * // CAN_open() failed.
295  * while (1) {}
296  * }
297  * @endcode
298  *
299  * ## CAN Message RAM Configuration
300  *
301  * The default message RAM configuration is as follows:
302  * - No Rx filters.
303  * - Tx Queue (message with lowest ID in the queue will be transmitted first)
304  * with a fixed device-specific number of Tx buffers.
305  * - No Tx event FIFO.
306  * - Fixed device-specific number of Rx FIFO0 buffers.
307  * - No Rx FIFO1 buffers.
308  * - No dedicated Rx buffers.
309  *
310  * The number of default Tx and Rx buffers varies depending on the size of the
311  * device's message RAM. Check the doxygen for the device-specific CAN
312  * implementation to find the message RAM size. If using a custom message RAM
313  * configuration, utilize the entire space by maximizing the number of Rx/Tx
314  * buffers for optimal performance.
315  *
316  * ## CAN Write Behavior
317  * CAN_write() will return immediately after the message is loaded into the CAN
318  * controller's message RAM and pending transfer; it does not wait for the CAN
319  * message to be transmitted on the bus before returning. The CAN controller will
320  * automatically handle transmission retries in the event of a failure.
321  *
322  * ## CAN Read Behavior
323  * When a message is received in Rx FIFO0/1 or a dedicated Rx buffer, the CAN
324  * driver's IRQ handler automatically reads the Rx buffer element from the CAN
325  * controller's message RAM and stores it in a ring buffer whose size is
326  * configurable in SysConfig. When CAN_read() is called, the Rx buffer element
327  * is copied from the ring buffer to the application. If the ring buffer becomes
328  * full, any new messages received will be lost until the application frees
329  * space in the ring buffer by calling CAN_read().
330  *******************************************************************************
331  */
332 #ifndef ti_drivers_can__include
333 #define ti_drivers_can__include
334 
335 #include <stdint.h>
336 #include <stddef.h>
337 
339 #include <ti/devices/DeviceFamily.h>
340 
341 #include <third_party/mcan/MCAN.h>
342 
343 #ifdef __cplusplus
344 extern "C" {
345 #endif
346 
357 #define CAN_STATUS_SUCCESS ((int_fast16_t)0)
358 
365 #define CAN_STATUS_ERROR ((int_fast16_t)-1)
366 
373 #define CAN_STATUS_NOT_SUPPORTED ((int_fast16_t)-2)
374 
380 #define CAN_STATUS_TX_BUF_FULL ((int_fast16_t)-3)
381 
388 #define CAN_STATUS_NO_RX_MSG_AVAIL ((int_fast16_t)-4)
389 
396 #define CAN_STATUS_NO_TX_EVENT_AVAIL ((int_fast16_t)-5)
397 
413 #define CAN_EVENT_SPI_XFER_ERROR (0x800U)
414 
421 #define CAN_EVENT_BIT_ERR_UNCORRECTED (0x400U)
422 
431 #define CAN_EVENT_RX_RING_BUFFER_FULL (0x200U)
432 
438 #define CAN_EVENT_RX_FIFO_MSG_LOST (0x100U)
439 
443 #define CAN_EVENT_ERR_PASSIVE (0x80U)
444 
448 #define CAN_EVENT_ERR_ACTIVE (0x40U)
449 
453 #define CAN_EVENT_BUS_OFF (0x20U)
454 
458 #define CAN_EVENT_BUS_ON (0x10U)
459 
466 #define CAN_EVENT_TX_EVENT_LOST (0x08U)
467 
475 #define CAN_EVENT_TX_EVENT_AVAIL (0x04U)
476 
480 #define CAN_EVENT_TX_FINISHED (0x02U)
481 
488 #define CAN_EVENT_RX_DATA_AVAIL (0x01U)
489 
497 #define CAN_DLC_0B ((uint32_t)0U)
498 #define CAN_DLC_1B ((uint32_t)1U)
499 #define CAN_DLC_2B ((uint32_t)2U)
500 #define CAN_DLC_3B ((uint32_t)3U)
501 #define CAN_DLC_4B ((uint32_t)4U)
502 #define CAN_DLC_5B ((uint32_t)5U)
503 #define CAN_DLC_6B ((uint32_t)6U)
504 #define CAN_DLC_7B ((uint32_t)7U)
505 #define CAN_DLC_8B ((uint32_t)8U)
506 #define CAN_DLC_12B ((uint32_t)9U)
507 #define CAN_DLC_16B ((uint32_t)10U)
508 #define CAN_DLC_20B ((uint32_t)11U)
509 #define CAN_DLC_24B ((uint32_t)12U)
510 #define CAN_DLC_32B ((uint32_t)13U)
511 #define CAN_DLC_48B ((uint32_t)14U)
512 #define CAN_DLC_64B ((uint32_t)15U)
531 #define CAN_FEC_DISABLE_FILTER ((uint32_t)0U)
532 #define CAN_FEC_STORE_RXFIFO0 ((uint32_t)1U)
533 #define CAN_FEC_STORE_RXFIFO1 ((uint32_t)2U)
534 #define CAN_FEC_REJECT_ID ((uint32_t)3U)
535 #define CAN_FEC_SET_PRIO ((uint32_t)4U)
536 #define CAN_FEC_SET_PRIO_STORE_RXFIFO0 ((uint32_t)5U)
537 #define CAN_FEC_SET_PRIO_STORE_RXFIFO1 ((uint32_t)6U)
538 #define CAN_FEC_STORE_RXBUF ((uint32_t)7U)
539 
550 #define CAN_FILTER_RANGE ((uint32_t)0U)
551 #define CAN_FILTER_DUAL_ID ((uint32_t)1U)
552 #define CAN_FILTER_WITH_MASK ((uint32_t)2U)
553 #define CAN_FILTER_DISABLE ((uint32_t)3U)
554 
560 
565 
570 
575 
579 typedef struct CAN_Config_ *CAN_Handle;
580 
606 typedef void (*CAN_EventCbk)(CAN_Handle handle, uint32_t event, uint32_t data, void *userArg);
607 
619 typedef struct
620 {
621  uint32_t stdFilterNum;
623  uint32_t extFilterNum;
630  /*
631  * Note: All Rx and Tx buffer elements include a 64-byte payload if CAN FD
632  * is enabled. Otherwise, they include an 8-byte payload.
633  */
634 
635  uint32_t rxFifoNum[2];
637  uint32_t rxBufNum;
640  uint32_t txBufNum;
642  uint32_t txFifoQNum;
644  uint32_t txFifoQMode;
647  uint32_t txEventFifoNum;
650 
657 typedef struct
658 {
659  uint32_t dbrp;
665  uint32_t dtSeg1;
669  uint32_t dtSeg2;
673  uint32_t dsjw;
677  uint32_t tdcOffset;
683  uint32_t tdcFilterWinLen;
692 
699 typedef struct
700 {
701  uint32_t nbrp;
706  uint32_t ntSeg1;
710  uint32_t ntSeg2;
714  uint32_t nsjw;
725 
734 typedef struct
735 {
738  uint32_t tsPrescaler;
740  uint32_t eventMask;
741  void *userArg;
742 } CAN_Params;
743 
749 typedef struct
750 {
752  uint32_t eventMask;
753  void *userArg;
754  uint32_t intMask;
756  uint32_t txBufNum;
757  uint32_t txFifoQNum;
758  uint32_t txEventFifoNum;
759  uint32_t rxBufNum;
760  uint32_t rxFifoNum[2];
765  bool isOpen;
766 } CAN_Object;
767 
775 typedef struct
776 {
777  bool enableCANFD;
778  bool enableBRS;
780  uint32_t nominalBitRate;
781  uint32_t dataBitRate;
783  void *rxRingBufPtr;
784  void *txRingBufPtr;
785  size_t rxRingBufSize;
786  size_t txRingBufSize;
787 #if (DeviceFamily_PARENT == DeviceFamily_PARENT_CC27XX)
788  uint32_t intPriority;
789  uint32_t rxPinMux;
790  uint32_t txPinMux;
791  uint_least8_t rxPin;
792  uint_least8_t txPin;
793 #endif
794 } CAN_HWAttrs;
795 
803 typedef struct CAN_Config_
804 {
807 
810 } CAN_Config;
811 
812 extern const CAN_Config CAN_config[];
813 extern const uint_least8_t CAN_count;
814 
825 void CAN_init(void);
826 
844 
875 CAN_Handle CAN_open(uint_least8_t index, CAN_Params *params);
876 
886 void CAN_close(CAN_Handle handle);
887 
899 int_fast16_t CAN_read(CAN_Handle handle, CAN_RxBufElement *elem);
900 
913 int_fast16_t CAN_write(CAN_Handle handle, const CAN_TxBufElement *elem);
914 
941 int_fast16_t CAN_writeBuffer(CAN_Handle handle, uint32_t bufIdx, const CAN_TxBufElement *elem);
942 
955 int_fast16_t CAN_readTxEvent(CAN_Handle handle, CAN_TxEventElement *elem);
956 
968 void CAN_getBitTiming(CAN_Handle handle, CAN_BitTimingParams *bitTiming, uint32_t *clkFreq);
969 
984 int_fast16_t CAN_enableLoopbackExt(CAN_Handle handle);
985 
999 int_fast16_t CAN_enableLoopbackInt(CAN_Handle handle);
1000 
1012 int_fast16_t CAN_disableLoopback(CAN_Handle handle);
1013 
1014 #ifdef __cplusplus
1015 }
1016 #endif
1017 
1018 #endif /* ti_drivers_can__include */
ADC_Params params
Definition: Driver_Init.h:11
uint32_t nbrp
Definition: CAN.h:701
MCAN_TxEventFifoElement CAN_TxEventElement
A CAN Tx Event element struct for CAN_readTxEvent().
Definition: CAN.h:569
void(* CAN_EventCbk)(CAN_Handle handle, uint32_t event, uint32_t data, void *userArg)
The definition of a callback function used by the CAN driver.
Definition: CAN.h:606
CAN Object.
Definition: CAN.h:749
bool isOpen
Definition: CAN.h:765
uint32_t rxBufNum
Definition: CAN.h:759
void * userArg
Definition: CAN.h:753
Structure for MCAN Standard Message ID Filter Element.
Definition: MCAN.h:1158
CAN hardware attributes.
Definition: CAN.h:775
uint_least8_t rxPin
Definition: CAN.h:791
uint32_t eventMask
Definition: CAN.h:752
uint32_t txFifoQNum
Definition: CAN.h:642
void CAN_init(void)
This function initializes the CAN module.
int_fast16_t CAN_enableLoopbackInt(CAN_Handle handle)
Enables internal loopback test mode.
uint32_t intPriority
Definition: CAN.h:788
struct CAN_Config_ * CAN_Handle
A handle that is returned from a CAN_open() call.
Definition: CAN.h:579
uint32_t nsjw
Definition: CAN.h:714
MCAN_StdMsgIDFilterElement * stdMsgIDFilterList
Definition: CAN.h:625
uint32_t txPinMux
Definition: CAN.h:790
uint32_t dtSeg1
Definition: CAN.h:665
Structure for MCAN Extended Message ID Filter Element.
Definition: MCAN.h:1213
uint32_t tsPrescaler
Definition: CAN.h:738
bool enableCANFD
Definition: CAN.h:777
StructRingBuf_Object txStructRingBuf
Definition: CAN.h:763
uint32_t dbrp
Definition: CAN.h:659
int_fast16_t CAN_write(CAN_Handle handle, const CAN_TxBufElement *elem)
Sends CAN message using the Tx FIFO/Queue.
uint32_t dtSeg2
Definition: CAN.h:669
size_t txRingBufSize
Definition: CAN.h:786
CAN Message RAM configuration.
Definition: CAN.h:619
struct CAN_Config_ CAN_Config
CAN Global configuration.
CAN_Object * object
Definition: CAN.h:806
CAN_Handle CAN_open(uint_least8_t index, CAN_Params *params)
Initializes a CAN driver instance and returns a handle.
uint32_t txEventFifoNum
Definition: CAN.h:647
const CAN_DataBitRateTimingRaw * dataTiming
Definition: CAN.h:720
uint32_t tdcFilterWinLen
Definition: CAN.h:683
CAN Global configuration.
Definition: CAN.h:803
uint32_t txFifoQNum
Definition: CAN.h:757
Structure for bit timing parameters.
Definition: MCAN.h:441
uint32_t ntSeg2
Definition: CAN.h:710
uint32_t extFilterNum
Definition: CAN.h:623
MCAN_TxBufElement CAN_TxBufElement
A CAN Tx buffer element struct for CAN_write() and CAN_writeBuffer().
Definition: CAN.h:564
CAN_EventCbk eventCbk
Definition: CAN.h:739
MCAN_RxBufElement CAN_RxBufElement
A CAN Rx buffer element struct for CAN_read().
Definition: CAN.h:559
Structure for MCAN Tx Event FIFO element.
Definition: MCAN.h:1106
Structure defining the raw MCAN CAN FD data phase bit rate configuration.
Definition: CAN.h:657
uint32_t txFifoQMode
Definition: CAN.h:644
int_fast16_t CAN_enableLoopbackExt(CAN_Handle handle)
Enables external loopback test mode.
const CAN_BitRateTimingRaw * bitTiming
Definition: CAN.h:737
uint32_t dsjw
Definition: CAN.h:673
uint32_t dataBitRate
Definition: CAN.h:781
uint32_t intMask
Definition: CAN.h:754
uint_least8_t txPin
Definition: CAN.h:792
Definition: StructRingBuf.h:45
const CAN_MsgRamConfig * msgRamConfig
Definition: CAN.h:736
void * rxRingBufPtr
Definition: CAN.h:783
const uint_least8_t CAN_count
size_t rxRingBufSize
Definition: CAN.h:785
MCAN_BitTimingParams CAN_BitTimingParams
A CAN bit timing struct for CAN_getBitTiming().
Definition: CAN.h:574
bool enableBRS
Definition: CAN.h:778
uint32_t txBufNum
Definition: CAN.h:756
uint32_t rxPinMux
Definition: CAN.h:789
void CAN_Params_init(CAN_Params *params)
Initializes the CAN_Params struct to its default values.
MCAN_ExtMsgIDFilterElement * extMsgIDFilterList
Definition: CAN.h:627
bool rejectNonMatchingMsgs
Definition: CAN.h:779
void * txRingBufPtr
Definition: CAN.h:784
uint32_t stdFilterNum
Definition: CAN.h:621
int_fast16_t CAN_read(CAN_Handle handle, CAN_RxBufElement *elem)
Reads a received CAN message.
uint32_t nominalBitRate
Definition: CAN.h:780
Structure for MCAN Tx Buffer element.
Definition: MCAN.h:896
uint32_t ntSeg1
Definition: CAN.h:706
uint32_t eventMask
Definition: CAN.h:740
uint32_t txBufNum
Definition: CAN.h:640
uint32_t txEventFifoNum
Definition: CAN.h:758
int_fast16_t CAN_writeBuffer(CAN_Handle handle, uint32_t bufIdx, const CAN_TxBufElement *elem)
Sends CAN message using a dedicated Tx Buffer.
void * userArg
Definition: CAN.h:741
StructRingBuf_Object rxStructRingBuf
Definition: CAN.h:762
Structure defining the raw MCAN bit rate configuration.
Definition: CAN.h:699
void CAN_close(CAN_Handle handle)
Closes a CAN peripheral specified by handle.
int_fast16_t CAN_readTxEvent(CAN_Handle handle, CAN_TxEventElement *elem)
Reads the next available CAN Tx Event FIFO element.
void CAN_getBitTiming(CAN_Handle handle, CAN_BitTimingParams *bitTiming, uint32_t *clkFreq)
Get the CAN bit timings and functional clock frequency.
Structure for MCAN Rx Buffer element.
Definition: MCAN.h:998
Hardware abstraction layer for M_CAN Controller v3.2.1.
int_fast16_t CAN_disableLoopback(CAN_Handle handle)
Disables loopback test mode.
uint32_t tdcOffset
Definition: CAN.h:677
CAN_EventCbk eventCbk
Definition: CAN.h:751
const CAN_Config CAN_config[]
const CAN_HWAttrs * hwAttrs
Definition: CAN.h:809
uint32_t rxBufNum
Definition: CAN.h:637
CAN Parameters.
Definition: CAN.h:734
© Copyright 1995-2024, Texas Instruments Incorporated. All rights reserved.
Trademarks | Privacy policy | Terms of use | Terms of sale