CAN.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2023, 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  * <hr>
46  * @anchor ti_drivers_CAN_Usage
47  * # Usage
48  *
49  * To use the CAN driver to send and receive messages over the CAN bus, the
50  * application calls the following APIs:
51  * - CAN_open(): Open the CAN driver instance and configure the CAN
52  * controller, placing it in normal operational mode.
53  * - CAN_write(): Transmit a message using the Tx FIFO/Queue. This is the
54  * typical method of transmission.
55  * - CAN_writeBuffer(): Transmit a message using a dedicated Tx Buffer. This
56  * method of transmission requires a custom message RAM configuration and
57  * should only be used if there is an application-specific need that cannot
58  * be met by using the Tx FIFO/Queue.
59  * - CAN_read(): Receive a message. This should be called in a task context
60  * and triggered by the event callback when CAN_EVENT_RX_DATA_AVAIL occurs.
61  * - CAN_close(): Close the CAN driver instance and reset the CAN controller,
62  * placing it in standby operational mode.
63  *
64  * @anchor ti_drivers_CAN_Synopsis
65  * ## Synopsis
66  * The following code example initializes the CAN driver with the default
67  * configuration, transmits a CAN FD message, and waits to read any received
68  * messages.
69  *
70  * @code
71  * // Payload data size indexed by Data Length Code (DLC) field.
72  * static const uint32_t DLCtoDataSize[16] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 12, 16, 20, 24, 32, 48, 64};
73  *
74  * // Rx semaphore.
75  * static SemaphoreP_Handle rxSemHandle;
76  *
77  * void eventCallback(CAN_Handle handle, uint32_t event, uint32_t data, void *userArg)
78  * {
79  * if (event == CAN_EVENT_RX_DATA_AVAIL)
80  * {
81  * SemaphoreP_post(rxSemHandle);
82  * }
83  * // Handle more events here if enabled via the event mask...
84  * }
85  *
86  * void thread(arg0, arg1)
87  * {
88  * int_fast16_t status;
89  * CAN_RxBufElement rxElem;
90  * CAN_TxBufElement txElem;
91  *
92  * // Initialize driver(s).
93  * CAN_init();
94  *
95  * // Create callback semaphore.
96  * SemaphoreP_Params semParams;
97  * SemaphoreP_Params_init(&semParams);
98  * semParams.mode = SemaphoreP_Mode_BINARY;
99  * callbackSemHandle = SemaphoreP_create(0, &(semParams));
100  *
101  * if (callbackSemHandle == NULL)
102  * {
103  * // SemaphoreP_create() failed.
104  * while (1) {}
105  * }
106  *
107  * // Open CAN driver with default configuration.
108  * CAN_Params_init(&canParams);
109  * canParams.eventCbk = eventCallback;
110  * // Setup event mask for events the application is interested in receiving
111  * // the callback for. Typically, only the CAN_EVENT_RX_DATA_AVAIL is required.
112  * canParams.eventMask = CAN_EVENT_RX_DATA_AVAIL;
113  *
114  * canHandle = CAN_open(CONFIG_CAN_0, &canParams);
115  * if (canHandle == NULL)
116  * {
117  * // CAN_open() failed.
118  * while (1) {}
119  * }
120  *
121  * // Setup Tx buffer element:
122  * // CAN FD without Bit Rate Switching
123  * // Extended Message ID = 0x12345678
124  * // Data Length of 64-bytes
125  * // Message marker = 5
126  * txElem.id = 0x12345678U;
127  * txElem.rtr = 0U;
128  * txElem.xtd = 1U;
129  * txElem.esi = 0U;
130  * txElem.brs = 1U;
131  * txElem.dlc = CAN_DLC_64B;
132  * txElem.fdf = 1U;
133  * txElem.efc = 0U;
134  * txElem.mm = 5U;
135  *
136  * // Fill data payload with incrementing values.
137  * for (i = 0; i < DLCtoDataSize[txElem.dlc]; i++)
138  * {
139  * txElem.data[i] = i;
140  * }
141  *
142  * // Transmit message.
143  * CAN_write(canHandle, &txElem);
144  *
145  * while (1)
146  * {
147  * // Wait for Rx data available event.
148  * SemaphoreP_pend(rxSemHandle, (uint32_t)SemaphoreP_WAIT_FOREVER);
149  *
150  * // Read all available messages.
151  * while (CAN_read(canHandle, &rxElem) == CAN_STATUS_SUCCESS)
152  * {
153  * // Process received message.
154  * }
155  * }
156  * }
157  *
158  * @endcode
159  *
160  * More details on usage are provided in the following subsections.
161  *
162  * @anchor ti_drivers_CAN_Examples
163  * ## Examples #
164  * * @ref ti_drivers_CAN_Synopsis "Usage Synopsis"
165  * * @ref ti_drivers_CAN_Example_initMsgRAM "Initialize with custom message RAM configuration"
166  * * @ref ti_drivers_CAN_Example_initRawBitRate "Initialize with raw bit rate timing"
167  *
168  * ## Initializing the CAN Driver
169  *
170  * CAN_init() must be called before any other CAN APIs. This function
171  * initializes common driver resources and calls the device-specific
172  * initialization function to configure the bit rate and message RAM.
173  *
174  * ## Opening the CAN Driver
175  * After initializing the CAN driver by calling CAN_init(), the application
176  * can open a CAN instance by calling CAN_open(). This function
177  * takes an index into the @p CAN_config[] array, and a CAN parameters data
178  * structure. The CAN instance is specified by the index of the CAN in
179  * @p CAN_config[]. Calling CAN_open() a second time with the same index
180  * previously passed to CAN_open() will result in an error. You can,
181  * though, re-use the index if the instance is closed via CAN_close().
182  *
183  * If no #CAN_Params structure is passed to CAN_open(), default values are
184  * used. If the open call is successful, it returns a non-NULL value.
185  * The CAN driver APIs are non-blocking; there is no configurable return behavior.
186  *
187  * @anchor ti_drivers_CAN_Example_initMsgRAM
188  * Example initializing the CAN driver with a custom message RAM configuration
189  * to receive only filtered message IDs:
190  *
191  * @note CAN driver SysConfig must be setup with 'Reject Non-Matching Messages' enabled.
192  *
193  * @code
194  * #define STD_MSG_FILTER_NUM 2U
195  * #define EXT_MSG_FILTER_NUM 1U
196  *
197  * static MCAN_StdMsgIDFilterElement stdMsgIDFilter[STD_MSG_FILTER_NUM] =
198  * {{.sfid1 = 0x555, .sfid2 = 0x444, .sfec = CAN_FEC_STORE_RXFIFO0, .sft = CAN_FILTER_DUAL_ID},
199  * {.sfid1 = 0x123, .sfid2 = 0U, .sfec = CAN_FEC_STORE_RXBUF, .sft = 0U}};
200  *
201  * static MCAN_ExtMsgIDFilterElement extMsgIDFilter[EXT_MSG_FILTER_NUM] =
202  * {{.efid1 = 0x1234578, .efid2 = 0x1234600, .efec = CAN_FEC_STORE_RXFIFO1, .eft = CAN_FILTER_RANGE}};
203  *
204  * const CAN_MsgRAMConfig msgRAMConfig = {
205  * .stdFilterNum = STD_MSG_FILTER_NUM,
206  * .extFilterNum = EXT_MSG_FILTER_NUM,
207  * .stdMsgIDFilterList = &stdMsgIDFilter[0],
208  * .extMsgIDFilterList = &extMsgIDFilter[0],
209  *
210  * .rxFIFONum[0] = 10U,
211  * .rxFIFONum[1] = 2U,
212  * .rxBufNum = 1U,
213  * .txBufNum = 1U,
214  * .txFIFOQNum = 5U,
215  * .txFIFOQMode = 1U,
216  * };
217  *
218  * int_fast16_t status;
219  *
220  * // Initialize driver(s).
221  * CAN_init();
222  *
223  * // Open CAN driver with custom message filters.
224  * CAN_Params_init(&canParams);
225  * canParams.msgRAMConfig = &msgRAMConfig;
226  * canParams.eventCbk = eventCallback;
227  * // Setup event mask for events the application is interested in receiving
228  * // the callback for. Typically, only the CAN_EVENT_RX_DATA_AVAIL is required.
229  * canParams.eventMask = CAN_EVENT_RX_DATA_AVAIL;
230  *
231  * canHandle = CAN_open(CONFIG_CAN_0, &canParams);
232  * if (canHandle == NULL)
233  * {
234  * // CAN_open() failed.
235  * while (1) {}
236  * }
237  * @endcode
238  *
239  * @anchor ti_drivers_CAN_Example_initRawBitRate
240  * Example initializing the CAN driver with a specific raw bit rate timing:
241  * @note For this example, CAN driver SysConfig should be setup with 'CAN FD
242  * Operation' and 'Bit Rate Switching' enabled. The nominal and data bit rates
243  * selected in SysConfig will be ignored since raw bit rate timing parameters
244  * are provided to CAN_open().
245  *
246  * @code
247  * const CAN_DataBitRateTimingRaw rawDataBitRateTiming = {
248  * // 1Mbps with 40MHz clk and 80% sample point ((40E6 / 2) / (15 + 4 + 1) = 1E6)
249  * // Add 1 to each programmed bit time to get functional value and +1 for for prop segment
250  * .dbrp = 1U,
251  * .dtSeg1 = 14U,
252  * .dtSeg2 = 3U,
253  * .dsjw = 3U,
254  * .tdcOffset = 1U,
255  * .tdcFilterWinLen = 2U
256  * };
257  *
258  * const CAN_BitRateTimingRaw rawBitTiming = {
259  * // 500kbps nominal with 40MHz clk and 87.5% sample point ((40E6 / 1) / (70 + 9 + 1) = 500E3)
260  * // Add 1 to each programmed bit time to get functional value and +1 for for prop segment
261  * .nbrp = 0U,
262  * .ntSeg1 = 69U,
263  * .ntSeg2 = 8U,
264  * .nsjw = 8U,
265  * .dataTiming = &rawDataBitRateTiming
266  * };
267  *
268  * int_fast16_t status;
269  *
270  * // Initialize driver(s).
271  * CAN_init();
272  *
273  * // Open CAN with specific raw bit timing.
274  * CAN_Params_init(&canParams);
275  * canParams.bitTiming = &rawBitTiming;
276  * canParams.eventCbk = eventCallback;
277  * // Setup event mask for events the application is interested in receiving
278  * // the callback for. Typically, only the CAN_EVENT_RX_DATA_AVAIL is required.
279  * canParams.eventMask = CAN_EVENT_RX_DATA_AVAIL;
280  *
281  * canHandle = CAN_open(CONFIG_CAN_0, &canParams);
282  * if (canHandle == NULL)
283  * {
284  * // CAN_open() failed.
285  * while (1) {}
286  * }
287  * @endcode
288  *
289  * ## CAN Message RAM Configuration
290  *
291  * The default message RAM configuration is as follows:
292  * - No Rx filters.
293  * - Tx Queue (message with lowest ID in the queue will be transmitted first)
294  * with a fixed device-specific number of Tx buffers.
295  * - No Tx event FIFO.
296  * - Fixed device-specific number of Rx FIFO0 buffers.
297  * - No Rx FIFO1 buffers.
298  * - No dedicated Rx buffers.
299  *
300  * The number of default Tx and Rx buffers varies depending on the size of the
301  * device's message RAM. Check the doxygen for the device-specific CAN
302  * implementation to find the message RAM size. If using a custom message RAM
303  * configuration, utilize the entire space by maximizing the number of Rx/Tx
304  * buffers for optimal performance.
305  *
306  * ## CAN Write Behavior
307  * CAN_write() will return immediately after the message is loaded into the CAN
308  * controller's message RAM and pending transfer; it does not wait for the CAN
309  * message to be transmitted on the bus before returning. The CAN controller will
310  * automatically handle transmission retries in the event of a failure.
311  *
312  * ## CAN Read Behavior
313  * When a message is received in Rx FIFO0/1 or a dedicated Rx buffer, the CAN
314  * driver's IRQ handler automatically reads the Rx buffer element from the CAN
315  * controller's message RAM and stores it in a ring buffer whose size is
316  * configurable in SysConfig. When CAN_read() is called, the Rx buffer element
317  * is copied from the ring buffer to the application. If the ring buffer becomes
318  * full, any new messages received will be lost until the application frees
319  * space in the ring buffer by calling CAN_read().
320  *******************************************************************************
321  */
322 #ifndef ti_drivers_can__include
323 #define ti_drivers_can__include
324 
325 #include <stdint.h>
326 #include <stddef.h>
327 
329 #include <ti/devices/DeviceFamily.h>
330 
331 #include <third_party/mcan/MCAN.h>
332 
333 #ifdef __cplusplus
334 extern "C" {
335 #endif
336 
347 #define CAN_STATUS_SUCCESS ((int_fast16_t)0)
348 
355 #define CAN_STATUS_ERROR ((int_fast16_t)-1)
356 
363 #define CAN_STATUS_NOT_SUPPORTED ((int_fast16_t)-2)
364 
370 #define CAN_STATUS_TX_BUF_FULL ((int_fast16_t)-3)
371 
378 #define CAN_STATUS_NO_RX_MSG_AVAIL ((int_fast16_t)-4)
379 
395 #define CAN_EVENT_SPI_XFER_ERROR (0x200U)
396 
403 #define CAN_EVENT_BIT_ERR_UNCORRECTED (0x100U)
404 
413 #define CAN_EVENT_RX_RING_BUFFER_FULL (0x80U)
414 
420 #define CAN_EVENT_RX_FIFO_MSG_LOST (0x40U)
421 
425 #define CAN_EVENT_ERR_PASSIVE (0x20U)
426 
430 #define CAN_EVENT_ERR_ACTIVE (0x10U)
431 
435 #define CAN_EVENT_BUS_OFF (0x08U)
436 
440 #define CAN_EVENT_BUS_ON (0x04U)
441 
445 #define CAN_EVENT_TX_FINISHED (0x02U)
446 
453 #define CAN_EVENT_RX_DATA_AVAIL (0x01U)
454 
461 
466 
470 typedef struct CAN_Config_ *CAN_Handle;
471 
493 typedef void (*CAN_EventCbk)(CAN_Handle handle, uint32_t event, uint32_t data, void *userArg);
494 
506 typedef struct
507 {
508  uint32_t stdFilterNum;
510  uint32_t extFilterNum;
517  /*
518  * Note: All Rx and Tx buffer elements include a 64-byte payload if CAN FD
519  * is enabled. Otherwise, they include an 8-byte payload.
520  */
521 
522  uint32_t rxFIFONum[2];
524  uint32_t rxBufNum;
527  uint32_t txBufNum;
529  uint32_t txFIFOQNum;
531  uint32_t txFIFOQMode;
534 
541 typedef struct
542 {
543  uint32_t dbrp;
548  uint32_t dtSeg1;
551  uint32_t dtSeg2;
554  uint32_t dsjw;
557  uint32_t tdcOffset;
559  uint32_t tdcFilterWinLen;
563 
570 typedef struct
571 {
572  uint32_t nbrp;
576  uint32_t ntSeg1;
579  uint32_t ntSeg2;
582  uint32_t nsjw;
591 
600 typedef struct
601 {
605  uint32_t eventMask;
606  void *userArg;
607 } CAN_Params;
608 
614 typedef struct
615 {
617  uint32_t eventMask;
618  void *userArg;
619  uint32_t intMask;
621  uint32_t txBufNum;
622  uint32_t txFIFOQNum;
623  uint32_t rxBufNum;
624  uint32_t rxFIFONum[2];
629  bool isOpen;
630 } CAN_Object;
631 
639 typedef struct
640 {
641  bool enableCANFD;
642  bool enableBRS;
644  uint32_t nominalBitRate;
645  uint32_t dataBitRate;
647  void *rxRingBufPtr;
648  void *txRingBufPtr;
649  size_t rxRingBufSize;
650  size_t txRingBufSize;
651 #if (DeviceFamily_PARENT == DeviceFamily_PARENT_CC27XX)
652  uint32_t intPriority;
653  uint32_t rxPinMux;
654  uint32_t txPinMux;
655  uint_least8_t rxPin;
656  uint_least8_t txPin;
657 #endif
658 } CAN_HWAttrs;
659 
667 typedef struct CAN_Config_
668 {
671 
674 } CAN_Config;
675 
676 extern const CAN_Config CAN_config[];
677 extern const uint_least8_t CAN_count;
678 
679 /* Data Length Code for use with CAN_RxBufElement & CAN_TxBufElement */
680 #define CAN_DLC_0B ((uint32_t)0U)
681 #define CAN_DLC_1B ((uint32_t)1U)
682 #define CAN_DLC_2B ((uint32_t)2U)
683 #define CAN_DLC_3B ((uint32_t)3U)
684 #define CAN_DLC_4B ((uint32_t)4U)
685 #define CAN_DLC_5B ((uint32_t)5U)
686 #define CAN_DLC_6B ((uint32_t)6U)
687 #define CAN_DLC_7B ((uint32_t)7U)
688 #define CAN_DLC_8B ((uint32_t)8U)
689 #define CAN_DLC_12B ((uint32_t)9U)
690 #define CAN_DLC_16B ((uint32_t)10U)
691 #define CAN_DLC_20B ((uint32_t)11U)
692 #define CAN_DLC_24B ((uint32_t)12U)
693 #define CAN_DLC_32B ((uint32_t)13U)
694 #define CAN_DLC_48B ((uint32_t)14U)
695 #define CAN_DLC_64B ((uint32_t)15U)
697 /*
698  * Filter Element Configuration
699  * 0 = Disable filter element
700  * 1 = Store in Rx FIFO 0 if filter matches
701  * 2 = Store in Rx FIFO 1 if filter matches
702  * 3 = Reject ID if filter matches
703  * 4 = Set priority if filter matches
704  * 5 = Set priority and store in FIFO 0 if filter matches
705  * 6 = Set priority and store in FIFO 1 if filter matches
706  * 7 = Store into Rx Buffer or as debug message,
707  * configuration of SFT[1:0] ignored.
708  * If SFEC = 4-6, a match sets high priority
709  * message status and generates an interrupt.
710  */
711 #define CAN_FEC_DISABLE_FILTER 0U
712 #define CAN_FEC_STORE_RXFIFO0 1U
713 #define CAN_FEC_STORE_RXFIFO1 2U
714 #define CAN_FEC_REJECT_ID 3U
715 #define CAN_FEC_SET_PRIO 4U
716 #define CAN_FEC_SET_PRIO_STORE_RXFIFO0 5U
717 #define CAN_FEC_SET_PRIO_STORE_RXFIFO1 6U
718 #define CAN_FEC_STORE_RXBUF 7U
719 
720 /*
721  * Filter Type
722  * 0 = Range filter from SFID1 to SFID2 (SFID2 >= SFID1)
723  * 1 = Dual ID filter for SFID1 or SFID2
724  * 2 = Classic filter: SFID1 = filter, SFID2 = mask
725  * 3 = Filter element disabled
726  */
727 #define CAN_FILTER_RANGE 0U
728 #define CAN_FILTER_DUAL_ID 1U
729 #define CAN_FILTER_WITH_MASK 2U
730 #define CAN_FILTER_DISABLE 3U
731 
742 void CAN_init(void);
743 
760 
785 CAN_Handle CAN_open(uint_least8_t index, CAN_Params *params);
786 
796 void CAN_close(CAN_Handle handle);
797 
809 int_fast16_t CAN_read(CAN_Handle handle, CAN_RxBufElement *elem);
810 
823 int_fast16_t CAN_write(CAN_Handle handle, const CAN_TxBufElement *elem);
824 
851 int_fast16_t CAN_writeBuffer(CAN_Handle handle, uint32_t bufIdx, const CAN_TxBufElement *elem);
852 
865 int_fast16_t CAN_enableLoopbackExt(CAN_Handle handle);
866 
879 int_fast16_t CAN_enableLoopbackInt(CAN_Handle handle);
880 
892 int_fast16_t CAN_disableLoopback(CAN_Handle handle);
893 
894 #ifdef __cplusplus
895 }
896 #endif
897 
898 #endif /* ti_drivers_can__include */
ADC_Params params
Definition: Driver_Init.h:11
uint32_t stdFilterNum
Definition: CAN.h:508
uint32_t nbrp
Definition: CAN.h:572
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:493
CAN Object.
Definition: CAN.h:614
bool isOpen
Definition: CAN.h:629
uint32_t rxBufNum
Definition: CAN.h:623
void * userArg
Definition: CAN.h:618
Structure for MCAN Standard Message ID Filter Element.
Definition: MCAN.h:1152
CAN hardware attributes.
Definition: CAN.h:639
uint_least8_t rxPin
Definition: CAN.h:655
uint32_t eventMask
Definition: CAN.h:617
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:652
struct CAN_Config_ * CAN_Handle
A handle that is returned from a CAN_open() call.
Definition: CAN.h:470
uint32_t nsjw
Definition: CAN.h:582
uint32_t txPinMux
Definition: CAN.h:654
uint32_t dtSeg1
Definition: CAN.h:548
Structure for MCAN Extended Message ID Filter Element.
Definition: MCAN.h:1184
bool enableCANFD
Definition: CAN.h:641
StructRingBuf_Object txStructRingBuf
Definition: CAN.h:627
uint32_t txFIFOQMode
Definition: CAN.h:531
uint32_t dbrp
Definition: CAN.h:543
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:551
size_t txRingBufSize
Definition: CAN.h:650
struct CAN_Config_ CAN_Config
CAN Global configuration.
uint32_t rxBufNum
Definition: CAN.h:524
CAN_Object * object
Definition: CAN.h:670
uint32_t extFilterNum
Definition: CAN.h:510
CAN_Handle CAN_open(uint_least8_t index, CAN_Params *params)
Initializes a CAN driver instance and returns a handle.
const CAN_DataBitRateTimingRaw * dataTiming
Definition: CAN.h:587
uint32_t tdcFilterWinLen
Definition: CAN.h:559
CAN Global configuration.
Definition: CAN.h:667
uint32_t ntSeg2
Definition: CAN.h:579
MCAN_TxBufElement CAN_TxBufElement
A CAN Tx buffer element struct for CAN_write() and CAN_writeBuffer().
Definition: CAN.h:465
CAN_EventCbk eventCbk
Definition: CAN.h:604
MCAN_RxBufElement CAN_RxBufElement
A CAN Rx buffer element struct for CAN_read().
Definition: CAN.h:460
Structure defining the raw MCAN CAN FD data phase bit rate configuration.
Definition: CAN.h:541
int_fast16_t CAN_enableLoopbackExt(CAN_Handle handle)
Enables external loopback test mode.
const CAN_BitRateTimingRaw * bitTiming
Definition: CAN.h:603
uint32_t dsjw
Definition: CAN.h:554
uint32_t dataBitRate
Definition: CAN.h:645
uint32_t intMask
Definition: CAN.h:619
uint_least8_t txPin
Definition: CAN.h:656
Definition: StructRingBuf.h:45
uint32_t txFIFOQNum
Definition: CAN.h:529
void * rxRingBufPtr
Definition: CAN.h:647
uint32_t txFIFOQNum
Definition: CAN.h:622
const uint_least8_t CAN_count
size_t rxRingBufSize
Definition: CAN.h:649
bool enableBRS
Definition: CAN.h:642
uint32_t txBufNum
Definition: CAN.h:621
uint32_t rxPinMux
Definition: CAN.h:653
void CAN_Params_init(CAN_Params *params)
Initializes the CAN_Params struct to its default values.
MCAN_StdMsgIDFilterElement * stdMsgIDFilterList
Definition: CAN.h:512
bool rejectNonMatchingMsgs
Definition: CAN.h:643
void * txRingBufPtr
Definition: CAN.h:648
uint32_t txBufNum
Definition: CAN.h:527
int_fast16_t CAN_read(CAN_Handle handle, CAN_RxBufElement *elem)
Reads a received CAN message.
uint32_t nominalBitRate
Definition: CAN.h:644
Structure for MCAN Tx Buffer element.
Definition: MCAN.h:888
uint32_t ntSeg1
Definition: CAN.h:576
uint32_t eventMask
Definition: CAN.h:605
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:606
StructRingBuf_Object rxStructRingBuf
Definition: CAN.h:626
Structure defining the raw MCAN bit rate configuration.
Definition: CAN.h:570
void CAN_close(CAN_Handle handle)
Closes a CAN peripheral specified by handle.
Structure for MCAN Rx Buffer element.
Definition: MCAN.h:992
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:557
CAN_EventCbk eventCbk
Definition: CAN.h:616
const CAN_MsgRAMConfig * msgRAMConfig
Definition: CAN.h:602
const CAN_Config CAN_config[]
const CAN_HWAttrs * hwAttrs
Definition: CAN.h:673
CAN Message RAM configuration.
Definition: CAN.h:506
MCAN_ExtMsgIDFilterElement * extMsgIDFilterList
Definition: CAN.h:514
CAN Parameters.
Definition: CAN.h:600
© Copyright 1995-2023, Texas Instruments Incorporated. All rights reserved.
Trademarks | Privacy policy | Terms of use | Terms of sale