Data Structures | Macros | Functions
MCAN.h File Reference

Detailed Description

Hardware abstraction layer for M_CAN Controller v3.2.1.


#include <stdint.h>
#include <stddef.h>
#include <third_party/mcan/inc/MCAN_reg.h>
Include dependency graph for MCAN.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  MCAN_TDCConfig
 Structure for MCAN Transmitter Delay Compensation parameters. More...
 
struct  MCAN_BitTimingParams
 Structure for bit timing parameters. More...
 
struct  MCAN_GlobalFiltConfig
 Structure for MCAN Global Filter Configuration parameters. More...
 
struct  MCAN_InitParams
 Structure for MCAN initialization parameters. More...
 
struct  MCAN_ConfigParams
 Structure for MCAN configuration parameters. More...
 
struct  MCAN_ErrCntStatus
 Structure for MCAN error logging counters status. More...
 
struct  MCAN_ProtocolStatus
 Structure for MCAN protocol status. More...
 
struct  MCAN_MsgRamConfig
 Structure for MCAN Message RAM Configuration Parameters. More...
 
struct  MCAN_HighPriorityMsgInfo
 Structure for MCAN High Priority Message. More...
 
struct  MCAN_RxNewDataStatus
 Structure for MCAN new data flag for Rx buffer. More...
 
struct  MCAN_RxFifoStatus
 Structure for MCAN Rx FIFO Status. More...
 
struct  MCAN_TxFifoQStatus
 Structure for MCAN Tx FIFO/Queue Status. More...
 
struct  MCAN_TxEventFifoStatus
 Structure for MCAN Tx Event FIFO Status. More...
 
struct  MCAN_TxBufElement
 Structure for MCAN Tx Buffer element. More...
 
struct  MCAN_TxBufElementNoCpy
 Structure for MCAN Tx Buffer element which takes data as a pointer. More...
 
struct  MCAN_RxBufElement
 Structure for MCAN Rx Buffer element. More...
 
struct  MCAN_RxBufElementNoCpy
 Structure for MCAN Rx Buffer element which takes data as a pointer. Please note that as the data field is a pointer so wrong value for payload size passed from application will lead to data corruption. More...
 
struct  MCAN_TxEventFifoElement
 Structure for MCAN Tx Event FIFO element. More...
 
struct  MCAN_StdMsgIDFilterElement
 Structure for MCAN Standard Message ID Filter Element. More...
 
struct  MCAN_ExtMsgIDFilterElement
 Structure for MCAN Extended Message ID Filter Element. More...
 

Macros

#define MCAN_STATUS_SUCCESS   ((int_fast16_t)0)
 Successful status code. More...
 
#define MCAN_STATUS_ERROR   ((int_fast16_t)-1)
 Generic error status code. More...
 
#define MCAN_MAX_PAYLOAD_SIZE   (64U)
 Maximum payload supported by CAN-FD protocol in bytes. More...
 
#define MCAN_STD_ID_FILTER_ELEM_SIZE   (4U)
 Standard Message ID filter element size in bytes. More...
 
#define MCAN_EXT_ID_FILTER_ELEM_SIZE   (8U)
 Extended Message ID filter element size in bytes. More...
 
#define MCAN_TX_EVENT_ELEM_SIZE   (8U)
 Tx Event FIFO element size in bytes. More...
 
#define MCAN_TX_RX_ELEMENT_HEADER_SIZE   (8U)
 Tx/Rx Element Header Size in bytes. More...
 

Functions

void MCAN_writeReg (uint32_t offset, uint32_t value)
 
void MCAN_writeMsgRam (uint32_t offset, const uint8_t *src, size_t numBytes)
 
uint32_t MCAN_readReg (uint32_t offset)
 
void MCAN_readMsgRam (uint8_t *dst, uint32_t offset, size_t numBytes)
 
uint32_t MCAN_getMRAMOffset (void)
 
int_fast16_t MCAN_init (const MCAN_InitParams *initParams)
 Initializes M_CAN controller. More...
 
int_fast16_t MCAN_config (const MCAN_ConfigParams *config)
 Configures M_CAN controller. More...
 
void MCAN_setOpMode (MCAN_OperationMode mode)
 Sets M_CAN controller mode of operation. More...
 
MCAN_OperationMode MCAN_getOpMode (void)
 Returns M_CAN controller mode of operation. More...
 
void MCAN_getBitTime (MCAN_BitTimingParams *bitTiming)
 Reads the M_CAN controller bit timings. More...
 
int_fast16_t MCAN_setBitTime (const MCAN_BitTimingParams *bitTiming)
 Sets M_CAN controller bit timings. More...
 
void MCAN_configMsgRam (const MCAN_MsgRamConfig *msgRamConfig)
 Configures the various sections of Message RAM. More...
 
void MCAN_writeTxMsgNoCpy (uint32_t bufIdx, const MCAN_TxBufElementNoCpy *elem)
 Writes Tx message to message RAM. More...
 
void MCAN_writeTxMsg (uint32_t bufIdx, const MCAN_TxBufElement *elem)
 Writes Tx message to message RAM. More...
 
void MCAN_setTxBufAddReq (uint32_t bufIdx)
 Sets Tx Buffer Add Request. More...
 
void MCAN_getNewDataStatus (MCAN_RxNewDataStatus *newDataStatus)
 Reads New Data Message Status. More...
 
void MCAN_clearNewDataStatus (const MCAN_RxNewDataStatus *newDataStatus)
 Clears New Data Message Status. More...
 
void MCAN_readRxMsgNoCpy (MCAN_MemType memType, uint32_t num, MCAN_RxBufElementNoCpy *elem)
 Reads received message from message RAM. More...
 
void MCAN_readRxMsg (MCAN_MemType memType, uint32_t num, MCAN_RxBufElement *elem)
 Reads received message from message RAM. More...
 
int_fast16_t MCAN_readTxEventFifo (MCAN_TxEventFifoElement *elem)
 Reads next available element from Tx Event FIFO. More...
 
void MCAN_addStdMsgIDFilter (uint32_t filtNum, const MCAN_StdMsgIDFilterElement *elem)
 Adds Standard Message ID Filter Element. More...
 
void MCAN_addExtMsgIDFilter (uint32_t filtNum, const MCAN_ExtMsgIDFilterElement *elem)
 Adds Extended Message ID Filter Element. More...
 
void MCAN_enableLoopbackMode (MCAN_LpbkMode lpbkMode)
 Enables Loopback Test Mode for M_CAN controller. More...
 
void MCAN_disableLoopbackMode (void)
 Disables Loopback Test Mode for M_CAN controller. More...
 
void MCAN_getProtocolStatus (MCAN_ProtocolStatus *protStatus)
 Reads protocol status for M_CAN controller. More...
 
void MCAN_enableInt (uint32_t intMask)
 Enables interrupts. More...
 
void MCAN_disableInt (uint32_t intMask)
 Disables interrupts. More...
 
void MCAN_setIntLineSel (uint32_t intMask, MCAN_IntLineNum lineNum)
 Sets interrupt line select. More...
 
void MCAN_enableIntLine (MCAN_IntLineNum lineNum)
 Enables selected interrupt line. More...
 
void MCAN_disableIntLine (MCAN_IntLineNum lineNum)
 Disables selected interrupt line. More...
 
uint32_t MCAN_getIntStatus (void)
 Returns interrupt status. More...
 
void MCAN_clearIntStatus (uint32_t intMask)
 Clears the interrupt status. More...
 
void MCAN_getRxFifoStatus (MCAN_RxFifoNum fifoNum, MCAN_RxFifoStatus *fifoStatus)
 Reads Rx FIFO status. More...
 
void MCAN_getTxEventFifoStatus (MCAN_TxEventFifoStatus *fifoStatus)
 Reads Tx Event FIFO status. More...
 
void MCAN_getTxFifoQStatus (MCAN_TxFifoQStatus *fifoQStatus)
 Reads Tx FIFO/Queue status. More...
 
int_fast16_t MCAN_setRxFifoAck (MCAN_RxFifoNum fifoNum, uint32_t idx)
 Sets Rx FIFO Acknowledgement. More...
 
uint32_t MCAN_getTxBufReqPend (void)
 Returns Tx Buffer Request Pending status. More...
 
void MCAN_cancelTxBufReq (uint32_t bufIdx)
 Cancels a Tx Buffer Request. More...
 
uint32_t MCAN_getTxBufTransmissionStatus (void)
 Returns Tx Buffer Transmission Occurred status. More...
 
uint32_t MCAN_getTxBufCancellationStatus (void)
 Returns Transmit Buffer Cancellation Finished status. More...
 
void MCAN_enableTxBufTransInt (uint32_t bufMask)
 Enables Tx Buffer Transmission Interrupt. More...
 
void MCAN_disableTxBufTransInt (uint32_t bufMask)
 Disables Tx Buffer Transmission Interrupt. More...
 
uint32_t MCAN_getClkStopAck (void)
 Returns clock stop acknowledgement for M_CAN controller. More...
 
uint16_t MCAN_getTimestampCounter (void)
 Returns the 16-bit timestamp counter value. More...
 

MCAN Interrupt Line Number

#define MCAN_INT_LINE_NUM_0   (0U)
 
#define MCAN_INT_LINE_NUM_1   (1U)
 
typedef uint32_t MCAN_IntLineNum
 Enum to select the MCAN interrupt lines. More...
 

MCAN Operation Mode

#define MCAN_OPERATION_MODE_NORMAL   (0U)
 
#define MCAN_OPERATION_MODE_SW_INIT   (1U)
 
typedef uint32_t MCAN_OperationMode
 Enum to represent the MCAN mode of operation. More...
 

MCAN Mem type

#define MCAN_MEM_TYPE_BUF   (0U)
 
#define MCAN_MEM_TYPE_FIFO   (1U)
 
typedef uint32_t MCAN_MemType
 Enum to represent the MCAN Message RAM type. More...
 

MCAN Rx FIFO Number

#define MCAN_RX_FIFO_NUM_0   (0U)
 
#define MCAN_RX_FIFO_NUM_1   (1U)
 
typedef uint32_t MCAN_RxFifoNum
 Enum to represent the MCAN Rx FIFO number. More...
 

MCAN Element Size

#define MCAN_ELEM_SIZE_8BYTES   (0U)
 
#define MCAN_ELEM_SIZE_12BYTES   (1U)
 
#define MCAN_ELEM_SIZE_16BYTES   (2U)
 
#define MCAN_ELEM_SIZE_20BYTES   (3U)
 
#define MCAN_ELEM_SIZE_24BYTES   (4U)
 
#define MCAN_ELEM_SIZE_32BYTES   (5U)
 
#define MCAN_ELEM_SIZE_48BYTES   (6U)
 
#define MCAN_ELEM_SIZE_64BYTES   (7U)
 
typedef uint32_t MCAN_ElemSize
 Enum to represent FIFO/Buffer element Size. More...
 

MCAN Timeout select

#define MCAN_TIMEOUT_SELECT_CONT   (0U)
 
#define MCAN_TIMEOUT_SELECT_TX_EVENT_FIFO   (1U)
 
#define MCAN_TIMEOUT_SELECT_RX_FIFO0   (2U)
 
#define MCAN_TIMEOUT_SELECT_RX_FIFO1   (3U)
 
typedef uint32_t MCAN_TimeOutSelect
 Enum to represent the MCAN time-out counter configuration. More...
 

MCAN Interrupt Source

#define MCAN_INT_SRC_RX_FIFO0_NEW_MSG   (MCAN_IR_RF0N_MASK)
 
#define MCAN_INT_SRC_RX_FIFO0_WATERMARK   (MCAN_IR_RF0W_MASK)
 
#define MCAN_INT_SRC_RX_FIFO0_FULL   (MCAN_IR_RF0F_MASK)
 
#define MCAN_INT_SRC_RX_FIFO0_MSG_LOST   (MCAN_IR_RF0L_MASK)
 
#define MCAN_INT_SRC_RX_FIFO1_NEW_MSG   (MCAN_IR_RF1N_MASK)
 
#define MCAN_INT_SRC_RX_FIFO1_WATERMARK   (MCAN_IR_RF1W_MASK)
 
#define MCAN_INT_SRC_RX_FIFO1_FULL   (MCAN_IR_RF1F_MASK)
 
#define MCAN_INT_SRC_RX_FIFO1_MSG_LOST   (MCAN_IR_RF1L_MASK)
 
#define MCAN_INT_SRC_HIGH_PRIO_MSG   (MCAN_IR_HPM_MASK)
 
#define MCAN_INT_SRC_TRANS_COMPLETE   (MCAN_IR_TC_MASK)
 
#define MCAN_INT_SRC_TRANS_CANCEL_FINISH   (MCAN_IR_TCF_MASK)
 
#define MCAN_INT_SRC_TX_FIFO_EMPTY   (MCAN_IR_TFE_MASK)
 
#define MCAN_INT_SRC_TX_EVT_FIFO_NEW_ENTRY   (MCAN_IR_TEFN_MASK)
 
#define MCAN_INT_SRC_TX_EVT_FIFO_WATERMARK   (MCAN_IR_TEFW_MASK)
 
#define MCAN_INT_SRC_TX_EVT_FIFO_FULL   (MCAN_IR_TEFF_MASK)
 
#define MCAN_INT_SRC_TX_EVT_FIFO_ELEM_LOST   (MCAN_IR_TEFL_MASK)
 
#define MCAN_INT_SRC_TIMESTAMP_WRAPAROUND   (MCAN_IR_TSW_MASK)
 
#define MCAN_INT_SRC_MSG_RAM_ACCESS_FAILURE   (MCAN_IR_MRAF_MASK)
 
#define MCAN_INT_SRC_TIMEOUT   (MCAN_IR_TOO_MASK)
 
#define MCAN_INT_SRC_DEDICATED_RX_BUFF_MSG   (MCAN_IR_DRX_MASK)
 
#define MCAN_INT_SRC_BIT_ERR_CORRECTED   (MCAN_IR_BEC_MASK)
 
#define MCAN_INT_SRC_BIT_ERR_UNCORRECTED   (MCAN_IR_BEU_MASK)
 
#define MCAN_INT_SRC_ERR_LOG_OVERFLOW   (MCAN_IR_ELO_MASK)
 
#define MCAN_INT_SRC_ERR_PASSIVE   (MCAN_IR_EP_MASK)
 
#define MCAN_INT_SRC_WARNING_STATUS   (MCAN_IR_EW_MASK)
 
#define MCAN_INT_SRC_BUS_OFF_STATUS   (MCAN_IR_BO_MASK)
 
#define MCAN_INT_SRC_WATCHDOG   (MCAN_IR_WDI_MASK)
 
#define MCAN_INT_SRC_PROTOCOL_ERR_ARB   (MCAN_IR_PEA_MASK)
 
#define MCAN_INT_SRC_PROTOCOL_ERR_DATA   (MCAN_IR_PED_MASK)
 
#define MCAN_INT_SRC_RES_ADDR_ACCESS   (MCAN_IR_ARA_MASK)
 
typedef uint32_t MCAN_IntSrc
 Enum for MCAN interrupts. More...
 

MCAN Loopback Mode

#define MCAN_LPBK_MODE_INTERNAL   (0U)
 
#define MCAN_LPBK_MODE_EXTERNAL   (1U)
 
typedef uint32_t MCAN_LpbkMode
 Enum to select the MCAN Loopback mode. More...
 

MCAN Com State

#define MCAN_COM_STATE_SYNCHRONIZING   (0U)
 
#define MCAN_COM_STATE_IDLE   (1U)
 
#define MCAN_COM_STATE_RECEIVER   (2U)
 
#define MCAN_COM_STATE_TRANSMITTER   (3U)
 
typedef uint32_t MCAN_ComState
 Enum to represent MCAN communication state. More...
 

MCAN General Filter Control Non-Matching

#define MCAN_GFC_NM_ACCEPT_INTO_RXFIFO0   (0U)
 
#define MCAN_GFC_NM_ACCEPT_INTO_RXFIFO1   (1U)
 
#define MCAN_GFC_NM_REJECT   (3U)
 
typedef uint32_t MCAN_GFCNonMatching
 Enum to represent the MCAN general filter configuration for non-matching frames. More...
 

MCAN timestamp select

#define MCAN_TSCC_COUNTER_ALWAYS_0   (0U)
 
#define MCAN_TSCC_COUNTER_USE_TCP   (1U)
 
#define MCAN_TSCC_COUNTER_EXTERNAL   (2U)
 
typedef uint32_t MCAN_TSCCTimestampSel
 Enum to represent the MCAN timestamp select. More...
 

MCAN Error Code

#define MCAN_ERR_CODE_NO_ERROR   (0U)
 
#define MCAN_ERR_CODE_STUFF_ERROR   (1U)
 
#define MCAN_ERR_CODE_FORM_ERROR   (2U)
 
#define MCAN_ERR_CODE_ACK_ERROR   (3U)
 
#define MCAN_ERR_CODE_BIT1_ERROR   (4U)
 
#define MCAN_ERR_CODE_BIT0_ERROR   (5U)
 
#define MCAN_ERR_CODE_CRC_ERROR   (6U)
 
#define MCAN_ERR_CODE_NO_CHANGE   (7U)
 
typedef uint32_t MCAN_ErrCode
 Enum to represent M_CAN Error Code. More...
 

Macro Definition Documentation

§ MCAN_STATUS_SUCCESS

#define MCAN_STATUS_SUCCESS   ((int_fast16_t)0)

Successful status code.

Functions return MCAN_STATUS_SUCCESS if the function was executed successfully.

§ MCAN_STATUS_ERROR

#define MCAN_STATUS_ERROR   ((int_fast16_t)-1)

Generic error status code.

Functions return MCAN_STATUS_ERROR if the function was not executed successfully and no more specific error is applicable.

§ MCAN_MAX_PAYLOAD_SIZE

#define MCAN_MAX_PAYLOAD_SIZE   (64U)

Maximum payload supported by CAN-FD protocol in bytes.

§ MCAN_STD_ID_FILTER_ELEM_SIZE

#define MCAN_STD_ID_FILTER_ELEM_SIZE   (4U)

Standard Message ID filter element size in bytes.

§ MCAN_EXT_ID_FILTER_ELEM_SIZE

#define MCAN_EXT_ID_FILTER_ELEM_SIZE   (8U)

Extended Message ID filter element size in bytes.

§ MCAN_TX_EVENT_ELEM_SIZE

#define MCAN_TX_EVENT_ELEM_SIZE   (8U)

Tx Event FIFO element size in bytes.

§ MCAN_TX_RX_ELEMENT_HEADER_SIZE

#define MCAN_TX_RX_ELEMENT_HEADER_SIZE   (8U)

Tx/Rx Element Header Size in bytes.

§ MCAN_INT_LINE_NUM_0

#define MCAN_INT_LINE_NUM_0   (0U)

MCAN interrupt line 0

§ MCAN_INT_LINE_NUM_1

#define MCAN_INT_LINE_NUM_1   (1U)

MCAN interrupt line 1

§ MCAN_OPERATION_MODE_NORMAL

#define MCAN_OPERATION_MODE_NORMAL   (0U)

MCAN normal mode

§ MCAN_OPERATION_MODE_SW_INIT

#define MCAN_OPERATION_MODE_SW_INIT   (1U)

MCAN SW initialization mode

§ MCAN_MEM_TYPE_BUF

#define MCAN_MEM_TYPE_BUF   (0U)

MCAN Msg RAM buffers

§ MCAN_MEM_TYPE_FIFO

#define MCAN_MEM_TYPE_FIFO   (1U)

MCAN Msg RAM FIFO/Queue

§ MCAN_RX_FIFO_NUM_0

#define MCAN_RX_FIFO_NUM_0   (0U)

MCAN Rx FIFO 0

§ MCAN_RX_FIFO_NUM_1

#define MCAN_RX_FIFO_NUM_1   (1U)

MCAN Rx FIFO 1

§ MCAN_ELEM_SIZE_8BYTES

#define MCAN_ELEM_SIZE_8BYTES   (0U)

8 byte data field

§ MCAN_ELEM_SIZE_12BYTES

#define MCAN_ELEM_SIZE_12BYTES   (1U)

12 byte data field

§ MCAN_ELEM_SIZE_16BYTES

#define MCAN_ELEM_SIZE_16BYTES   (2U)

16 byte data field

§ MCAN_ELEM_SIZE_20BYTES

#define MCAN_ELEM_SIZE_20BYTES   (3U)

20 byte data field

§ MCAN_ELEM_SIZE_24BYTES

#define MCAN_ELEM_SIZE_24BYTES   (4U)

24 byte data field

§ MCAN_ELEM_SIZE_32BYTES

#define MCAN_ELEM_SIZE_32BYTES   (5U)

32 byte data field

§ MCAN_ELEM_SIZE_48BYTES

#define MCAN_ELEM_SIZE_48BYTES   (6U)

48 byte data field

§ MCAN_ELEM_SIZE_64BYTES

#define MCAN_ELEM_SIZE_64BYTES   (7U)

64 byte data field

§ MCAN_TIMEOUT_SELECT_CONT

#define MCAN_TIMEOUT_SELECT_CONT   (0U)

Continuous operation Mode

§ MCAN_TIMEOUT_SELECT_TX_EVENT_FIFO

#define MCAN_TIMEOUT_SELECT_TX_EVENT_FIFO   (1U)

Timeout controlled by Tx Event FIFO

§ MCAN_TIMEOUT_SELECT_RX_FIFO0

#define MCAN_TIMEOUT_SELECT_RX_FIFO0   (2U)

Timeout controlled by Rx FIFO 0

§ MCAN_TIMEOUT_SELECT_RX_FIFO1

#define MCAN_TIMEOUT_SELECT_RX_FIFO1   (3U)

Timeout controlled by Rx FIFO 1

§ MCAN_INT_SRC_RX_FIFO0_NEW_MSG

#define MCAN_INT_SRC_RX_FIFO0_NEW_MSG   (MCAN_IR_RF0N_MASK)

Rx FIFO 0 New Message interrupt

§ MCAN_INT_SRC_RX_FIFO0_WATERMARK

#define MCAN_INT_SRC_RX_FIFO0_WATERMARK   (MCAN_IR_RF0W_MASK)

Rx FIFO 0 Watermark Reached interrupt

§ MCAN_INT_SRC_RX_FIFO0_FULL

#define MCAN_INT_SRC_RX_FIFO0_FULL   (MCAN_IR_RF0F_MASK)

Rx FIFO 0 Full interrupt

§ MCAN_INT_SRC_RX_FIFO0_MSG_LOST

#define MCAN_INT_SRC_RX_FIFO0_MSG_LOST   (MCAN_IR_RF0L_MASK)

Rx FIFO 0 Message Lost interrupt

§ MCAN_INT_SRC_RX_FIFO1_NEW_MSG

#define MCAN_INT_SRC_RX_FIFO1_NEW_MSG   (MCAN_IR_RF1N_MASK)

Rx FIFO 1 New Message interrupt

§ MCAN_INT_SRC_RX_FIFO1_WATERMARK

#define MCAN_INT_SRC_RX_FIFO1_WATERMARK   (MCAN_IR_RF1W_MASK)

Rx FIFO 1 Watermark Reached interrupt

§ MCAN_INT_SRC_RX_FIFO1_FULL

#define MCAN_INT_SRC_RX_FIFO1_FULL   (MCAN_IR_RF1F_MASK)

Rx FIFO 1 Full interrupt

§ MCAN_INT_SRC_RX_FIFO1_MSG_LOST

#define MCAN_INT_SRC_RX_FIFO1_MSG_LOST   (MCAN_IR_RF1L_MASK)

Rx FIFO 1 Message Lost interrupt

§ MCAN_INT_SRC_HIGH_PRIO_MSG

#define MCAN_INT_SRC_HIGH_PRIO_MSG   (MCAN_IR_HPM_MASK)

High Priority Message interrupt

§ MCAN_INT_SRC_TRANS_COMPLETE

#define MCAN_INT_SRC_TRANS_COMPLETE   (MCAN_IR_TC_MASK)

Transmission Completed interrupt

§ MCAN_INT_SRC_TRANS_CANCEL_FINISH

#define MCAN_INT_SRC_TRANS_CANCEL_FINISH   (MCAN_IR_TCF_MASK)

Transmission Cancellation Finished interrupt

§ MCAN_INT_SRC_TX_FIFO_EMPTY

#define MCAN_INT_SRC_TX_FIFO_EMPTY   (MCAN_IR_TFE_MASK)

Tx FIFO Empty interrupt

§ MCAN_INT_SRC_TX_EVT_FIFO_NEW_ENTRY

#define MCAN_INT_SRC_TX_EVT_FIFO_NEW_ENTRY   (MCAN_IR_TEFN_MASK)

Tx Event FIFO New Entry interrupt

§ MCAN_INT_SRC_TX_EVT_FIFO_WATERMARK

#define MCAN_INT_SRC_TX_EVT_FIFO_WATERMARK   (MCAN_IR_TEFW_MASK)

Tx Event FIFO Watermark Reached interrupt

§ MCAN_INT_SRC_TX_EVT_FIFO_FULL

#define MCAN_INT_SRC_TX_EVT_FIFO_FULL   (MCAN_IR_TEFF_MASK)

Tx Event FIFO Full interrupt

§ MCAN_INT_SRC_TX_EVT_FIFO_ELEM_LOST

#define MCAN_INT_SRC_TX_EVT_FIFO_ELEM_LOST   (MCAN_IR_TEFL_MASK)

Tx Event FIFO Element Lost interrupt

§ MCAN_INT_SRC_TIMESTAMP_WRAPAROUND

#define MCAN_INT_SRC_TIMESTAMP_WRAPAROUND   (MCAN_IR_TSW_MASK)

Timestamp Wraparound interrupt

§ MCAN_INT_SRC_MSG_RAM_ACCESS_FAILURE

#define MCAN_INT_SRC_MSG_RAM_ACCESS_FAILURE   (MCAN_IR_MRAF_MASK)

Message RAM Access Failure interrupt

§ MCAN_INT_SRC_TIMEOUT

#define MCAN_INT_SRC_TIMEOUT   (MCAN_IR_TOO_MASK)

Timeout Occurred interrupt

§ MCAN_INT_SRC_DEDICATED_RX_BUFF_MSG

#define MCAN_INT_SRC_DEDICATED_RX_BUFF_MSG   (MCAN_IR_DRX_MASK)

Message stored to Dedicated Rx Buffer interrupt

§ MCAN_INT_SRC_BIT_ERR_CORRECTED

#define MCAN_INT_SRC_BIT_ERR_CORRECTED   (MCAN_IR_BEC_MASK)

Bit Error Corrected interrupt

§ MCAN_INT_SRC_BIT_ERR_UNCORRECTED

#define MCAN_INT_SRC_BIT_ERR_UNCORRECTED   (MCAN_IR_BEU_MASK)

Bit Error Uncorrected interrupt

§ MCAN_INT_SRC_ERR_LOG_OVERFLOW

#define MCAN_INT_SRC_ERR_LOG_OVERFLOW   (MCAN_IR_ELO_MASK)

Error Logging Overflow interrupt

§ MCAN_INT_SRC_ERR_PASSIVE

#define MCAN_INT_SRC_ERR_PASSIVE   (MCAN_IR_EP_MASK)

Error Passive interrupt

§ MCAN_INT_SRC_WARNING_STATUS

#define MCAN_INT_SRC_WARNING_STATUS   (MCAN_IR_EW_MASK)

Warning Status interrupt

§ MCAN_INT_SRC_BUS_OFF_STATUS

#define MCAN_INT_SRC_BUS_OFF_STATUS   (MCAN_IR_BO_MASK)

Bus_Off Status interrupt

§ MCAN_INT_SRC_WATCHDOG

#define MCAN_INT_SRC_WATCHDOG   (MCAN_IR_WDI_MASK)

Watchdog Interrupt interrupt

§ MCAN_INT_SRC_PROTOCOL_ERR_ARB

#define MCAN_INT_SRC_PROTOCOL_ERR_ARB   (MCAN_IR_PEA_MASK)

Protocol Error in Arbitration Phase interrupt

§ MCAN_INT_SRC_PROTOCOL_ERR_DATA

#define MCAN_INT_SRC_PROTOCOL_ERR_DATA   (MCAN_IR_PED_MASK)

Protocol Error in Data Phase interrupt

§ MCAN_INT_SRC_RES_ADDR_ACCESS

#define MCAN_INT_SRC_RES_ADDR_ACCESS   (MCAN_IR_ARA_MASK)

Access to Reserved Address interrupt

§ MCAN_LPBK_MODE_INTERNAL

#define MCAN_LPBK_MODE_INTERNAL   (0U)

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

§ MCAN_LPBK_MODE_EXTERNAL

#define MCAN_LPBK_MODE_EXTERNAL   (1U)

External Loop Back Mode. In this mode, the M_CAN controller 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.

§ MCAN_COM_STATE_SYNCHRONIZING

#define MCAN_COM_STATE_SYNCHRONIZING   (0U)

MCAN is synchronizing on CAN communication

§ MCAN_COM_STATE_IDLE

#define MCAN_COM_STATE_IDLE   (1U)

MCAN is neither receiver nor transmitter

§ MCAN_COM_STATE_RECEIVER

#define MCAN_COM_STATE_RECEIVER   (2U)

MCAN is operating as receiver

§ MCAN_COM_STATE_TRANSMITTER

#define MCAN_COM_STATE_TRANSMITTER   (3U)

MCAN is operating as transmitter

§ MCAN_GFC_NM_ACCEPT_INTO_RXFIFO0

#define MCAN_GFC_NM_ACCEPT_INTO_RXFIFO0   (0U)

Accept non-matching frames into Rx FIFO0

§ MCAN_GFC_NM_ACCEPT_INTO_RXFIFO1

#define MCAN_GFC_NM_ACCEPT_INTO_RXFIFO1   (1U)

Accept non-matching frames into Rx FIFO0

§ MCAN_GFC_NM_REJECT

#define MCAN_GFC_NM_REJECT   (3U)

Reject non-matching frames

§ MCAN_TSCC_COUNTER_ALWAYS_0

#define MCAN_TSCC_COUNTER_ALWAYS_0   (0U)

Timestamp counter value always 0x0000

§ MCAN_TSCC_COUNTER_USE_TCP

#define MCAN_TSCC_COUNTER_USE_TCP   (1U)

Timestamp counter value incremented according to Timestamp Counter Prescaler

§ MCAN_TSCC_COUNTER_EXTERNAL

#define MCAN_TSCC_COUNTER_EXTERNAL   (2U)

External timestamp counter value used - req'd for CAN FD

§ MCAN_ERR_CODE_NO_ERROR

#define MCAN_ERR_CODE_NO_ERROR   (0U)

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

§ MCAN_ERR_CODE_STUFF_ERROR

#define MCAN_ERR_CODE_STUFF_ERROR   (1U)

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

§ MCAN_ERR_CODE_FORM_ERROR

#define MCAN_ERR_CODE_FORM_ERROR   (2U)

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

§ MCAN_ERR_CODE_ACK_ERROR

#define MCAN_ERR_CODE_ACK_ERROR   (3U)

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

§ MCAN_ERR_CODE_BIT1_ERROR

#define MCAN_ERR_CODE_BIT1_ERROR   (4U)

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.

§ MCAN_ERR_CODE_BIT0_ERROR

#define MCAN_ERR_CODE_BIT0_ERROR   (5U)

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).

§ MCAN_ERR_CODE_CRC_ERROR

#define MCAN_ERR_CODE_CRC_ERROR   (6U)

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.

§ MCAN_ERR_CODE_NO_CHANGE

#define MCAN_ERR_CODE_NO_CHANGE   (7U)

Typedef Documentation

§ MCAN_IntLineNum

typedef uint32_t MCAN_IntLineNum

Enum to select the MCAN interrupt lines.

§ MCAN_OperationMode

typedef uint32_t MCAN_OperationMode

Enum to represent the MCAN mode of operation.

§ MCAN_MemType

typedef uint32_t MCAN_MemType

Enum to represent the MCAN Message RAM type.

§ MCAN_RxFifoNum

typedef uint32_t MCAN_RxFifoNum

Enum to represent the MCAN Rx FIFO number.

§ MCAN_ElemSize

typedef uint32_t MCAN_ElemSize

Enum to represent FIFO/Buffer element Size.

§ MCAN_TimeOutSelect

typedef uint32_t MCAN_TimeOutSelect

Enum to represent the MCAN time-out counter configuration.

§ MCAN_IntSrc

typedef uint32_t MCAN_IntSrc

Enum for MCAN interrupts.

§ MCAN_LpbkMode

typedef uint32_t MCAN_LpbkMode

Enum to select the MCAN Loopback mode.

§ MCAN_ComState

typedef uint32_t MCAN_ComState

Enum to represent MCAN communication state.

§ MCAN_GFCNonMatching

typedef uint32_t MCAN_GFCNonMatching

Enum to represent the MCAN general filter configuration for non-matching frames.

§ MCAN_TSCCTimestampSel

typedef uint32_t MCAN_TSCCTimestampSel

Enum to represent the MCAN timestamp select.

§ MCAN_ErrCode

typedef uint32_t MCAN_ErrCode

Enum to represent M_CAN Error Code.

Function Documentation

§ MCAN_writeReg()

void MCAN_writeReg ( uint32_t  offset,
uint32_t  value 
)

§ MCAN_writeMsgRam()

void MCAN_writeMsgRam ( uint32_t  offset,
const uint8_t *  src,
size_t  numBytes 
)

§ MCAN_readReg()

uint32_t MCAN_readReg ( uint32_t  offset)

§ MCAN_readMsgRam()

void MCAN_readMsgRam ( uint8_t *  dst,
uint32_t  offset,
size_t  numBytes 
)

§ MCAN_getMRAMOffset()

uint32_t MCAN_getMRAMOffset ( void  )

§ MCAN_init()

int_fast16_t MCAN_init ( const MCAN_InitParams initParams)

Initializes M_CAN controller.

Parameters
initParamsPointer to initialization parameters. Refer struct MCAN_InitParams.
Return values
MCAN_STATUS_SUCCESSif successful.
MCAN_STATUS_ERRORif config has invalid time delay compensation or WDT preload.

§ MCAN_config()

int_fast16_t MCAN_config ( const MCAN_ConfigParams config)

Configures M_CAN controller.

Parameters
configPointer to configuration parameters. Refer struct MCAN_ConfigParams.
Return values
MCAN_STATUS_SUCCESSif successful.
MCAN_STATUS_ERRORif config has invalid prescaler or timeout preload.

§ MCAN_setOpMode()

void MCAN_setOpMode ( MCAN_OperationMode  mode)

Sets M_CAN controller mode of operation.

Parameters
modeMode of operation. Refer enum MCAN_OperationMode.
Returns
None.

§ MCAN_getOpMode()

MCAN_OperationMode MCAN_getOpMode ( void  )

Returns M_CAN controller mode of operation.

Returns
mode Mode of operation. Refer enum MCAN_OperationMode.

§ MCAN_getBitTime()

void MCAN_getBitTime ( MCAN_BitTimingParams bitTiming)

Reads the M_CAN controller bit timings.

Parameters
bitTimingPointer to MCAN bit timing parameters. Refer struct MCAN_BitTimingParams.
Returns
None.

§ MCAN_setBitTime()

int_fast16_t MCAN_setBitTime ( const MCAN_BitTimingParams bitTiming)

Sets M_CAN controller bit timings.

Parameters
bitTimingPointer to MCAN bit timing parameters. Refer struct MCAN_BitTimingParams.
Return values
MCAN_STATUS_SUCCESSif successful.
MCAN_STATUS_ERRORif config has invalid timing values.

§ MCAN_configMsgRam()

void MCAN_configMsgRam ( const MCAN_MsgRamConfig msgRamConfig)

Configures the various sections of Message RAM.

Warning
Message RAM configuration is not validated by this API.
Parameters
msgRamConfigPointer to Message RAM configuration. Refer struct MCAN_MsgRamConfig.
Returns
None.

§ MCAN_writeTxMsgNoCpy()

void MCAN_writeTxMsgNoCpy ( uint32_t  bufIdx,
const MCAN_TxBufElementNoCpy elem 
)

Writes Tx message to message RAM.

Parameters
bufIdxTx Buffer index [0-31] where to write message. Must be valid per the message RAM configuration.
elemPointer to Tx element. Refer struct MCAN_TxBufElementNoCpy.
Returns
None.
Postcondition
MCAN_setTxBufAddReq()
See also
MCAN_writeTxMsg()

§ MCAN_writeTxMsg()

void MCAN_writeTxMsg ( uint32_t  bufIdx,
const MCAN_TxBufElement elem 
)

Writes Tx message to message RAM.

Parameters
bufIdxTx Buffer index [0-31] where to write message. Must be valid per the message RAM configuration.
elemPointer to Tx element. Refer struct MCAN_TxBufElement.
Returns
None.
Postcondition
MCAN_setTxBufAddReq()
See also
MCAN_writeTxMsgNoCpy()

§ MCAN_setTxBufAddReq()

void MCAN_setTxBufAddReq ( uint32_t  bufIdx)

Sets Tx Buffer Add Request.

Precondition
MCAN_writeTxMsgNoCpy() or MCAN_writeTxMsg()
Parameters
bufIdxTx Buffer index [0-31] for which request is to be added. Must be valid per the message RAM configuration.
Returns
None.

§ MCAN_getNewDataStatus()

void MCAN_getNewDataStatus ( MCAN_RxNewDataStatus newDataStatus)

Reads New Data Message Status.

Parameters
newDataStatusPointer to Rx Buffer new data status. Refer struct MCAN_RxNewDataStatus.
Returns
None.
Postcondition
MCAN_clearNewDataStatus()

§ MCAN_clearNewDataStatus()

void MCAN_clearNewDataStatus ( const MCAN_RxNewDataStatus newDataStatus)

Clears New Data Message Status.

Precondition
MCAN_getNewDataStatus()
Parameters
newDataStatusPointer to Rx Buffer new data status. Refer struct MCAN_RxNewDataStatus.
Returns
None.

§ MCAN_readRxMsgNoCpy()

void MCAN_readRxMsgNoCpy ( MCAN_MemType  memType,
uint32_t  num,
MCAN_RxBufElementNoCpy elem 
)

Reads received message from message RAM.

This function uses the MCAN_RxBufElementNoCpy structure element which has data as pointer instead of an array. Note that as the data is a pointer here hence corruption of data is possible when the payload size is exceeded.

Parameters
memTypePart of message ram to which given message to write. Refer enum MCAN_MemType.
numBuffer number or FIFO number from where message is to read. Refer enum MCAN_RxFifoNum if FIFO number. Must be valid per the message RAM configuration.
elemPointer to Rx element. Refer struct MCAN_RxBufElementNoCpy.
Returns
None.
Postcondition
MCAN_setRxFifoAck()
See also
MCAN_readRxMsg()

§ MCAN_readRxMsg()

void MCAN_readRxMsg ( MCAN_MemType  memType,
uint32_t  num,
MCAN_RxBufElement elem 
)

Reads received message from message RAM.

Parameters
memTypePart of message ram to which given message to write. Refer enum MCAN_MemType.
numBuffer number or FIFO number from where message is to read. Refer enum MCAN_RxFifoNum if FIFO number. Must be valid per the message RAM configuration.
elemPointer to Rx element. Refer struct MCAN_RxBufElement.
Returns
None.
Postcondition
MCAN_setRxFifoAck()
See also
MCAN_readRxMsgNoCpy()

§ MCAN_readTxEventFifo()

int_fast16_t MCAN_readTxEventFifo ( MCAN_TxEventFifoElement elem)

Reads next available element from Tx Event FIFO.

This function writes the Tx Event FIFO acknowledge index after successfully reading the Tx Event FIFO element.

Parameters
elemPointer to Tx Event FIFO Element Object. Refer struct MCAN_TxEventFifoElement.
Return values
MCAN_STATUS_SUCCESSif successful.
MCAN_STATUS_ERRORif the Tx Event FIFO is empty.

§ MCAN_addStdMsgIDFilter()

void MCAN_addStdMsgIDFilter ( uint32_t  filtNum,
const MCAN_StdMsgIDFilterElement elem 
)

Adds Standard Message ID Filter Element.

Parameters
filtNumFilter number (0-based).
elemPointer to standard ID Filter Object. Refer struct MCAN_StdMsgIDFilterElement.
Returns
None.

§ MCAN_addExtMsgIDFilter()

void MCAN_addExtMsgIDFilter ( uint32_t  filtNum,
const MCAN_ExtMsgIDFilterElement elem 
)

Adds Extended Message ID Filter Element.

Parameters
filtNumFilter number (0-based).
elemPointer to extended ID Filter Object. Refer struct MCAN_ExtMsgIDFilterElement.
Returns
None.

§ MCAN_enableLoopbackMode()

void MCAN_enableLoopbackMode ( MCAN_LpbkMode  lpbkMode)

Enables Loopback Test Mode for M_CAN controller.

Parameters
lpbkModeLoopback mode for MCAN. Refer enum MCAN_LpbkMode.
Returns
None.
Note
This API can be called only when MCAN is in Software Initialization mode of operation.

§ MCAN_disableLoopbackMode()

void MCAN_disableLoopbackMode ( void  )

Disables Loopback Test Mode for M_CAN controller.

Precondition
MCAN_enableLoopbackMode()
Returns
None.
Note
This API can be called only when MCAN is in Software Initialization mode of operation.

§ MCAN_getProtocolStatus()

void MCAN_getProtocolStatus ( MCAN_ProtocolStatus protStatus)

Reads protocol status for M_CAN controller.

Parameters
protStatusPointer to Protocol Status. Refer struct MCAN_ProtocolStatus.
Returns
None.

§ MCAN_enableInt()

void MCAN_enableInt ( uint32_t  intMask)

Enables interrupts.

Parameters
intMaskBit mask of interrupts to enable. Refer enum MCAN_IntSrc.
Returns
None.

§ MCAN_disableInt()

void MCAN_disableInt ( uint32_t  intMask)

Disables interrupts.

Parameters
intMaskBit mask of interrupts to disable. Refer enum MCAN_IntSrc.
Returns
None.

§ MCAN_setIntLineSel()

void MCAN_setIntLineSel ( uint32_t  intMask,
MCAN_IntLineNum  lineNum 
)

Sets interrupt line select.

Parameters
intMaskInterrupt Number for which interrupt line is to be selected. Refer enum MCAN_IntSrc.
lineNumInterrupt Line to select. Refer enum MCAN_IntLineNum.
Returns
None.

§ MCAN_enableIntLine()

void MCAN_enableIntLine ( MCAN_IntLineNum  lineNum)

Enables selected interrupt line.

Parameters
lineNumInterrupt Line to enable. Refer enum MCAN_IntLineNum.
Returns
None.

§ MCAN_disableIntLine()

void MCAN_disableIntLine ( MCAN_IntLineNum  lineNum)

Disables selected interrupt line.

Parameters
lineNumInterrupt Line to disable. Refer enum MCAN_IntLineNum.
Returns
None.

§ MCAN_getIntStatus()

uint32_t MCAN_getIntStatus ( void  )

Returns interrupt status.

Returns
Interrupt Status.

§ MCAN_clearIntStatus()

void MCAN_clearIntStatus ( uint32_t  intMask)

Clears the interrupt status.

Parameters
intMaskInterrupts to clear status.
Returns
None.

§ MCAN_getRxFifoStatus()

void MCAN_getRxFifoStatus ( MCAN_RxFifoNum  fifoNum,
MCAN_RxFifoStatus fifoStatus 
)

Reads Rx FIFO status.

Parameters
fifoNumRx FIFO number Refer enum MCAN_RxFifoNum
fifoStatusRx FIFO Status. Refer struct MCAN_RxFifoStatus.
Returns
None.

§ MCAN_getTxEventFifoStatus()

void MCAN_getTxEventFifoStatus ( MCAN_TxEventFifoStatus fifoStatus)

Reads Tx Event FIFO status.

Parameters
fifoStatusPointer to Tx Event FIFO Status. Refer struct TxEventFifoStatus.
Returns
None.

§ MCAN_getTxFifoQStatus()

void MCAN_getTxFifoQStatus ( MCAN_TxFifoQStatus fifoQStatus)

Reads Tx FIFO/Queue status.

Parameters
fifoQStatusPointer to Tx FIFO/Queue Status. Refer struct MCAN_TxFifoQStatus.
Returns
None.

§ MCAN_setRxFifoAck()

int_fast16_t MCAN_setRxFifoAck ( MCAN_RxFifoNum  fifoNum,
uint32_t  idx 
)

Sets Rx FIFO Acknowledgement.

Parameters
fifoNumFIFO Number. Refer enum MCAN_RxFifoNum.
idxRx FIFO Acknowledge Index
Return values
MCAN_STATUS_SUCCESSif successful.
MCAN_STATUS_ERRORif fifoNum or idx is invalid.

§ MCAN_getTxBufReqPend()

uint32_t MCAN_getTxBufReqPend ( void  )

Returns Tx Buffer Request Pending status.

Returns
Tx Buffer Request Pending status.

§ MCAN_cancelTxBufReq()

void MCAN_cancelTxBufReq ( uint32_t  bufIdx)

Cancels a Tx Buffer Request.

Parameters
bufIdxTx Buffer index [0-31] for which request is to be cancelled.
Returns
None.

§ MCAN_getTxBufTransmissionStatus()

uint32_t MCAN_getTxBufTransmissionStatus ( void  )

Returns Tx Buffer Transmission Occurred status.

Returns
Tx Buffer Transmission Occurred status.

§ MCAN_getTxBufCancellationStatus()

uint32_t MCAN_getTxBufCancellationStatus ( void  )

Returns Transmit Buffer Cancellation Finished status.

Returns
Transmit Buffer Cancellation Finished status.

§ MCAN_enableTxBufTransInt()

void MCAN_enableTxBufTransInt ( uint32_t  bufMask)

Enables Tx Buffer Transmission Interrupt.

Parameters
bufMaskTx Buffer mask for which interrupt(s) to enable.
Returns
None.

§ MCAN_disableTxBufTransInt()

void MCAN_disableTxBufTransInt ( uint32_t  bufMask)

Disables Tx Buffer Transmission Interrupt.

Parameters
bufMaskTx Buffer mask for which interrupt(s) to disable.
Returns
None.

§ MCAN_getClkStopAck()

uint32_t MCAN_getClkStopAck ( void  )

Returns clock stop acknowledgement for M_CAN controller.

Returns
Clock Stop Acknowledge:
0 = No clock stop acknowledged,
1 = M_CAN may be set in power down

§ MCAN_getTimestampCounter()

uint16_t MCAN_getTimestampCounter ( void  )

Returns the 16-bit timestamp counter value.

Returns
Timestamp counter value
© Copyright 1995-2024, Texas Instruments Incorporated. All rights reserved.
Trademarks | Privacy policy | Terms of use | Terms of sale