AM263Px MCU+ SDK  10.01.00

Introduction

Files

file  canfd.h
 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.
 

Data Structures

struct  CANFD_MCANLoopbackCfgParams
 
struct  CANFD_MCANBitTimingParams
 
struct  CANFD_MCANTdcConfig
 
struct  CANFD_MCANGlobalFiltConfig
 
struct  CANFD_MCANMsgRAMCfgParams
 
struct  CANFD_MCANECCConfigParams
 
struct  CANFD_MCANErrCntStatus
 
struct  CANFD_MCANProtocolStatus
 
struct  CANFD_MCANECCErrForceParams
 
struct  CANFD_MCANECCErrStatus
 
union  CANFD_ErrStatusResp
 
struct  CANFD_Attrs
 
struct  CANFD_OptionTLV
 
struct  CANFD_OpenParams
 
struct  CANFD_Object
 
struct  CANFD_Config
 
struct  CANFD_DmaMsgConfig
 
struct  CANFD_DmaRxBuf
 
struct  CANFD_MessageObject
 
struct  CANFD_MCANMsgObjectStats
 
struct  CANFD_DmaConfig
 
typedef void * CANFD_Handle
 A handle that is returned from a CANFD_open() call. More...
 
uint32_t gCANFDConfigNum
 Externally defined driver configuration array size. More...
 

Return status

Return status when the API execution was successful

#define MCAN_STATUS_SUCCESS   ((int32_t)0)
 
#define MCAN_STATUS_FAILURE   ((int32_t)-1)
 Return status when the API execution was not successful due to a failure. More...
 

Transfer Mode

This determines whether the driver operates synchronously or asynchronously

In CANFD_TRANSFER_MODE_BLOCKING mode CANFD_write() blocks code execution until the transaction has completed

In CANFD_TRANSFER_MODE_CALLBACK CANFD_write() does not block code execution and instead calls a CANFD_TransferCallbackFxn callback function when the transaction has completed

#define CANFD_TRANSFER_MODE_BLOCKING   (0U)
 CANFD_write() blocks execution. This mode can only be used when called within a Task context More...
 
#define CANFD_TRANSFER_MODE_CALLBACK   (1U)
 CANFD_write() does not block code execution and will call a CANFD_TransferCallbackFxn. This mode can be used in a Task, Swi, or Hwi context More...
 

Operating Mode

Values used to determine the CANFD driver operation.

#define CANFD_OPER_MODE_POLLED   (0U)
 
#define CANFD_OPER_MODE_INTERRUPT   (1U)
 
#define CANFD_OPER_MODE_DMA   (2U)
 
#define MCAN_MSG_RAM_STD_ELEM_SIZE   (1U)
 The section has a list of all the data structures which are exposed to the application. 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_FRAME_TYPE_FD   (1U)
 MCAN Frame type FD. 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...
 
#define CANFD_MAX_DLC_MAPPING   (16U)
 Maximum data to DLC mapping supported. Refer MCAN_DataLengthSize. More...
 

CANFD Driver State

This macros defines the values used to represent the CANFD driver state

#define CANFD_DRIVER_STATE_UNINIT   (0U)
 
#define CANFD_DRIVER_STATE_STARTED   (1U)
 
#define CANFD_DRIVER_STATE_STOPPED   (2U)
 
#define CCANFD_DRIVER_STATE_SLEEP   (3U)
 

CANFD Element Size

This enumeration defines the MCAN FIFO/Buffer element Size

enum  CANFD_MCANElemSize {
  CANFD_MCANElemSize_8BYTES = 0U, CANFD_MCANElemSize_12BYTES = 1U, CANFD_MCANElemSize_16BYTES = 2U, CANFD_MCANElemSize_20BYTES = 3U,
  CANFD_MCANElemSize_24BYTES = 4U, CANFD_MCANElemSize_32BYTES = 5U, CANFD_MCANElemSize_48BYTES = 6U, CANFD_MCANElemSize_64BYTES = 7U
}
 

CANFD Operation Mode

Enumerates the values used to represent the MCAN mode of operation

enum  CANFD_MCANOperationMode { CANFD_MCANOperationMode_NORMAL = 0U, CANFD_MCANOperationMode_SW_INIT = 1U }
 

CANFD Direction

This enumeration defines the values used to set the direction of message object

enum  CANFD_Direction { CANFD_Direction_RX, CANFD_Direction_TX }
 

CANFD Identifier Type

This enumeration defines the values used to represent the CAN Identifier Type

enum  CANFD_MCANXidType { CANFD_MCANXidType_11_BIT, CANFD_MCANXidType_29_BIT }
 

CANFD Frame Type

This enumeration defines the CAN frame type

enum  CANFD_MCANFrameType { CANFD_MCANFrameType_CLASSIC, CANFD_MCANFrameType_FD }
 

CANFD Time out select

This enumeration defines the MCAN timeout counter configuration

enum  CANFD_MCANTimeOutSelect { CANFD_MCANTimeOutSelect_CONT = 0U, CANFD_MCANTimeOutSelect_TX_EVENT_FIFO = 1U, CANFD_MCANTimeOutSelect_RX_FIFO0 = 2U, CANFD_MCANTimeOutSelect_RX_FIFO1 = 3U }
 

CANFD ECC error type

typedef uint32_t CANFD_MCANECCErrType
 This enumeration defines the MCAN ECC Error Types. More...
 
#define CANFD_MCAN_ECC_ERR_TYPE_SEC   (0U)
 
#define CANFD_MCAN_ECC_ERR_TYPE_DED   (1U)
 

CANFD Loopback mode

This enumeration defines the MCAN Loopback mode

enum  CANFD_MCANLoopBackMode { CANFD_MCANLoopBackMode_INTERNAL = 0U, CANFD_MCANLoopBackMode_EXTERNAL = 1U }
 

CANFD Communication State

This enumeration defines the MCAN's communication state

enum  CANFD_MCANCommState { CANFD_MCANCommState_SYNCHRONIZING = 0U, CANFD_MCANCommState_IDLE = 1U, CANFD_MCANCommState_RECEIVER = 2U, CANFD_MCANCommState_TRANSMITTER = 3U }
 

CANFD Error Code

This enumeration defines the MCAN's Error Code

enum  CANFD_MCANErrCode {
  CANFD_MCANErrCode_NO_ERROR = 0U, CANFD_MCANErrCode_STUFF_ERROR = 1U, CANFD_MCANErrCode_FORM_ERROR = 2U, CANFD_MCANErrCode_ACK_ERROR = 3U,
  CANFD_MCANErrCode_BIT1_ERROR = 4U, CANFD_MCANErrCode_BIT0_ERROR = 5U, CANFD_MCANErrCode_CRC_ERROR = 6U, CANFD_MCANErrCode_NO_CHANGE = 7U
}
 

CANFD reason

This enumeration describes a list of all the reasons for which the driver will invoke application callback functions.

enum  CANFD_Reason {
  CANFD_Reason_RX = 0x1, CANFD_Reason_TX_COMPLETION = 0x2, CANFD_Reason_TX_CANCELED = 0x3, CANFD_Reason_ECC_ERROR = 0x4,
  CANFD_Reason_BUSOFF = 0x5, CANFD_Reason_PROTOCOL_ERR_DATA_PHASE = 0x6, CANFD_Reason_PROTOCOL_ERR_ARB_PHASE = 0x7
}
 

CANFD Option

This enumeration defines the values used to represent the GET/SET options

See also
CANFD_OptionTLV
enum  CANFD_Option {
  CANFD_Option_MCAN_ERROR_COUNTER, CANFD_Option_MCAN_PROTOCOL_STATUS, CANFD_Option_MCAN_MSG_OBJECT_STATS, CANFD_Option_MCAN_MODE,
  CANFD_Option_MCAN_LOOPBACK, CANFD_Option_MCAN_POWER_DOWN
}
 
typedef void * CANFD_DmaHandle
 
typedef void * CANFD_DmaChConfig
 

CANFD Option TLV

Options TLV data structure

Specifies the option type, length, value.

typedef void(* CANFD_TransferCallbackFxn) (void *args, CANFD_Reason reason)
 The definition of a callback function used by the CANFD driver when used in CANFD_TRANSFER_MODE_CALLBACK. More...
 
typedef void(* CANFD_ErrorCallbackFxn) (void *args, CANFD_Reason reason, CANFD_ErrStatusResp *errStatusResp)
 The definition of a callback function used by the CANFD driver when used in CANFD_TRANSFER_MODE_CALLBACK in case of error. More...
 

CANFD Message Handle

CANFD message object handle returned by the CANFD_createMsgObject() API call.

typedef CANFD_MessageObjectCANFD_MsgObjHandle
 

CANFD Dma Config

CANFD DMA Configuration, these are filled by SysCfg based on the DMA driver(EDMA/UDMA) that is selected

void CANFD_init (void)
 This function initializes each driver instance object and create a driver lock. More...
 
void CANFD_deinit (void)
 This function de-initializes each driver instance object and delete a driver lock. More...
 
CANFD_Handle CANFD_open (uint32_t index, CANFD_OpenParams *openPrms)
 This function opens a given CANFD peripheral. More...
 
void CANFD_close (CANFD_Handle handle)
 Function to close a CANFD peripheral specified by the CANFD handle. More...
 
int32_t CANFD_configBitTime (CANFD_Handle handle, const CANFD_MCANBitTimingParams *bitTimeParams)
 Function configures the bit time parameters for the CANFD module. More...
 
int32_t CANFD_createMsgObject (CANFD_Handle handle, CANFD_MessageObject *ptrCanMsgObj)
 Function configures the receive or transmit message object. It also enables Tx completion and Tx cancelation interrupts . The callback function will be invoked on data transmit complete for transmit message objects OR upon receiving data for receive message objects. The application MUST then call CANFD_read() API to process the received data. More...
 
int32_t CANFD_createRxRangeMsgObject (CANFD_Handle handle, CANFD_MessageObject *ptrCanMsgObj)
 Function configures a receive message objects for a range of message identifiers. It also enables Rx interrupts. The callback function will be invoked upon receiving data for receive message objects. The application MUST then call CANFD_read() API to process the received data. More...
 
int32_t CANFD_deleteMsgObject (CANFD_MsgObjHandle handle)
 Function deletes a message object. More...
 
int32_t CANFD_write (CANFD_MsgObjHandle handle, uint32_t id, CANFD_MCANFrameType frameType, uint32_t numMsgs, const uint8_t *data)
 Function used by the application to transmit data. More...
 
int32_t CANFD_writeCancel (CANFD_MsgObjHandle handle)
 Function used by the application to cancel a pending data transmit. More...
 
int32_t CANFD_writeDma (CANFD_MsgObjHandle handle, uint32_t id, CANFD_MCANFrameType frameType, uint32_t numMsgs, const void *data)
 Function used by the application to initiate transmit data in dma mode. DMA mode is recommended to be used when multiple msgs needs to be transmitted. This will transmit first msg and configure the dma to copy subsequent msgs in message ram. Once first msg transfer is completed the CANFD_dmaTxCompletionCallback function is called. Application needs to call the API CANFD_writeDmaTriggerNext to trigger transmission of subsequent msgs. More...
 
int32_t CANFD_writeDmaTriggerNext (CANFD_MsgObjHandle handle)
 Function used by the application to start transmission of next msg in dma mode. Transfer should be initiated using the API CANFD_writeDma before calling this function. This should be called after the previous transfer is completed and CANFD_dmaTxCompletionCallback is called. More...
 
uint32_t CANFD_getFilterEventConfig (uint32_t eventNum)
 
int32_t CANFD_read (CANFD_MsgObjHandle handle, uint32_t numMsgs, uint8_t *data)
 Function is used by the application to get the CAN message from message RAM using a receive message object. More...
 
int32_t CANFD_readDmaConfig (CANFD_MsgObjHandle handle, const void *data, uint32_t numMsgs)
 Function is used by the application to configure reading the received msgs from message ram. This API will configure the DMA to copy msg from MCAN message ram to application buffer. For every message received the CANFD_dmaRxCompletionCallback will be called by driver by pointing to the latest msg in the data buffer. More...
 
int32_t CANFD_getOptions (CANFD_Handle handle, const CANFD_OptionTLV *ptrOptInfo)
 Function is used by the application to get the error and status information from the driver. More...
 
int32_t CANFD_setOptions (CANFD_Handle handle, const CANFD_OptionTLV *ptrOptInfo)
 Function is used by the application to configure the driver options. More...
 
void CANFD_int0Isr (void *args)
 The function is the registered interrupt 0 ISR for the CANFD Driver. More...
 
void CANFD_int1Isr (void *args)
 The function is the registered interrupt 1 ISR for the CANFD Driver. More...
 
void CANFD_transferCallBack (void *args, CANFD_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...
 
void CANFD_errStatusCallBack (CANFD_Handle handle, CANFD_Reason reason, CANFD_ErrStatusResp *errStatusResp)
 Application specified callback function which is invoked by the CANFD driver on error or status change. More...
 
int32_t CANFD_dmaOpen (CANFD_Handle canfdHandle, CANFD_DmaChConfig dmaChCfg)
 API to open an CANFD DMA channel. More...
 
int32_t CANFD_dmaClose (CANFD_Handle canfdHandle)
 API to close an CANFD DMA channel. More...
 
int32_t CANFD_createDmaTxMsgObject (const CANFD_Object *ptrCanFdObj, CANFD_MessageObject *ptrCanMsgObj)
 API to configure dma for the Tx message object. Called from the API CANFD_createMsgObject. More...
 
int32_t CANFD_deleteDmaTxMsgObject (const CANFD_Object *ptrCanFdObj, const CANFD_MessageObject *ptrCanMsgObj)
 API to delete dma configuration for the Tx message object. Called from the API CANFD_deleteMsgObject. More...
 
int32_t CANFD_configureDmaTx (const CANFD_Object *ptrCanFdObj, CANFD_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_writeDma. More...
 
int32_t CANFD_cancelDmaTx (const CANFD_Object *ptrCanFdObj, const CANFD_MessageObject *ptrCanMsgObj)
 API to disbale dma event transfer for the Tx to cancel the transfer. More...
 
void CANFD_dmaTxCompletionCallback (CANFD_MessageObject *ptrCanMsgObj, const 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_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_createDmaRxMsgObject (const CANFD_Object *ptrCanFdObj, CANFD_MessageObject *ptrCanMsgObj)
 API to configure dma for the Rx message object. Called from the CANFD_createMsgObject. More...
 
int32_t CANFD_deleteDmaRxMsgObject (const CANFD_Object *ptrCanFdObj, const CANFD_MessageObject *ptrCanMsgObj)
 API to delete dma configuration for the Rx message object. Called from the CANFD_deleteMsgObject. More...
 
int32_t CANFD_configureDmaRx (const CANFD_Object *ptrCanFdObj, CANFD_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_readDma. More...
 
void CANFD_dmaRxCompletionCallback (CANFD_MessageObject *ptrCanMsgObj, const 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_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...
 
int32_t CANFD_isDataSizeValid (uint32_t dataSize)
 Function to verify the the data Size is valid or not. More...
 

Macro Definition Documentation

◆ MCAN_STATUS_SUCCESS

#define MCAN_STATUS_SUCCESS   ((int32_t)0)

◆ MCAN_STATUS_FAILURE

#define MCAN_STATUS_FAILURE   ((int32_t)-1)

Return status when the API execution was not successful due to a failure.

◆ CANFD_TRANSFER_MODE_BLOCKING

#define CANFD_TRANSFER_MODE_BLOCKING   (0U)

CANFD_write() blocks execution. This mode can only be used when called within a Task context

◆ CANFD_TRANSFER_MODE_CALLBACK

#define CANFD_TRANSFER_MODE_CALLBACK   (1U)

CANFD_write() does not block code execution and will call a CANFD_TransferCallbackFxn. This mode can be used in a Task, Swi, or Hwi context

◆ CANFD_OPER_MODE_POLLED

#define CANFD_OPER_MODE_POLLED   (0U)

◆ CANFD_OPER_MODE_INTERRUPT

#define CANFD_OPER_MODE_INTERRUPT   (1U)

◆ CANFD_OPER_MODE_DMA

#define CANFD_OPER_MODE_DMA   (2U)

◆ MCAN_MSG_RAM_STD_ELEM_SIZE

#define MCAN_MSG_RAM_STD_ELEM_SIZE   (1U)

The section has a list of all the data structures which are exposed to the application.

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_FRAME_TYPE_FD

#define MCAN_FRAME_TYPE_FD   (1U)

MCAN Frame type FD.

◆ 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

◆ CANFD_MAX_DLC_MAPPING

#define CANFD_MAX_DLC_MAPPING   (16U)

Maximum data to DLC mapping supported. Refer MCAN_DataLengthSize.

◆ CANFD_DRIVER_STATE_UNINIT

#define CANFD_DRIVER_STATE_UNINIT   (0U)

CANFD controller not initialized

◆ CANFD_DRIVER_STATE_STARTED

#define CANFD_DRIVER_STATE_STARTED   (1U)

CANFD controller started

◆ CANFD_DRIVER_STATE_STOPPED

#define CANFD_DRIVER_STATE_STOPPED   (2U)

CANFD controller stopped

◆ CCANFD_DRIVER_STATE_SLEEP

#define CCANFD_DRIVER_STATE_SLEEP   (3U)

CANFD controller in sleep mode

◆ CANFD_MCAN_ECC_ERR_TYPE_SEC

#define CANFD_MCAN_ECC_ERR_TYPE_SEC   (0U)

ECC Single Error Correction

◆ CANFD_MCAN_ECC_ERR_TYPE_DED

#define CANFD_MCAN_ECC_ERR_TYPE_DED   (1U)

ECC Single Error Detection

Typedef Documentation

◆ CANFD_Handle

typedef void* CANFD_Handle

A handle that is returned from a CANFD_open() call.

◆ CANFD_MCANECCErrType

typedef uint32_t CANFD_MCANECCErrType

This enumeration defines the MCAN ECC Error Types.

◆ CANFD_DmaHandle

typedef void* CANFD_DmaHandle

◆ CANFD_DmaChConfig

typedef void* CANFD_DmaChConfig

◆ CANFD_TransferCallbackFxn

typedef void(* CANFD_TransferCallbackFxn) (void *args, CANFD_Reason reason)

The definition of a callback function used by the CANFD driver when used in CANFD_TRANSFER_MODE_CALLBACK.

Parameters
void*void pointer
reasonCause of the interrupt which prompted the callback.

◆ CANFD_ErrorCallbackFxn

typedef void(* CANFD_ErrorCallbackFxn) (void *args, CANFD_Reason reason, CANFD_ErrStatusResp *errStatusResp)

The definition of a callback function used by the CANFD driver when used in CANFD_TRANSFER_MODE_CALLBACK in case of error.

Parameters
void*void pointer
reasonCause of the interrupt which prompted the callback.

◆ CANFD_MsgObjHandle

Enumeration Type Documentation

◆ CANFD_MCANElemSize

Enumerator
CANFD_MCANElemSize_8BYTES 

8 byte data field

CANFD_MCANElemSize_12BYTES 

12 byte data field

CANFD_MCANElemSize_16BYTES 

16 byte data field

CANFD_MCANElemSize_20BYTES 

20 byte data field

CANFD_MCANElemSize_24BYTES 

24 byte data field

CANFD_MCANElemSize_32BYTES 

32 byte data field

CANFD_MCANElemSize_48BYTES 

48 byte data field

CANFD_MCANElemSize_64BYTES 

64 byte data field

◆ CANFD_MCANOperationMode

Enumerator
CANFD_MCANOperationMode_NORMAL 

MCAN normal mode

CANFD_MCANOperationMode_SW_INIT 

MCAN SW initialization mode

◆ CANFD_Direction

Enumerator
CANFD_Direction_RX 

Message object used to receive data

CANFD_Direction_TX 

Message object used to transmit data

◆ CANFD_MCANXidType

Enumerator
CANFD_MCANXidType_11_BIT 

11bit MCAN Identifier

CANFD_MCANXidType_29_BIT 

29bit MCAN Identifier

◆ CANFD_MCANFrameType

Enumerator
CANFD_MCANFrameType_CLASSIC 

Classic Frame

CANFD_MCANFrameType_FD 

FD Frame

◆ CANFD_MCANTimeOutSelect

Enumerator
CANFD_MCANTimeOutSelect_CONT 

Continuous operation Mode

CANFD_MCANTimeOutSelect_TX_EVENT_FIFO 

Timeout controlled by Tx Event FIFO

CANFD_MCANTimeOutSelect_RX_FIFO0 

Timeout controlled by Rx FIFO 0

CANFD_MCANTimeOutSelect_RX_FIFO1 

Timeout controlled by Rx FIFO 1

◆ CANFD_MCANLoopBackMode

Enumerator
CANFD_MCANLoopBackMode_INTERNAL 

This mode can be used for hot self-test and this mode will not affect bus state.

CANFD_MCANLoopBackMode_EXTERNAL 

In this mode, MCAN the MCAN treats its own transmitted messages as received messages and stores them (if they pass acceptance filtering) into an Rx Buffer or an Rx FIFO. This mode will affect bus state.

◆ CANFD_MCANCommState

Enumerator
CANFD_MCANCommState_SYNCHRONIZING 

MCAN is synchronizing on CANFD communication

CANFD_MCANCommState_IDLE 

MCAN is neither receiver nor transmitter

CANFD_MCANCommState_RECEIVER 

MCAN is operating as receiver

CANFD_MCANCommState_TRANSMITTER 

MCAN is operating as transmitter

◆ CANFD_MCANErrCode

Enumerator
CANFD_MCANErrCode_NO_ERROR 

No error occurred since LEC has been reset by successful reception or transmission.

CANFD_MCANErrCode_STUFF_ERROR 

More than 5 equal bits in a sequence have occurred in a part of a received message where this is not allowed.

CANFD_MCANErrCode_FORM_ERROR 

A fixed format part of a received frame has the wrong format.

CANFD_MCANErrCode_ACK_ERROR 

The message transmitted by the MCAN was not acknowledged by another node.

CANFD_MCANErrCode_BIT1_ERROR 

During the transmission of a message (with the exception of the arbitration field), the device wanted to send a recessive level (bit of logical value 1), but the monitored bus value was dominant.

CANFD_MCANErrCode_BIT0_ERROR 

During the transmission of a message (or acknowledge bit, or active error flag, or overload flag), the device wanted to send a dominant level (data or identifier bit logical value 0), but the monitored bus value was recessive. During Bus_Off recovery this status is set each time a sequence of 11 recessive bits has been monitored. This enables the CPU to monitor the proceeding of the Bus_Off recovery sequence (indicating the bus is not stuck at dominant or continuously disturbed).

CANFD_MCANErrCode_CRC_ERROR 

The CRC check sum of a received message was incorrect. The CRC of an incoming message does not match with the CRC calculated from the received data.

CANFD_MCANErrCode_NO_CHANGE 

Any read access to the Protocol Status Register re-initializes the LEC to 7. When the LEC shows the value 7, no CANFD bus event was detected since the last CPU read access to the Protocol Status Register.

◆ CANFD_Reason

Enumerator
CANFD_Reason_RX 

Data has been received and the application is required to read and process the data.

CANFD_Reason_TX_COMPLETION 

Data has been succesfully transmitted.

CANFD_Reason_TX_CANCELED 

Data transmission is succesfully canceled.

CANFD_Reason_ECC_ERROR 

Data has been succesfully transmitted.

CANFD_Reason_BUSOFF 

Bus Off condition detected.

CANFD_Reason_PROTOCOL_ERR_DATA_PHASE 

Protocol error in data phase detected.

CANFD_Reason_PROTOCOL_ERR_ARB_PHASE 

Protocol error in arbitration phase detected.

◆ CANFD_Option

Enumerator
CANFD_Option_MCAN_ERROR_COUNTER 

Used to get the MCAN Tx and Rx error counters

See also
CANFD_getOptions

NOTE: The length in the TLV should be sizeof(CANFD_MCANErrCntStatus) for this option.

CANFD_Option_MCAN_PROTOCOL_STATUS 

Used to get the MCAN protocol status

See also
CANFD_getOptions

NOTE: The length in the TLV should be sizeof(CANFD_MCANProtocolStatus) for this option.

CANFD_Option_MCAN_MSG_OBJECT_STATS 

Used to get the MCAN message object software maintained statistics

See also
CANFD_getOptions

NOTE: The length in the TLV should be sizeof(CANFD_MCANMsgObjectStats) for this option. Application must fill in the message object handle for which the statistics is requested.

CANFD_Option_MCAN_MODE 

Used to put the MCAN module in init or operational state

See also
CANFD_setOptions

NOTE: The length in the TLV should be 1 byte for this option. Valid values: Refer to (CANFD_MCANOperationMode)

CANFD_Option_MCAN_LOOPBACK 

Used to enable or disable internal/external loopback mode

See also
CANFD_setOptions

NOTE: The length in the TLV should be sizeof(CANFD_MCANLoopbackCfgParams) for this option.

CANFD_Option_MCAN_POWER_DOWN 

Used to request a local power down or wakeup from a local power down

See also
CANFD_setOptions

NOTE: The length in the TLV should be 1 byte for this option. Valid values are 1 - MCAN Sleep 0 - MCAN Wakeup

Function Documentation

◆ CANFD_init()

void CANFD_init ( void  )

This function initializes each driver instance object and create a driver lock.

◆ CANFD_deinit()

void CANFD_deinit ( void  )

This function de-initializes each driver instance object and delete a driver lock.

◆ CANFD_open()

CANFD_Handle CANFD_open ( uint32_t  index,
CANFD_OpenParams openPrms 
)

This function opens a given CANFD peripheral.

Precondition
CANFD has been initialized using CANFD_init()
Parameters
indexIndex of config to use in the CANFD_Config array
openPrmsPointer to open parameters. If NULL is passed, then default values will be used
Returns
A CANFD_Handle on success or a NULL on an error or if it has been opened already

◆ CANFD_close()

void CANFD_close ( CANFD_Handle  handle)

Function to close a CANFD peripheral specified by the CANFD handle.

Precondition
CANFD_open() has to be called first
Parameters
handleCANFD_Handle returned from CANFD_open()

◆ CANFD_configBitTime()

int32_t CANFD_configBitTime ( CANFD_Handle  handle,
const CANFD_MCANBitTimingParams bitTimeParams 
)

Function configures the bit time parameters for the CANFD module.

Parameters
handleHandle to the CANFD Driver
bitTimeParamsBit time configuration parameters
Returns
SystemP_SUCCESS on success, else failure

◆ CANFD_createMsgObject()

int32_t CANFD_createMsgObject ( CANFD_Handle  handle,
CANFD_MessageObject ptrCanMsgObj 
)

Function configures the receive or transmit message object. It also enables Tx completion and Tx cancelation interrupts . The callback function will be invoked on data transmit complete for transmit message objects OR upon receiving data for receive message objects. The application MUST then call CANFD_read() API to process the received data.

Parameters
handleHandle to the CANFD Driver
ptrCanMsgObjPointer to Message Object configuration parameters
Returns
Success - Handle to the message object.
Error - NULL

◆ CANFD_createRxRangeMsgObject()

int32_t CANFD_createRxRangeMsgObject ( CANFD_Handle  handle,
CANFD_MessageObject ptrCanMsgObj 
)

Function configures a receive message objects for a range of message identifiers. It also enables Rx interrupts. The callback function will be invoked upon receiving data for receive message objects. The application MUST then call CANFD_read() API to process the received data.

Parameters
handleHandle to the CANFD Driver
ptrCanMsgObjPointer to Message Object configuration parameters
Returns
Success - Handle to the message object.
Error - NULL

◆ CANFD_deleteMsgObject()

int32_t CANFD_deleteMsgObject ( CANFD_MsgObjHandle  handle)

Function deletes a message object.

Parameters
handleHandle to the message object
Returns
SystemP_SUCCESS on success, else failure

◆ CANFD_write()

int32_t CANFD_write ( CANFD_MsgObjHandle  handle,
uint32_t  id,
CANFD_MCANFrameType  frameType,
uint32_t  numMsgs,
const uint8_t *  data 
)

Function used by the application to transmit data.

Parameters
handleHandle to the message object
idMessage Identifier
frameTypeFrame type - Classic or FD
numMsgsNumber of msgs to be transmitted Only applicale in DMA Mode.
dataData to be transmitted
Returns
SystemP_SUCCESS on success, else failure

◆ CANFD_writeCancel()

int32_t CANFD_writeCancel ( CANFD_MsgObjHandle  handle)

Function used by the application to cancel a pending data transmit.

Parameters
handleHandle to the message object
Returns
SystemP_SUCCESS on success, else failure

◆ CANFD_writeDma()

int32_t CANFD_writeDma ( CANFD_MsgObjHandle  handle,
uint32_t  id,
CANFD_MCANFrameType  frameType,
uint32_t  numMsgs,
const void *  data 
)

Function used by the application to initiate transmit data in dma mode. DMA mode is recommended to be used when multiple msgs needs to be transmitted. This will transmit first msg and configure the dma to copy subsequent msgs in message ram. Once first msg transfer is completed the CANFD_dmaTxCompletionCallback function is called. Application needs to call the API CANFD_writeDmaTriggerNext to trigger transmission of subsequent msgs.

Parameters
handleHandle to the message object
idMessage Identifier
frameTypeFrame type - Classic or FD
numMsgsNumber of msgs to be transmitted
dataData to be transmitted. This should be a 2d array of uint8[numMsgs][dataLengthPerMsg]
Returns
SystemP_SUCCESS on success, else failure

◆ CANFD_writeDmaTriggerNext()

int32_t CANFD_writeDmaTriggerNext ( CANFD_MsgObjHandle  handle)

Function used by the application to start transmission of next msg in dma mode. Transfer should be initiated using the API CANFD_writeDma before calling this function. This should be called after the previous transfer is completed and CANFD_dmaTxCompletionCallback is called.

Parameters
handleHandle to the message object
Returns
SystemP_SUCCESS on success, else failure

◆ CANFD_getFilterEventConfig()

uint32_t CANFD_getFilterEventConfig ( uint32_t  eventNum)

◆ CANFD_read()

int32_t CANFD_read ( CANFD_MsgObjHandle  handle,
uint32_t  numMsgs,
uint8_t *  data 
)

Function is used by the application to get the CAN message from message RAM using a receive message object.

Parameters
handleHandle to the message object
numMsgsNumber of message count. Applicale only for DMA Mode, for other modes, provide 0.
dataReceived data.
Returns
SystemP_SUCCESS on success, else failure

◆ CANFD_readDmaConfig()

int32_t CANFD_readDmaConfig ( CANFD_MsgObjHandle  handle,
const void *  data,
uint32_t  numMsgs 
)

Function is used by the application to configure reading the received msgs from message ram. This API will configure the DMA to copy msg from MCAN message ram to application buffer. For every message received the CANFD_dmaRxCompletionCallback will be called by driver by pointing to the latest msg in the data buffer.

Parameters
handleHandle to the message object
dataArray of CANFD_DmaRxBuf to receive the data from message ram. This should be an array of type CANFD_DmaRxBuf and length numDmaRxBuf
numMsgs
Number of messages to transmit
Returns
SystemP_SUCCESS on success, else failure

◆ CANFD_getOptions()

int32_t CANFD_getOptions ( CANFD_Handle  handle,
const CANFD_OptionTLV ptrOptInfo 
)

Function is used by the application to get the error and status information from the driver.

Parameters
handleHandle to the CANFD Driver
ptrOptInfoOption info in TLV format which is populated with the requested information
Returns
SystemP_SUCCESS on success, else failure

◆ CANFD_setOptions()

int32_t CANFD_setOptions ( CANFD_Handle  handle,
const CANFD_OptionTLV ptrOptInfo 
)

Function is used by the application to configure the driver options.

Parameters
handleHandle to the CANFD Driver
ptrOptInfoOption info in TLV format which is used to configure the driver
Returns
SystemP_SUCCESS on success, else failure

◆ CANFD_int0Isr()

void CANFD_int0Isr ( void *  args)

The function is the registered interrupt 0 ISR for the CANFD Driver.

◆ CANFD_int1Isr()

void CANFD_int1Isr ( void *  args)

The function is the registered interrupt 1 ISR for the CANFD Driver.

◆ CANFD_transferCallBack()

void CANFD_transferCallBack ( void *  args,
CANFD_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.

Parameters
argsvoid pointer basically Message object handle for which the callback function is invoked.
reasonCause of the interrupt which prompted the callback.

◆ CANFD_errStatusCallBack()

void CANFD_errStatusCallBack ( CANFD_Handle  handle,
CANFD_Reason  reason,
CANFD_ErrStatusResp errStatusResp 
)

Application specified callback function which is invoked by the CANFD driver on error or status change.

Parameters
handleHandle to the CANFD Driver
reasonCause of the interrupt which prompted the callback.
errStatusRespResponse structure populated with the value of the fields that caused the error or status interrupt. Processing of this structure is dependent on the callback reason.

◆ CANFD_dmaOpen()

int32_t CANFD_dmaOpen ( CANFD_Handle  canfdHandle,
CANFD_DmaChConfig  dmaChCfg 
)

API to open an CANFD DMA channel.

This API will open a DMA Channel using the appropriate DMA driver callbacks and the registered via Sysconfig

Parameters
canfdHandleCANFD Handle
dmaChCfgCANFD Channel config
Returns
SystemP_SUCCESS on success, else failure

◆ CANFD_dmaClose()

int32_t CANFD_dmaClose ( CANFD_Handle  canfdHandle)

API to close an CANFD DMA channel.

Parameters
canfdHandleCANFD handle returned from CANFD_open
Returns
SystemP_SUCCESS on success, else failure

◆ CANFD_createDmaTxMsgObject()

int32_t CANFD_createDmaTxMsgObject ( const CANFD_Object ptrCanFdObj,
CANFD_MessageObject ptrCanMsgObj 
)

API to configure dma for the Tx message object. Called from the API CANFD_createMsgObject.

Parameters
ptrCanFdObjpointer to the CANFD driver object
ptrCanMsgObjpointer to the CANFD message object
Returns
SystemP_SUCCESS on success, else failure

◆ CANFD_deleteDmaTxMsgObject()

int32_t CANFD_deleteDmaTxMsgObject ( const CANFD_Object ptrCanFdObj,
const CANFD_MessageObject ptrCanMsgObj 
)

API to delete dma configuration for the Tx message object. Called from the API CANFD_deleteMsgObject.

Parameters
ptrCanFdObjpointer to the CANFD driver object
ptrCanMsgObjpointer to the CANFD message object
Returns
SystemP_SUCCESS on success, else failure

◆ CANFD_configureDmaTx()

int32_t CANFD_configureDmaTx ( const CANFD_Object ptrCanFdObj,
CANFD_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_writeDma.

Parameters
ptrCanFdObjpointer to the CANFD driver object
ptrCanMsgObjpointer to the CANFD message object
dataLengthPerMsgdata length in bytes for each message
numMsgsNumber f messages to transmit
datapointer to the data buffer to transmit
Returns
SystemP_SUCCESS on success, else failure

◆ CANFD_cancelDmaTx()

int32_t CANFD_cancelDmaTx ( const CANFD_Object ptrCanFdObj,
const CANFD_MessageObject ptrCanMsgObj 
)

API to disbale dma event transfer for the Tx to cancel the transfer.

Parameters
ptrCanFdObjpointer to the CANFD driver object
ptrCanMsgObjpointer to the CANFD message object
Returns
SystemP_SUCCESS on success, else failure

◆ CANFD_dmaTxCompletionCallback()

void CANFD_dmaTxCompletionCallback ( CANFD_MessageObject ptrCanMsgObj,
const 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_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.

Parameters
ptrCanMsgObjpointer to the CANFD message object
datapointer to current completed message
completionTypespecifie completion type for the callback

◆ CANFD_createDmaRxMsgObject()

int32_t CANFD_createDmaRxMsgObject ( const CANFD_Object ptrCanFdObj,
CANFD_MessageObject ptrCanMsgObj 
)

API to configure dma for the Rx message object. Called from the CANFD_createMsgObject.

Parameters
ptrCanFdObjpointer to the CANFD driver object
ptrCanMsgObjpointer to the CANFD message object
Returns
SystemP_SUCCESS on success, else failure

◆ CANFD_deleteDmaRxMsgObject()

int32_t CANFD_deleteDmaRxMsgObject ( const CANFD_Object ptrCanFdObj,
const CANFD_MessageObject ptrCanMsgObj 
)

API to delete dma configuration for the Rx message object. Called from the CANFD_deleteMsgObject.

Parameters
ptrCanFdObjpointer to the CANFD driver object
ptrCanMsgObjpointer to the CANFD message object
Returns
SystemP_SUCCESS on success, else failure

◆ CANFD_configureDmaRx()

int32_t CANFD_configureDmaRx ( const CANFD_Object ptrCanFdObj,
CANFD_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_readDma.

Parameters
ptrCanFdObjpointer to the CANFD driver object
ptrCanMsgObjpointer to the CANFD message object
dataLengthPerMsgdata length in bytes for each message
numMsgsNumber f messages to transmit
datapointer to the data buffer to transmit

◆ CANFD_dmaRxCompletionCallback()

void CANFD_dmaRxCompletionCallback ( CANFD_MessageObject ptrCanMsgObj,
const 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_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.

Parameters
ptrCanMsgObjpointer to the CANFD message object
datapointer to current recieved message
completionTypespecifie completion type for the callback

◆ CANFD_isDataSizeValid()

int32_t CANFD_isDataSizeValid ( uint32_t  dataSize)

Function to verify the the data Size is valid or not.

Parameters
dataSizeCANFD data Size
Returns
SystemP_SUCCESS on success, else failure

Variable Documentation

◆ gCANFDConfigNum

uint32_t gCANFDConfigNum
extern

Externally defined driver configuration array size.

MCAN_INTR_SRC_TRANS_CANCEL_FINISH
#define MCAN_INTR_SRC_TRANS_CANCEL_FINISH
Definition: mcan.h:569
MCAN_INTR_SRC_DEDICATED_RX_BUFF_MSG
#define MCAN_INTR_SRC_DEDICATED_RX_BUFF_MSG
Definition: mcan.h:587
CANFD_UTILS_GETARRAYINDEX
#define CANFD_UTILS_GETARRAYINDEX(member, array)
Get the index of the given element within an array.
Definition: canfd.h:205
MCAN_INTR_SRC_RX_FIFO0_MSG_LOST
#define MCAN_INTR_SRC_RX_FIFO0_MSG_LOST
Definition: mcan.h:555
CANFD_UTILS_ARRAYSIZE
#define CANFD_UTILS_ARRAYSIZE(x)
Macro to get the size of an array.
Definition: canfd.h:202
MCAN_INTR_SRC_PROTOCOL_ERR_DATA
#define MCAN_INTR_SRC_PROTOCOL_ERR_DATA
Definition: mcan.h:605
MCAN_INTR_SRC_TRANS_COMPLETE
#define MCAN_INTR_SRC_TRANS_COMPLETE
Definition: mcan.h:567
MCAN_INTR_SRC_RX_FIFO0_NEW_MSG
#define MCAN_INTR_SRC_RX_FIFO0_NEW_MSG
Definition: mcan.h:549
MCAN_INTR_SRC_BUS_OFF_STATUS
#define MCAN_INTR_SRC_BUS_OFF_STATUS
Definition: mcan.h:599
MCAN_INTR_SRC_PROTOCOL_ERR_ARB
#define MCAN_INTR_SRC_PROTOCOL_ERR_ARB
Definition: mcan.h:603
MCAN_INTR_SRC_RX_FIFO1_NEW_MSG
#define MCAN_INTR_SRC_RX_FIFO1_NEW_MSG
Definition: mcan.h:557