xWRL6432 MMWAVE-L-SDK  05.04.00.01
canfd_lld.h File Reference

Introduction

This is the header file for the CANFD driver which exposes the data structures and exported API which can be used by the applications to use the CANFD driver.

Go to the source code of this file.

Data Structures

struct  CANFDLLD_MCANLoopbackCfgParams
 Data structure defines the MCAN Loopback parameters. More...
 
struct  CANFDLLD_MCANBitTimingParams
 Data structure defines the parameters for bit timing calculation. Bit timing related to data phase will be valid only in case where MCAN is put in CANFD mode and will be '0' otherwise. More...
 
struct  CANFDLLD_MCANTdcConfig
 Data structure defines the MCAN Transmitter Delay Compensation parameters. More...
 
struct  CANFDLLD_MCANGlobalFiltConfig
 Data structure defines the MCAN Global Filter Configuration parameters. More...
 
struct  CANFDLLD_MCANMsgRAMCfgParams
 Data structure defines the MCAN Message RAM Configuration Parameters. Message RAM can contain following sections: Standard ID filters, Extended ID filters, TX FIFO(or TX Q), TX Buffers, TX EventFIFO, RX FIFO0, RX FIFO1, RX Buffer. Note: If particular section in the RAM is not used then it's size should be initialized to '0' (Number of buffers in case of Tx/Rx buffer). More...
 
struct  CANFDLLD_MCANECCConfigParams
 Data structure defines the MCAN ECC configuration parameters. More...
 
struct  CANFDLLD_MCANErrCntStatus
 Data structure defines the MCAN error logging counters status. More...
 
struct  CANFDLLD_MCANProtocolStatus
 Data structure defines the MCAN protocol status. More...
 
struct  CANFDLLD_MCANECCErrForceParams
 Data structure defines the ECC Error forcing. More...
 
struct  CANFDLLD_MCANECCErrStatus
 Data structure defines the ECC Error Status. More...
 
struct  CANFDLLD_ErrStatusResp
 Response structure definition for Error and status information. More...
 
struct  CANFDLLD_MCANInitParams
 Data structure defines the MCAN initialization parameters. More...
 
struct  CANFDLLD_OptionTLV
 Options TLV data structure. More...
 
struct  CANFDLLD_Object
 CANFD Master Control Block. More...
 
struct  CANFDLLD_DmaMsgConfig
 CANFD DMA message configuration used for Tx. More...
 
struct  CANFDLLD_DmaRxBuf
 CANFD Rx Buffer used in DMA mode. More...
 
struct  CANFDLLD_MessageObject
 CAN message object block. More...
 
struct  CANFDLLD_MCANMsgObjectStats
 Data structure defines the software maintained message object statistics. More...
 

Macros

#define ATTRIBUTE_WEAK   __attribute__((weak))
 
#define MCAN_MAX_TX_MSG_OBJECTS   (32U)
 Maximum number of Tx message objects that can be supported by CANFD. More...
 
#define MCAN_MAX_RX_MSG_OBJECTS   (32U)
 Maximum number of Rx message objects that can be supported by CANFD. More...
 
#define MCAN_MAX_MSG_OBJECTS   (MCAN_MAX_TX_MSG_OBJECTS + MCAN_MAX_RX_MSG_OBJECTS)
 Maximum number of message objects that can be supported by CANFD. More...
 
#define MCAN_MSG_RAM_STD_ELEM_SIZE   (1U)
 Standard ID Filter Element Size. More...
 
#define MCAN_MSG_RAM_EXT_ELEM_SIZE   (2U)
 Extended ID Filter Element Size. More...
 
#define MCAN_MSG_HEADER_SIZE   (8U)
 MCAN Header size in Bytes. More...
 
#define MCAN_MSG_RAM_TX_RX_ELEM_SIZE   (18U)
 Tx/Rx Element Size. 18 words = 18 * 4 = 72 bytes: 8 bytes of header and 64 bytes of data. More...
 
#define XTD_MSGID_MASK   (0x1fffffffU)
 Message Identifier Masks. More...
 
#define STD_MSGID_MASK   (0x7ffU)
 
#define STD_MSGID_SHIFT   (18U)
 
#define MCAN_MAX_PAYLOAD_BYTES   (64U)
 Maximum payload supported by CAN-FD protocol in bytes. More...
 
#define MCAN_MAX_RX_BUFFERS   (64U)
 Maximum number of Rx buffers. More...
 
#define MCAN_MAX_TX_BUFFERS   (32U)
 Maximum number of Tx buffers. More...
 
#define CANFD_UTILS_ARRAYSIZE(x)   (sizeof(x) / sizeof(x[0]))
 Macro to get the size of an array. More...
 
#define CANFD_UTILS_GETARRAYINDEX(member, array)   (member - &array[0])
 Get the index of the given element within an array. More...
 
#define CANFD_UTILS_ARRAYISMEMBER(member, array)
 Macro to determine if a member is part of an array. More...
 
#define MCAN_INTR_MASK
 Defines all the interrupt are enabled. More...
 
#define CANFD_DMA_TX_COMPLETION_INTERMEDIATE   (1U)
 completion type for Tx in dma mode - Intermediate completion More...
 
#define CANFD_DMA_TX_COMPLETION_FINAL   (2U)
 completion type for Tx in dma mode - Final completion More...
 
#define CANFD_DMA_RX_COMPLETION_INTERMEDIATE   (1U)
 completion type for Rx in dma mode - Intermediate completion More...
 
#define CANFD_DMA_RX_COMPLETION_FINAL   (2U)
 completion type for Rx in dma mode - Final completion More...
 

Typedefs

typedef void * CANFDLLD_DmaHandle
 
typedef void * CANFDLLD_DmaChConfig
 
typedef CANFDLLD_ObjectCANFDLLD_Handle
 CANFD module handle returned by the CANFD_lld_init() API call. More...
 
typedef CANFDLLD_MessageObjectCANFDLLD_MsgObjHandle
 CANFD message object handle returned by the CANFD_lld_createMsgObject() API call. More...
 

Enumerations

enum  CANFDLLD_MCANElemSize {
  CANFDLLD_MCANElemSize_8BYTES = 0U, CANFDLLD_MCANElemSize_12BYTES = 1U, CANFDLLD_MCANElemSize_16BYTES = 2U, CANFDLLD_MCANElemSize_20BYTES = 3U,
  CANFDLLD_MCANElemSize_24BYTES = 4U, CANFDLLD_MCANElemSize_32BYTES = 5U, CANFDLLD_MCANElemSize_48BYTES = 6U, CANFDLLD_MCANElemSize_64BYTES = 7U
}
 This enumeration defines the MCAN FIFO/Buffer element Size. More...
 
enum  CANFDLLD_DriverState { CANFDLLD_DriverState_UNINIT, CANFDLLD_DriverState_STARTED, CANFDLLD_DriverState_STOPPED, CANFDLLD_DriverState_SLEEP }
 This enumeration defines the values used to represent the CANFD driver state. More...
 
enum  CANFDLLD_MCANOperationMode { CANFDLLD_MCANOperationMode_NORMAL = 0U, CANFDLLD_MCANOperationMode_SW_INIT = 1U }
 Enumerates the values used to represent the MCAN mode of operation. More...
 
enum  CANFDLLD_Direction { CANFDLLD_Direction_RX, CANFDLLD_Direction_TX }
 This enumeration defines the values used to set the direction of message object. More...
 
enum  CANFDLLD_MCANXidType { CANFDLLD_MCANXidType_11_BIT, CANFDLLD_MCANXidType_29_BIT }
 This enumeration defines the values used to represent the CAN Identifier Type. More...
 
enum  CANFDLLD_MCANFrameType { CANFDLLD_MCANFrameType_CLASSIC, CANFDLLD_MCANFrameType_FD }
 This enumeration defines the CAN frame type. More...
 
enum  CANFDLLD_MCANTimeOutSelect { CANFDLLD_MCANTimeOutSelect_CONT = 0U, CANFDLLD_MCANTimeOutSelect_TX_EVENT_FIFO = 1U, CANFDLLD_MCANTimeOutSelect_RX_FIFO0 = 2U, CANFDLLD_MCANTimeOutSelect_RX_FIFO1 = 3U }
 This enumeration defines the MCAN timeout counter configuration. More...
 
enum  CANFDLLD_MCANECCErrType { CANFDLLD_MCANECCErrType_SEC = 0U, CANFDLLD_MCANECCErrType_DED = 1U }
 This enumeration defines the MCAN ECC Error Types. More...
 
enum  CANFDLLD_MCANLoopBackMode { CANFDLLD_MCANLoopBackMode_INTERNAL = 0U, CANFDLLD_MCANLoopBackMode_EXTERNAL = 1U }
 This enumeration defines the MCAN Loopback mode. More...
 
enum  CANFDLLD_MCANCommState { CANFDLLD_MCANCommState_SYNCHRONIZING = 0U, CANFDLLD_MCANCommState_IDLE = 1U, CANFDLLD_MCANCommState_RECEIVER = 2U, CANFDLLD_MCANCommState_TRANSMITTER = 3U }
 This enumeration defines the MCAN's communication state. More...
 
enum  CANFDLLD_MCANErrCode {
  CANFDLLD_MCANErrCode_NO_ERROR = 0U, CANFDLLD_MCANErrCode_STUFF_ERROR = 1U, CANFDLLD_MCANErrCode_FORM_ERROR = 2U, CANFDLLD_MCANErrCode_ACK_ERROR = 3U,
  CANFDLLD_MCANErrCode_BIT1_ERROR = 4U, CANFDLLD_MCANErrCode_BIT0_ERROR = 5U, CANFDLLD_MCANErrCode_CRC_ERROR = 6U, CANFDLLD_MCANErrCode_NO_CHANGE = 7U
}
 This enumeration defines the MCAN's Error Code. More...
 
enum  CANFDLLD_Reason {
  CANFDLLD_Reason_RX = 0x1, CANFDLLD_Reason_TX_COMPLETION = 0x2, CANFDLLD_Reason_TX_CANCELED = 0x3, CANFDLLD_Reason_ECC_ERROR = 0x4,
  CANFDLLD_Reason_BUSOFF = 0x5, CANFDLLD_Reason_PROTOCOL_ERR_DATA_PHASE = 0x6, CANFDLLD_Reason_PROTOCOL_ERR_ARB_PHASE = 0x7
}
 This enumeration describes a list of all the reasons for which the driver will invoke application callback functions. More...
 
enum  CANFDLLD_Option {
  CANFDLLD_Option_MCAN_ERROR_COUNTER, CANFDLLD_Option_MCAN_PROTOCOL_STATUS, CANFDLLD_Option_MCAN_MSG_OBJECT_STATS, CANFDLLD_Option_MCAN_MODE,
  CANFDLLD_Option_MCAN_LOOPBACK, CANFDLLD_Option_MCAN_POWER_DOWN
}
 This enumeration defines the values used to represent the GET/SET options. More...
 

Functions

int32_t CANFD_lld_init (CANFDLLD_Handle hCanfd)
 
int32_t CANFD_lld_deInit (CANFDLLD_Handle handle)
 
int32_t CANFD_lld_configBitTime (CANFDLLD_Handle handle, const CANFDLLD_MCANBitTimingParams *bitTimeParams)
 
int32_t CANFD_lld_createMsgObject (CANFDLLD_Handle handle, CANFDLLD_MessageObject *ptrCanMsgObj)
 
int32_t CANFD_lld_createRxRangeMsgObject (CANFDLLD_Handle handle, CANFDLLD_MessageObject *ptrCanMsgObj)
 
int32_t CANFD_lld_deleteMsgObject (CANFDLLD_MsgObjHandle handle)
 
int32_t CANFD_lld_write (CANFDLLD_MsgObjHandle handle, uint32_t id, CANFDLLD_MCANFrameType frameType, uint32_t dataLength, const uint8_t *data)
 
int32_t CANFD_lld_writeCancel (CANFDLLD_MsgObjHandle handle)
 
int32_t CANFD_lld_writeDma (CANFDLLD_MsgObjHandle handle, uint32_t id, CANFDLLD_MCANFrameType frameType, uint32_t dataLengthPerMsg, uint32_t numMsgs, void *data)
 
int32_t CANFD_lld_writeDmaTriggerNext (CANFDLLD_MsgObjHandle handle)
 
uint32_t CANFD_lld_getFilterEventConfig (uint32_t eventNum)
 
int32_t CANFD_lld_read (CANFDLLD_MsgObjHandle handle, uint32_t *id, CANFDLLD_MCANFrameType *ptrFrameType, CANFDLLD_MCANXidType *idType, uint32_t *ptrDataLength, uint8_t *data)
 
int32_t CANFD_lld_readDmaConfig (CANFDLLD_MsgObjHandle handle, void *data, uint32_t numDmaRxBuf)
 
int32_t CANFD_lld_getOptions (CANFDLLD_Handle handle, CANFDLLD_OptionTLV *ptrOptInfo)
 
int32_t CANFD_lld_setOptions (CANFDLLD_Handle handle, const CANFDLLD_OptionTLV *ptrOptInfo)
 
void CANFD_lld_int0Isr (CANFDLLD_Object *ptrCanFdObj)
 
void CANFD_lld_int1Isr (CANFDLLD_Object *ptrCanFdObj)
 
ATTRIBUTE_WEAK void CANFD_lld_dataAppCallBack (CANFDLLD_MsgObjHandle handle, CANFDLLD_Reason reason)
 Application specified callback function which is invoked by the CANFD driver once transmit is complete or data has been received for the specified message object. More...
 
ATTRIBUTE_WEAK void CANFD_lld_errStatusAppCallBack (CANFDLLD_Handle handle, CANFDLLD_Reason reason, CANFDLLD_ErrStatusResp *errStatusResp)
 Application specified callback function which is invoked by the CANFD driver on error or status change. More...
 
int32_t CANFD_lld_dmaOpen (CANFDLLD_Handle canfdHandle, CANFDLLD_DmaChConfig dmaChCfg)
 API to open an CANFD DMA channel. More...
 
int32_t CANFD_lld_dmaClose (CANFDLLD_Handle canfdHandle)
 API to close an CANFD DMA channel. More...
 
int32_t CANFD_lld_createDmaTxMsgObject (CANFDLLD_Object *ptrCanFdObj, CANFDLLD_MessageObject *ptrCanMsgObj)
 API to configure dma for the Tx message object. Called from the API CANFD_lld_createMsgObject. More...
 
int32_t CANFD_lld_deleteDmaTxMsgObject (CANFDLLD_Object *ptrCanFdObj, CANFDLLD_MessageObject *ptrCanMsgObj)
 API to delete dma configuration for the Tx message object. Called from the API CANFD_lld_deleteMsgObject. More...
 
int32_t CANFD_lld_configureDmaTx (CANFDLLD_Object *ptrCanFdObj, CANFDLLD_MessageObject *ptrCanMsgObj, uint32_t dataLengthPerMsg, uint32_t numMsgs, const void *data)
 API to enable dma event transfer for the Tx. Called from the API CANFD_lld_writeDma. More...
 
int32_t CANFD_lld_cancelDmaTx (CANFDLLD_Object *ptrCanFdObj, CANFDLLD_MessageObject *ptrCanMsgObj)
 API to disbale dma event transfer for the Tx to cancel the transfer. More...
 
ATTRIBUTE_WEAK void CANFD_dmaTxCompletionCallback (CANFDLLD_MessageObject *ptrCanMsgObj, void *data, uint32_t completionType)
 Callback function for the Tx completion. This is called for each message in the array of msgs provided in CANFD_lld_configureDmaTx. data will point to the current transmitted message. For intermediate message transfer completion the completionType will be set to CANFD_DMA_TX_COMPLETION_INTERMEDIATE for last message transfer completion the completionType will be set to CANFD_DMA_TX_COMPLETION_FINAL. More...
 
int32_t CANFD_lld_createDmaRxMsgObject (CANFDLLD_Object *ptrCanFdObj, CANFDLLD_MessageObject *ptrCanMsgObj)
 API to configure dma for the Rx message object. Called from the CANFD_lld_createMsgObject. More...
 
int32_t CANFD_lld_deleteDmaRxMsgObject (CANFDLLD_Object *ptrCanFdObj, CANFDLLD_MessageObject *ptrCanMsgObj)
 API to delete dma configuration for the Rx message object. Called from the CANFD_lld_deleteMsgObject. More...
 
int32_t CANFD_lld_configureDmaRx (CANFDLLD_Object *ptrCanFdObj, CANFDLLD_MessageObject *ptrCanMsgObj, uint32_t dataLengthPerMsg, uint32_t numMsgs, const void *data)
 API to enable dma event transfer for the Rx. Called from the API CANFD_lld_readDma. More...
 
ATTRIBUTE_WEAK void CANFD_dmaRxCompletionCallback (CANFDLLD_MessageObject *ptrCanMsgObj, void *data, uint32_t completionType)
 Callback function for the Rx completion. This is called for each message in the array of msgs provided in CANFD_lld_configureDmaRx. data will point to the current received message. For intermediate message transfer completion the completionType will be set to CANFD_DMA_RX_COMPLETION_INTERMEDIATE for last message transfer completion the completionType will be set to CANFD_DMA_RX_COMPLETION_FINAL. More...
 

Macro Definition Documentation

◆ ATTRIBUTE_WEAK

#define ATTRIBUTE_WEAK   __attribute__((weak))

◆ MCAN_MAX_TX_MSG_OBJECTS

#define MCAN_MAX_TX_MSG_OBJECTS   (32U)

Maximum number of Tx message objects that can be supported by CANFD.

◆ MCAN_MAX_RX_MSG_OBJECTS

#define MCAN_MAX_RX_MSG_OBJECTS   (32U)

Maximum number of Rx message objects that can be supported by CANFD.

◆ MCAN_MAX_MSG_OBJECTS

#define MCAN_MAX_MSG_OBJECTS   (MCAN_MAX_TX_MSG_OBJECTS + MCAN_MAX_RX_MSG_OBJECTS)

Maximum number of message objects that can be supported by CANFD.

◆ MCAN_MSG_RAM_STD_ELEM_SIZE

#define MCAN_MSG_RAM_STD_ELEM_SIZE   (1U)

Standard ID Filter Element Size.

◆ MCAN_MSG_RAM_EXT_ELEM_SIZE

#define MCAN_MSG_RAM_EXT_ELEM_SIZE   (2U)

Extended ID Filter Element Size.

◆ MCAN_MSG_HEADER_SIZE

#define MCAN_MSG_HEADER_SIZE   (8U)

MCAN Header size in Bytes.

◆ MCAN_MSG_RAM_TX_RX_ELEM_SIZE

#define MCAN_MSG_RAM_TX_RX_ELEM_SIZE   (18U)

Tx/Rx Element Size. 18 words = 18 * 4 = 72 bytes: 8 bytes of header and 64 bytes of data.

◆ XTD_MSGID_MASK

#define XTD_MSGID_MASK   (0x1fffffffU)

Message Identifier Masks.

◆ STD_MSGID_MASK

#define STD_MSGID_MASK   (0x7ffU)

◆ STD_MSGID_SHIFT

#define STD_MSGID_SHIFT   (18U)

◆ MCAN_MAX_PAYLOAD_BYTES

#define MCAN_MAX_PAYLOAD_BYTES   (64U)

Maximum payload supported by CAN-FD protocol in bytes.

◆ MCAN_MAX_RX_BUFFERS

#define MCAN_MAX_RX_BUFFERS   (64U)

Maximum number of Rx buffers.

◆ MCAN_MAX_TX_BUFFERS

#define MCAN_MAX_TX_BUFFERS   (32U)

Maximum number of Tx buffers.

◆ CANFD_UTILS_ARRAYSIZE

#define CANFD_UTILS_ARRAYSIZE (   x)    (sizeof(x) / sizeof(x[0]))

Macro to get the size of an array.

◆ CANFD_UTILS_GETARRAYINDEX

#define CANFD_UTILS_GETARRAYINDEX (   member,
  array 
)    (member - &array[0])

Get the index of the given element within an array.

◆ CANFD_UTILS_ARRAYISMEMBER

#define CANFD_UTILS_ARRAYISMEMBER (   member,
  array 
)
Value:
(((((uint32)member - (uint32) & array[0]) % sizeof(array[0])) == 0) \
&& (member >= &array[0]) \
&& (CANFD_UTILS_GETARRAYINDEX(member, array) < CANFD_UTILS_ARRAYSIZE(array)))

Macro to determine if a member is part of an array.

◆ MCAN_INTR_MASK

#define MCAN_INTR_MASK

◆ CANFD_DMA_TX_COMPLETION_INTERMEDIATE

#define CANFD_DMA_TX_COMPLETION_INTERMEDIATE   (1U)

completion type for Tx in dma mode - Intermediate completion

◆ CANFD_DMA_TX_COMPLETION_FINAL

#define CANFD_DMA_TX_COMPLETION_FINAL   (2U)

completion type for Tx in dma mode - Final completion

◆ CANFD_DMA_RX_COMPLETION_INTERMEDIATE

#define CANFD_DMA_RX_COMPLETION_INTERMEDIATE   (1U)

completion type for Rx in dma mode - Intermediate completion

◆ CANFD_DMA_RX_COMPLETION_FINAL

#define CANFD_DMA_RX_COMPLETION_FINAL   (2U)

completion type for Rx in dma mode - Final completion

MCAN_INTR_SRC_TRANS_CANCEL_FINISH
#define MCAN_INTR_SRC_TRANS_CANCEL_FINISH
Definition: mcan/v0/mcan.h:459
MCAN_INTR_SRC_DEDICATED_RX_BUFF_MSG
#define MCAN_INTR_SRC_DEDICATED_RX_BUFF_MSG
Definition: mcan/v0/mcan.h:477
MCAN_INTR_SRC_RX_FIFO0_MSG_LOST
#define MCAN_INTR_SRC_RX_FIFO0_MSG_LOST
Definition: mcan/v0/mcan.h:445
MCAN_INTR_SRC_PROTOCOL_ERR_DATA
#define MCAN_INTR_SRC_PROTOCOL_ERR_DATA
Definition: mcan/v0/mcan.h:495
MCAN_INTR_SRC_TRANS_COMPLETE
#define MCAN_INTR_SRC_TRANS_COMPLETE
Definition: mcan/v0/mcan.h:457
MCAN_INTR_SRC_RX_FIFO0_NEW_MSG
#define MCAN_INTR_SRC_RX_FIFO0_NEW_MSG
Definition: mcan/v0/mcan.h:439
MCAN_INTR_SRC_BUS_OFF_STATUS
#define MCAN_INTR_SRC_BUS_OFF_STATUS
Definition: mcan/v0/mcan.h:489
MCAN_INTR_SRC_PROTOCOL_ERR_ARB
#define MCAN_INTR_SRC_PROTOCOL_ERR_ARB
Definition: mcan/v0/mcan.h:493
CANFD_UTILS_GETARRAYINDEX
#define CANFD_UTILS_GETARRAYINDEX(member, array)
Get the index of the given element within an array.
Definition: canfd_lld.h:154
CANFD_UTILS_ARRAYSIZE
#define CANFD_UTILS_ARRAYSIZE(x)
Macro to get the size of an array.
Definition: canfd_lld.h:151
MCAN_INTR_SRC_RX_FIFO1_NEW_MSG
#define MCAN_INTR_SRC_RX_FIFO1_NEW_MSG
Definition: mcan/v0/mcan.h:447