# MCAN Module

The Modular Controller Area Network (MCAN) module supports both classic CAN and CAN FD (CAN with Flexible Data-Rate) specifications. CAN FD feature allows high throughput and increased payload per data frame. The classic CAN and CAN FD devices can coexist on the same network without any conflict. Functions are provided to setup and configure the module operating options, setup the different types of message objects, send and read messages, and setup and handle interrupts and events.

group `mcan_api`

  Defines

  `MCANSS_MSG_RAM_NUM` (0U)

    MCAN MSG RAM BANK number for ECC AGGR.

  `MCANSS_RX_BUFFER_MAX` (64U)

    Maximum Number of Rx Buffers.

  `MCANSS_TX_BUFFER_MAX` (32U)

    Maximum Number of Tx Buffers.

  `MCANSS_STD_ID_FILTER_SIZE_WORDS` (1U)

    Macro for standard Message ID filter.

  `MCANSS_EXT_ID_FILTER_SIZE_WORDS` (2U)

    Macro for extended Message ID filter.

  `MCANSS_TX_EVENT_FIFO_SIZE_WORDS` (2U)

    Macro for Tx Event FIFO element size.

  `MCANSS_INTR_LINE_EN_MASK` ((MCAN_ILE_EINT0_MASK | MCAN_ILE_EINT1_MASK))

    Macro for Interrupt Line enable mask.

  `MCAN_INTR_MASK_ALL` (MCAN_IR_RF0N_MASK

  | \

  MCAN_IR_RF0W_MASK

  | \

  MCAN_IR_RF0F_MASK

  | \

  MCAN_IR_RF0L_MASK

  | \

  MCAN_IR_RF1N_MASK

  | \

  MCAN_IR_RF1W_MASK

  | \

  MCAN_IR_RF1F_MASK

  | \

  MCAN_IR_RF1L_MASK

  | \

  MCAN_IR_HPM_MASK

  | \

  MCAN_IR_TC_MASK

  | \

  MCAN_IR_TCF_MASK

  | \

  MCAN_IR_TFE_MASK

  | \

  MCAN_IR_TEFN_MASK

  | \

  MCAN_IR_TEFW_MASK

  | \

  MCAN_IR_TEFF_MASK

  | \

  MCAN_IR_TEFL_MASK

  | \

  MCAN_IR_TSW_MASK

  | \

  MCAN_IR_MRAF_MASK

  | \

  MCAN_IR_TOO_MASK

  | \

  MCAN_IR_DRX_MASK

  | \

  MCAN_IR_BEC_MASK

  | \

  MCAN_IR_BEU_MASK

  | \

  MCAN_IR_ELO_MASK

  | \

  MCAN_IR_EP_MASK

  | \

  MCAN_IR_EW_MASK

  | \

  MCAN_IR_BO_MASK

  | \

  MCAN_IR_WDI_MASK

  | \

  MCAN_IR_PEA_MASK

  | \

  MCAN_IR_PED_MASK

  | \

  MCAN_IR_ARA_MASK)

    Macro defines mask for all the interrupts status for MCAN.

  `MCAN_MAX_PAYLOAD_BYTES` (64U)

    Maximum payload supported by CAN-FD protocol in bytes.

  `MCAN_STDFILT_RANGE` (0U)

    Range Filter from SFID1 to SFID2

  `MCAN_STDFILT_DUAL` (1U)

    Dual ID Filter for SFID1 or SFID2

  `MCAN_STDFILT_CLASSIC` (2U)

    Classic Filter: SFID1 = filter, SFID2 = mask

  `MCAN_STDFILT_DISABLED` (3U)

    Filter Element Disabled

  `MCAN_STDFILTEC_DISABLE` (0U)

    Filter Element Disabled

  `MCAN_STDFILTEC_FIFO0` (1U)

    Store in RX FIFO 0 if filter matches

  `MCAN_STDFILTEC_FIFO1` (2U)

    Store in RX FIFO 1 if filter matches

  `MCAN_STDFILTEC_REJECT` (3U)

    Reject ID if filter matches

  `MCAN_STDFILTEC_PRI` (4U)

    Set priority if filter matches

  `MCAN_STDFILTEC_PRI_FIFO0` (5U)

    Set priority and store in RX FIFO 0 if filter matches

  `MCAN_STDFILTEC_PRI_FIFO1` (6U)

    Set priority and store in RX FIFO 1 if filter matches

  `MCAN_STDFILTEC_RXBUFF` (7U)

    Store in RX Buffer

  Enums

  enum `MCAN_IntrLineNum`

    Enum to select the MCAN interrupt lines.

    Values:

    enumerator `MCAN_INTR_LINE_NUM_0` = 0U

      MCAN interrupt line 0

    enumerator `MCAN_INTR_LINE_NUM_1` = 1U

      MCAN interrupt line 1

  enum `MCAN_IdType`

    Enum to represent the MCAN Identifier Type.

    Values:

    enumerator `MCAN_ID_TYPE_11_BIT` = 0U

      11bit MCAN Identifier

    enumerator `MCAN_ID_TYPE_29_BIT` = 1U

      29bit MCAN Identifier

  enum `MCAN_OperationMode`

    Enum to represent the MCAN mode of operation.

    Values:

    enumerator `MCAN_OPERATION_MODE_NORMAL` = 0U

      MCAN normal mode

    enumerator `MCAN_OPERATION_MODE_SW_INIT` = 1U

      MCAN SW initialization mode

  enum `MCAN_MemType`

    Enum to represent the MCAN Message RAM type.

    Values:

    enumerator `MCAN_MEM_TYPE_BUF` = 0U

      MCAN Msg RAM buffers

    enumerator `MCAN_MEM_TYPE_FIFO` = 1U

      MCAN Msg RAM FIFO/Queue

  enum `MCAN_RxFIFONum`

    Enum to represent the MCAN Rx FIFO number.

    Values:

    enumerator `MCAN_RX_FIFO_NUM_0` = 0U

      MCAN Rx FIFO 0

    enumerator `MCAN_RX_FIFO_NUM_1` = 1U

      MCAN Rx FIFO 1

  enum `MCAN_PinType`

    Enum to represent the MCAN pin type.

    Values:

    enumerator `MCAN_PIN_TYPE_RX` = 0U

      MCAN Rx Pin

    enumerator `MCAN_PIN_TYPE_TX` = 1U

      MCAN Tx Pin

  enum `MCAN_ElemSize`

    Enum to represent FIFO/Buffer element Size.

    Values:

    enumerator `MCAN_ELEM_SIZE_8BYTES` = 0U

      8 byte data field

    enumerator `MCAN_ELEM_SIZE_12BYTES` = 1U

      12 byte data field

    enumerator `MCAN_ELEM_SIZE_16BYTES` = 2U

      16 byte data field

    enumerator `MCAN_ELEM_SIZE_20BYTES` = 3U

      20 byte data field

    enumerator `MCAN_ELEM_SIZE_24BYTES` = 4U

      24 byte data field

    enumerator `MCAN_ELEM_SIZE_32BYTES` = 5U

      32 byte data field

    enumerator `MCAN_ELEM_SIZE_48BYTES` = 6U

      48 byte data field

    enumerator `MCAN_ELEM_SIZE_64BYTES` = 7U

      64 byte data field

  enum `MCAN_TimeOutSelect`

    Enum to represent the MCAN time-out counter configuration.

    Values:

    enumerator `MCAN_TIMEOUT_SELECT_CONT` = 0U

      Continuous operation Mode

    enumerator `MCAN_TIMEOUT_SELECT_TX_EVENT_FIFO` = 1U

      Timeout controlled by Tx Event FIFO

    enumerator `MCAN_TIMEOUT_SELECT_RX_FIFO0` = 2U

      Timeout controlled by Rx FIFO 0

    enumerator `MCAN_TIMEOUT_SELECT_RX_FIFO1` = 3U

      Timeout controlled by Rx FIFO 1

  enum `MCAN_IntrSrc`

    Enum for MCAN interrupts.

    Values:

    enumerator `MCAN_INTR_SRC_RX_FIFO0_NEW_MSG` = (0x00000001U)

      Rx FIFO 0 New Message interrupt

    enumerator `MCAN_INTR_SRC_RX_FIFO0_WATERMARK` = (0x00000002U)

      Rx FIFO 0 Watermark Reached interrupt

    enumerator `MCAN_INTR_SRC_RX_FIFO0_FULL` = (0x00000004U)

      Rx FIFO 0 Full interrupt

    enumerator `MCAN_INTR_SRC_RX_FIFO0_MSG_LOST` = (0x00000008U)

      Rx FIFO 0 Message Lost interrupt

    enumerator `MCAN_INTR_SRC_RX_FIFO1_NEW_MSG` = (0x00000010U)

      Rx FIFO 1 New Message interrupt

    enumerator `MCAN_INTR_SRC_RX_FIFO1_WATERMARK` = (0x00000020U)

      Rx FIFO 1 Watermark Reached interrupt

    enumerator `MCAN_INTR_SRC_RX_FIFO1_FULL` = (0x00000040U)

      Rx FIFO 1 Full interrupt

    enumerator `MCAN_INTR_SRC_RX_FIFO1_MSG_LOST` = (0x00000080U)

      Rx FIFO 1 Message Lost interrupt

    enumerator `MCAN_INTR_SRC_HIGH_PRIO_MSG` = (0x00000100U)

      High Priority Message interrupt

    enumerator `MCAN_INTR_SRC_TRANS_COMPLETE` = (0x00000200U)

      Transmission Completed interrupt

    enumerator `MCAN_INTR_SRC_TRANS_CANCEL_FINISH` = (0x00000400U)

      Transmission Cancellation Finished interrupt

    enumerator `MCAN_INTR_SRC_TX_FIFO_EMPTY` = (0x00000800U)

      Tx FIFO Empty interrupt

    enumerator `MCAN_INTR_SRC_TX_EVT_FIFO_NEW_ENTRY` = (0x00001000U)

      Tx Event FIFO New Entry interrupt

    enumerator `MCAN_INTR_SRC_TX_EVT_FIFO_WATERMARK` = (0x00002000U)

      Tx Event FIFO Watermark Reached interrupt

    enumerator `MCAN_INTR_SRC_TX_EVT_FIFO_FULL` = (0x00004000U)

      Tx Event FIFO Full interrupt

    enumerator `MCAN_INTR_SRC_TX_EVT_FIFO_ELEM_LOST` = (0x00008000U)

      Tx Event FIFO Element Lost interrupt

    enumerator `MCAN_INTR_SRC_TIMESTAMP_WRAPAROUND` = (0x00010000U)

      Timestamp Wraparound interrupt

    enumerator `MCAN_INTR_SRC_MSG_RAM_ACCESS_FAILURE` = (0x00020000U)

      Message RAM Access Failure interrupt

    enumerator `MCAN_INTR_SRC_TIMEOUT` = (0x00040000U)

      Timeout Occurred interrupt

    enumerator `MCAN_INTR_SRC_DEDICATED_RX_BUFF_MSG` = (0x00080000U)

      Message stored to Dedicated Rx Buffer interrupt

    enumerator `MCAN_INTR_SRC_BIT_ERR_CORRECTED` = (0x00100000U)

      Bit Error Corrected interrupt

    enumerator `MCAN_INTR_SRC_BIT_ERR_UNCORRECTED` = (0x00200000U)

      Bit Error Uncorrected interrupt

    enumerator `MCAN_INTR_SRC_ERR_LOG_OVRFLW` = (0x00400000U)

      Error Logging Overflow interrupt

    enumerator `MCAN_INTR_SRC_ERR_PASSIVE` = (0x00800000U)

      Error Passive interrupt

    enumerator `MCAN_INTR_SRC_WARNING_STATUS` = (0x01000000U)

      Warning Status interrupt

    enumerator `MCAN_INTR_SRC_BUS_OFF_STATUS` = (0x02000000U)

      Bus_Off Status interrupt

    enumerator `MCAN_INTR_SRC_WATCHDOG` = (0x04000000U)

      Watchdog Interrupt interrupt

    enumerator `MCAN_INTR_SRC_PROTOCOL_ERR_ARB` = (0x08000000U)

      Protocol Error in Arbitration Phase interrupt

    enumerator `MCAN_INTR_SRC_PROTOCOL_ERR_DATA` = (0x10000000U)

      Protocol Error in Data Phase interrupt

    enumerator `MCAN_INTR_SRC_RES_ADDR_ACCESS` = (0x20000000U)

      Access to Reserved Address interrupt

  enum `MCAN_ECCErrType`

    Enum to represent the ECC Error Types.

    Values:

    enumerator `MCAN_ECC_ERR_TYPE_SEC` = 0U

      ECC Single Error Correction

    enumerator `MCAN_ECC_ERR_TYPE_DED` = 1U

      ECC Single Error Detection

  enum `MCAN_LpbkMode`

    Enum to select the MCAN Loopback mode.

    Values:

    enumerator `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.

    enumerator `MCAN_LPBK_MODE_EXTERNAL` = 1U

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

  enum `MCAN_ComState`

    Enum to represent MCAN’s communication state.

    Values:

    enumerator `MCAN_COM_STATE_SYNCHRONIZING` = 0U

      MCAN is synchronizing on CAN communication

    enumerator `MCAN_COM_STATE_IDLE` = 1U

      MCAN is neither receiver nor transmitter

    enumerator `MCAN_COM_STATE_RECEIVER` = 2U

      MCAN is operating as receiver

    enumerator `MCAN_COM_STATE_TRANSMITTER` = 3U

      MCAN is operating as transmitter

  enum `MCAN_ErrCode`

    Enum to represent MCAN’s Error Code.

    Values:

    enumerator `MCAN_ERR_CODE_NO_ERROR` = 0U

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

    enumerator `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.

    enumerator `MCAN_ERR_CODE_FORM_ERROR` = 2U

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

    enumerator `MCAN_ERR_CODE_ACK_ERROR` = 3U

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

    enumerator `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.

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

    enumerator `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.

    enumerator `MCAN_ERR_CODE_NO_CHANGE` = 7U

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

  enum `MCAN_ClockSource`

    Enum to determine the clock source that will be set up via a call to the MCAN_selectClockSource() API.

    Values:

    enumerator `MCAN_CLOCK_SOURCE_SYS` = 0x0

      Peripheral System Clock Source.

    enumerator `MCAN_CLOCK_SOURCE_AUXPLL` = 0x1

      Auxiliary PLL Clock Source.

    enumerator `MCAN_CLOCK_SOURCE_AUXIN` = 0x2

      Auxiliary Clock Input Source.

    enumerator `MCAN_CLOCK_SOURCE_PLLRAW` = 0x3

      PLL Raw Clock Source.

  Functions

  void `MCAN_selectClockSource`(uint32_t baseAddr, MCAN_ClockSource source)

    This function selects the specified clock source for the MCAN controller.

    The

    source parameter can be any one of the following:

    - MCAN_CLOCK_SOURCE_SYS - Peripheral System Clock

    - MCAN_CLOCK_SOURCE_AUXPLL - Auxiliary PLL Clock

    - MCAN_CLOCK_SOURCE_AUXIN - Auxiliary Clock Input

    - MCAN_CLOCK_SOURCE_PLLRAW - PLL Raw Clock

    Parameters

      - `baseAddr`: Base Address of the MCAN Registers.

      - `source`: Clock source to use for the MCAN controller.

    Return Value

      - `None`:

  uint32_t `MCAN_isInReset`(uint32_t baseAddr)

    This function checks if the MCAN module is in Reset.

    Parameters

      - `baseAddr`: Base Address of the MCAN Registers.

    Return Value

      - `state`: Returns TRUE if reset is in progress. Else returns FALSE.

  uint32_t `MCAN_isFDOpEnable`(uint32_t baseAddr)

    This API will return flexible data rate operation status MCAN module.

    Return

      state Returns TRUE if flexible data rate operation is enabled. Else returns FALSE.

    Parameters

      - `baseAddr`: Base Address of the MCAN Registers.

  uint32_t `MCAN_isMemInitDone`(uint32_t baseAddr)

    This function checks if the memory initialization is done for MCAN module.

    Parameters

      - `baseAddr`: Base Address of the MCAN Registers.

    Return Value

      - `state`: Returns TRUE if memory initialization is done. Else returns FALSE.

  void `MCAN_setOpMode`(uint32_t baseAddr, uint32_t mode)

    This API will set MCAN module mode of operation.

    Return

      None.

    Parameters

      - `baseAddr`: Base Address of the MCAN Registers.

      - `mode`: Mode of operation. Refer enum MCAN_OperationMode.

  uint32_t `MCAN_getOpMode`(uint32_t baseAddr)

    This API will return MCAN module mode of operation.

    Return

      mode Mode of operation. Refer enum MCAN_OperationMode.

    Parameters

      - `baseAddr`: Base Address of the MCAN Registers.

  int32_t `MCAN_init`(uint32_t baseAddr, const MCAN_InitParams *initParams)

    This API will initialize MCAN module.

    Return

      status Initialization status.

    Parameters

      - `baseAddr`: Base Address of the MCAN Registers.

      - `initParams`: Initialization parameters. Refer struct MCAN_InitParams.

  int32_t `MCAN_config`(uint32_t baseAddr, const MCAN_ConfigParams *configParams)

    This API will configure MCAN module.

    Return

      status Configuration status.

    Parameters

      - `baseAddr`: Base Address of the MCAN Registers.

      - `configParams`: configuration parameters. Refer struct MCAN_ConfigParams.

  void `MCAN_eccConfig`(uint32_t baseAddr, const MCAN_ECCConfigParams *configParams)

    This API will enable/disable ECC on the Message RAM.

    Return

      None.

    Parameters

      - `baseAddr`: Base Address of the MCAN Registers.

      - `configParams`: MCAN ECC Configuration Parameters. Refer #struct MCAN_ECCConfigParams.

  int32_t `MCAN_setBitTime`(uint32_t baseAddr, const MCAN_BitTimingParams *configParams)

    This API will configure a bit timings for MCAN module.

    Return

      status Bit Timings configuration status.

    Parameters

      - `baseAddr`: Base Address of the MCAN Registers.

      - `configParams`: Configuration parameters for MCAN bit timing. Refer struct MCAN_BitTimingParams.

  int32_t `MCAN_msgRAMConfig`(uint32_t baseAddr, const MCAN_MsgRAMConfigParams *msgRAMConfigParams)

    This API will configure Different sections of Message RAM.

    Return

      status Configuration Status.

    Parameters

      - `baseAddr`: Base Address of the MCAN Registers.

      - `msgRAMConfigParams`: Message RAM Configuration parameters. Refer struct MCAN_MsgRAMConfigParams.

  int32_t `MCAN_setExtIDAndMask`(uint32_t baseAddr, uint32_t idMask)

    This API will configure Extended ID AND Mask.

    Return

      status Extended ID AND Mask configuration status.

    Parameters

      - `baseAddr`: Base Address of the MCAN Registers.

      - `idMask`: Configuration parameters for MCAN Extended Id mask. This value is 29 bit wide.

  void `MCAN_writeMsgRam`(uint32_t baseAddr, uint32_t memType, uint32_t bufNum, const MCAN_TxBufElement *elem)

    This API is used to write Tx message to message RAM.

    Return

      None.

    Parameters

      - `baseAddr`: Base Address of the MCAN Registers.

      - `memType`: Part of message ram to which given message to write. Refer enum MCAN_MemType.

      - `bufNum`: Buffer number where message to write. This parameter will ignored if memType is FIFO/Q.

      - `elem`: Message Object. Refer struct MCAN_TxBufElement.

  int32_t `MCAN_txBufAddReq`(uint32_t baseAddr, uint32_t bufNum)

    This API will set Tx Buffer Add Request.

    Return

      status Configuration Status.

    Parameters

      - `baseAddr`: Base Address of the MCAN Registers.

      - `bufNum`: Tx Buffer number for which request is to be added.

  void `MCAN_getNewDataStatus`(uint32_t baseAddr, MCAN_RxNewDataStatus *newDataStatus)

    This API will return New Data Message Status.

    Return

      None.

    Parameters

      - `baseAddr`: Base Address of the MCAN Registers.

      - `newDataStatus`: Rx Buffer new data status. Refer struct MCAN_RxNewDataStatus.

  void `MCAN_clearNewDataStatus`(uint32_t baseAddr, const MCAN_RxNewDataStatus *newDataStatus)

    This API clear New Data Message Status.

    Return

      None.

    Parameters

      - `baseAddr`: Base Address of the MCAN Registers.

      - `newDataStatus`: Rx Buffer new data status. Refer struct MCAN_RxNewDataStatus.

  void `MCAN_readMsgRam`(uint32_t baseAddr, uint32_t memType, uint32_t bufNum, uint32_t fifoNum, MCAN_RxBufElement *elem)

    This API is used to read received message from Message RAM.

    Return

      None.

    Parameters

      - `baseAddr`: Base Address of the MCAN Registers.

      - `memType`: Part of message ram to which given message to write. Refer enum MCAN_MemType.

      - `bufNum`: Buffer number from where message is to read. This parameter will ignored if memType is FIFO/Q.

      - `fifoNum`: FIFOs number from where message is to read. Refer enum MCAN_RxFIFONum. This parameter will ignored if memType is buffer.

      - `elem`: Message Object. Refer struct MCAN_RxBufElement.

  void `MCAN_readTxEventFIFO`(uint32_t baseAddr, MCAN_TxEventFIFOElement *txEventElem)

    This API is used to read from Tx Event FIFO.

    Return

      None.

    Parameters

      - `baseAddr`: Base Address of the MCAN Registers.

      - `txEventElem`: Tx Event FIFO Message Object. Refer struct MCAN_TxEventFIFOElement.

  void `MCAN_addStdMsgIDFilter`(uint32_t baseAddr, uint32_t filtNum, const MCAN_StdMsgIDFilterElement *elem)

    This API is used to add Standard Message ID Filter Element.

    Return

      None.

    Parameters

      - `baseAddr`: Base Address of the MCAN Registers.

      - `filtNum`: Filter number.

      - `elem`: Filter Object. Refer struct MCAN_StdMsgIDFilterElement.

  void `MCAN_addExtMsgIDFilter`(uint32_t baseAddr, uint32_t filtNum, const MCAN_ExtMsgIDFilterElement *elem)

    This API is used to add Extended Message ID Filter Element.

    Return

      None.

    Parameters

      - `baseAddr`: Base Address of the MCAN Registers.

      - `filtNum`: Filter number.

      - `elem`: Filter Object. Refer struct MCAN_ExtMsgIDFilterElement.

  void `MCAN_lpbkModeEnable`(uint32_t baseAddr, uint32_t lpbkMode, uint32_t enable)

    This API will enable/disable Loop Back Test Mode for MCAN module.

    Return

      None.

    Note

      This API can be called only when MCAN is in Software Initialization mode of operation.

    Parameters

      - `baseAddr`: Base Address of the MCAN Registers.

      - `lpbkMode`: Loopback mode for MCAN. Refer #enum MCAN_LpbkMode.

      - `enable`: Loop Back Mode is enabled if it is TRUE. Loop Back Mode is disabled if it is FALSE.

  void `MCAN_getErrCounters`(uint32_t baseAddr, MCAN_ErrCntStatus *errCounter)

    This API will return error counter status for MCAN module.

    Return

      None.

    Parameters

      - `baseAddr`: Base Address of the MCAN Registers.

      - `errCounter`: Error Counter Status. Refer struct MCAN_ErrCntStatus.

  void `MCAN_getProtocolStatus`(uint32_t baseAddr, MCAN_ProtocolStatus *protStatus)

    This API will return protocol status for MCAN module.

    Return

      None.

    Parameters

      - `baseAddr`: Base Address of the MCAN Registers.

      - `protStatus`: Protocol Status. Refer struct MCAN_ProtocolStatus.

  void `MCAN_enableIntr`(uint32_t baseAddr, uint32_t intrMask, uint32_t enable)

    This API is used to enable/disable interrupts.

    Return

      None.

    Parameters

      - `baseAddr`: Base Address of the MCAN Registers.

      - `intrMask`: Interrupts to enable. Refer enum MCAN_IntrSrc.

      - `enable`: Interrupt is enabled if it is TRUE. Interrupt is disabled if it is FALSE.

  void `MCAN_selectIntrLine`(uint32_t baseAddr, uint32_t intrMask, uint32_t lineNum)

    This API is used to select interrupt line.

    Return

      None.

    Parameters

      - `baseAddr`: Base Address of the MCAN Registers.

      - `intrMask`: Interrupt Number for which interrupt line is to be selected. Refer enum MCAN_IntrSrc.

      - `lineNum`: Interrupt Line to select. Refer enum MCAN_IntrLineNum,

  uint32_t `MCAN_getIntrLineSelectStatus`(uint32_t baseAddr)

    This API is used to get interrupt line selected for each interrupt.

    Return

      status Interrupt Line Select Status.

    Parameters

      - `baseAddr`: Base Address of the MCAN Registers.

  void `MCAN_enableIntrLine`(uint32_t baseAddr, uint32_t lineNum, uint32_t enable)

    This API is used to enable/disable selected interrupt line.

    Return

      None.

    Parameters

      - `baseAddr`: Base Address of the MCAN Registers.

      - `lineNum`: Interrupt Line to select. Refer enum MCAN_IntrLineNum,

      - `enable`: Interrupt Line is enabled if it is 1. Interrupt Line is disabled if it is 0.

  uint32_t `MCAN_getIntrStatus`(uint32_t baseAddr)

    This API will return interrupt status.

    Return

      status Interrupt Status.

    Parameters

      - `baseAddr`: Base Address of the MCAN Registers.

  void `MCAN_clearIntrStatus`(uint32_t baseAddr, uint32_t intrMask)

    This API is used to clear the interrupt status.

    Return

      None.

    Parameters

      - `baseAddr`: Base Address of the MCAN Registers.

      - `intrMask`: Interrupts to clear status.

  void `MCAN_clearInterrupt`(uint32_t baseAddr, uint16_t intrNum)

    This API is used to clear the interrupt.

    Return

      None.

    Parameters

      - `baseAddr`: Base Address of the MCAN Registers.

      - `intrMask`: Interrupts to clear. 0x00 External TS Interrupt is cleared 0x01 Interrupt Line 0 is cleared 0x02 Interrupt Line 1 is cleared Other writes are ignored

  void `MCAN_getHighPriorityMsgStatus`(uint32_t baseAddr, MCAN_HighPriorityMsgInfo *hpm)

    This API will return High Priority Message Status.

    Return

      None.

    Parameters

      - `baseAddr`: Base Address of the MCAN Registers.

      - `hpm`: High Priority Message Status. Refer struct MCAN_HighPriorityMsgInfo.

  void `MCAN_readHighPriorityMsgRam`(uint32_t baseAddr, MCAN_RxBufElement *elem)

    This API will read the High Priority message object from Message RAM.

    Return

      None.

    Parameters

      - `baseAddr`: Base Address of the MCAN Registers.

      - `elem`: Message Object. Refer struct MCAN_RxBufElement.

  void `MCAN_getRxFIFOStatus`(uint32_t baseAddr, MCAN_RxFIFOStatus *fifoStatus)

    This API will Rx FIFO status.

    Return

      None.

    Parameters

      - `baseAddr`: Base Address of the MCAN Registers.

      - `fifoStatus`: Rx FIFO Status. Refer struct MCAN_RxFIFOStatus.

  int32_t `MCAN_writeRxFIFOAck`(uint32_t baseAddr, uint32_t fifoNum, uint32_t idx)

    This API will write Rx FIFO Acknowledgement.

    Return

      status Acknowledgement Status.

    Parameters

      - `baseAddr`: Base Address of the MCAN Registers. Refer enum MCAN_RxFIFONum.

      - `fifoNum`: FIFO Number.

      - `idx`: Rx FIFO Acknowledge Index

  void `MCAN_getTxFIFOQueStatus`(uint32_t baseAddr, MCAN_TxFIFOStatus *fifoStatus)

    This API will Tx FIFO status.

    Return

      None.

    Parameters

      - `baseAddr`: Base Address of the MCAN Registers.

      - `fifoStatus`: Tx FIFO Status. Refer struct MCAN_TxFIFOStatus.

  uint32_t `MCAN_getTxBufReqPend`(uint32_t baseAddr)

    This API will return Tx Buffer Request Pending status.

    Return

      status Tx Buffer Request Pending status.

    Parameters

      - `baseAddr`: Base Address of the MCAN Registers.

  int32_t `MCAN_txBufCancellationReq`(uint32_t baseAddr, uint32_t buffNum)

    This API will set Tx Buffer Cancellation Request.

    Return

      status Configuration Status.

    Parameters

      - `baseAddr`: Base Address of the MCAN Registers.

      - `buffNum`: Tx Buffer number for which request is to be added.

  uint32_t `MCAN_getTxBufTransmissionStatus`(uint32_t baseAddr)

    This API will return Tx Buffer Transmission Occurred status.

    Return

      status Tx Buffer Transmission Occurred status.

    Parameters

      - `baseAddr`: Base Address of the MCAN Registers.

  uint32_t `MCAN_txBufCancellationStatus`(uint32_t baseAddr)

    This API will return Transmit Buffer Cancellation Finished status.

    Return

      status Transmit Buffer Cancellation Finished status.

    Parameters

      - `baseAddr`: Base Address of the MCAN Registers.

  int32_t `MCAN_txBufTransIntrEnable`(uint32_t baseAddr, uint32_t bufNum, uint32_t enable)

    This API is used to enable/disable Tx Buffer Transmission Interrupt.

    Return

      status Configuration status.

    Parameters

      - `baseAddr`: Base Address of the MCAN Registers.

      - `bufNum`: Buffer number for which interrupt is to enable.

      - `enable`: Interrupt is enabled if it is TRUE. Interrupt is disabled if it is FALSE.

  int32_t `MCAN_getTxBufCancellationIntrEnable`(uint32_t baseAddr, uint32_t bufNum, uint32_t enable)

    This API is used to enable/disable Tx Buffer Cancellation Finished Interrupt.

    Return

      status Configuration status.

    Parameters

      - `baseAddr`: Base Address of the MCAN Registers.

      - `bufNum`: Buffer number for which interrupt is to enable.

      - `enable`: Interrupt is enabled if it is TRUE. Interrupt is disabled if it is FALSE.

  void `MCAN_addClockStopRequest`(uint32_t baseAddr, uint32_t enable)

    This API add clock stop request for MCAN module to put it in power down mode.

    Return

      None.

    Parameters

      - `baseAddr`: Base Address of the MCAN Registers.

      - `enable`: Add CLock Stop Request. Adds Clock Clock stop Request is TRUE otherwise removes it.

  void `MCAN_getTxEventFIFOStatus`(uint32_t baseAddr, MCAN_TxEventFIFOStatus *fifoStatus)

    This API will Tx Event FIFO status.

    Return

      None.

    Parameters

      - `baseAddr`: Base Address of the MCAN Registers.

      - `fifoStatus`: Tx Event FIFO Status. Refer struct MCAN_TxEventFIFOStatus.

  int32_t `MCAN_writeTxEventFIFOAck`(uint32_t baseAddr, uint32_t idx)

    This API will write Event FIFO Acknowledge Index.

    Return

      status Acknowledgement Status.

    Parameters

      - `baseAddr`: Base Address of the MCAN Registers.

      - `idx`: Event FIFO Acknowledge Index

  void `MCAN_eccForceError`(uint32_t baseAddr, const MCAN_ECCErrForceParams *eccErr)

    This API will Force Error on ECC.

    Return

      status configuration status.

    Parameters

      - `baseAddr`: Base Address of the MCAN Registers.

      - `eccErr`: Force Error on ECC configuration. Refer struct MCAN_ECCErrForceParams.

  void `MCAN_eccGetErrorStatus`(uint32_t baseAddr, MCAN_ECCErrStatus *eccErr)

    This API will return ECC Error status.

    Return

      None.

    Parameters

      - `baseAddr`: Base Address of the MCAN Registers.

      - `eccErr`: ECC error status. Refer struct MCAN_ECCErrStatus.

  void `MCAN_eccClearErrorStatus`(uint32_t baseAddr, uint32_t errType)

    This API is used to clear the ECC Error status.

    Return

      None.

    Parameters

      - `baseAddr`: Base Address of the MCAN Registers.

      - `errType`: Error type to clear status. Refer enum MCAN_ECCErrType.

  void `MCAN_eccWriteEOI`(uint32_t baseAddr, uint32_t errType)

    This API is used to write End of Interrupt for ECC interrupt.

    Return

      None.

    Parameters

      - `baseAddr`: Base Address of the MCAN Registers.

      - `errType`: Interrupt to enable. Refer enum MCAN_ECCErrType.

  void `MCAN_eccEnableIntr`(uint32_t baseAddr, uint32_t errType, uint32_t enable)

    This API is used to enable ECC interrupt.

    Return

      None.

    Parameters

      - `baseAddr`: Base Address of the MCAN Registers.

      - `errType`: Interrupt to enable. Refer enum MCAN_ECCErrType.

      - `enable`: ECC Interrupt is enabled if it is TRUE. ECC Interrupt is disabled if it is FALSE.

  uint32_t `MCAN_eccGetIntrStatus`(uint32_t baseAddr, uint32_t errType)

    This API is used to get ECC interrupt status.

    Return

      None.

    Parameters

      - `baseAddr`: Base Address of the MCAN Registers.

      - `errType`: Interrupt status to read. Refer enum MCAN_ECCErrType.

  void `MCAN_eccClearIntrStatus`(uint32_t baseAddr, uint32_t errType)

    This API is used to clear ECC interrupt status.

    Return

      None.

    Parameters

      - `baseAddr`: Base Address of the MCAN Registers.

      - `errType`: Interrupt status to clear. Refer enum MCAN_ECCErrType.

  void `MCAN_extTSCounterConfig`(uint32_t baseAddr, uint32_t prescalar)

    This API will configure external timestamp counter for MCAN module.

    Return

      None.

    Note

      Actual value programmed prescalar values is (prescalar - 1).

    Parameters

      - `baseAddr`: Base Address of the MCAN Registers.

      - `prescalar`: Timestamp Counter Prescaler. Range:[0x0-0xFFFFFF]

  void `MCAN_extTSCounterEnable`(uint32_t baseAddr, uint32_t enable)

    This API will enable/disable fast external time stamp counter for MCAN module.

    Return

      None.

    Parameters

      - `baseAddr`: Base Address of the MCAN Registers.

      - `enable`: External TS is enabled if it is 1. External TS is disabled if it is 0.

  void `MCAN_extTSEnableIntr`(uint32_t baseAddr, uint32_t enable)

    This API will enable/disable External TimeStamp Counter Overflow Interrupt for MCAN module.

    Return

      None.

    Parameters

      - `baseAddr`: Base Address of the MCAN Registers.

      - `enable`: External TimeStamp Counter Overflow Interrupt is enabled if it is TRUE. External TimeStamp Counter Overflow Interrupt is disabled if it is FALSE.

  void `MCAN_extTSWriteEOI`(uint32_t baseAddr)

    This API is used to write End of Interrupt for External TimeStamp Counter Overflow Interrupt.

    Return

      None.

    Parameters

      - `baseAddr`: Base Address of the MCAN Registers.

  uint32_t `MCAN_extTSGetUnservicedIntrCount`(uint32_t baseAddr)

    This API returns Number of unserviced rollover/overflow interrupts for external TimeStamp counter.

    Return

      status Returns Number of unserviced rollover/overflow interrupts for external TimeStamp counter. Maximum number of unserviced interrupts is 0xF.

    Parameters

      - `baseAddr`: Base Address of the MCAN Registers.

  void `MCAN_getRevisionId`(uint32_t baseAddr, MCAN_RevisionId *revId)

    This API is check the MCAN base address.

    This API is used get the MCAN revision ID.

    Return

      Returns true if base address is valid, otherwise false

    Parameters

      - `baseAddr`: Base Address of the MCAN Registers.

    Return

      None.

    Parameters

      - `baseAddr`: Base Address of the MCAN Registers.

      - `revId`: Contains Revision ID of MCAN module. Refer struct MCAN_RevisionId.

  uint32_t `MCAN_getClockStopAck`(uint32_t baseAddr)

    This API get clock stop acknowledgement for MCAN module. It return whether MCAN is power down mode or not.

    Return

      status Return Clock Stop Acknowledgement status. Return ‘1’ if M_CAN is set in power down mode else returns ‘0’.

    Parameters

      - `baseAddr`: Base Address of the MCAN Registers.

  void `MCAN_extTSSetRawStatus`(uint32_t baseAddr)

    This API will set External TimeStamp Counter Overflow Interrupt Raw status for MCAN module.

    Return

      None.

    Parameters

      - `baseAddr`: Base Address of the MCAN Registers.

  void `MCAN_extTSClearRawStatus`(uint32_t baseAddr)

    This API will clear External TimeStamp Counter Overflow Interrupt raw status for MCAN module.

    Return

      None.

    Parameters

      - `baseAddr`: Base Address of the MCAN Registers.

  uint32_t `MCAN_getRxPinState`(uint32_t baseAddr)

    This API will return Rx pin state of MCAN module.

    Return

      state MCAN Rx Pin State. 0= The CAN bus is dominant 1= The CAN bus is recessive

    Parameters

      - `baseAddr`: Base Address of the MCAN Registers.

  void `MCAN_setTxPinState`(uint32_t baseAddr, uint32_t state)

    This API will set Tx pin state of MCAN module.

    Return

      None.

    Parameters

      - `baseAddr`: Base Address of the MCAN Registers.

      - `state`: MCAN Tx Pin State. 00= Reset value 01= Sample Point can be monitored at tx pin 10= The CAN bus is dominant 11= The CAN bus is recessive other= It will treated as 11.

  uint32_t `MCAN_getTxPinState`(uint32_t baseAddr)

    This API will return Tx pin state of MCAN module.

    Return

      state MCAN Tx Pin State. 00= Reset value 01= Sample Point can be monitored at tx pin 10= The CAN bus is dominant 11= The CAN bus is recessive

    Parameters

      - `baseAddr`: Base Address of the MCAN Registers.

  uint32_t `MCAN_getTSCounterVal`(uint32_t baseAddr)

    This API will return current timestamp counter value.

    Return

      val Current Timestamp counter value.

    Parameters

      - `baseAddr`: Base Address of the MCAN Registers.

  uint32_t `MCAN_getClkStopAck`(uint32_t baseAddr)

    This API will return clock stop acknowledgement for MCAN module.

    Return

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

    Parameters

      - `baseAddr`: Base Address of the MCAN Registers.

  void `MCAN_getBitTime`(uint32_t baseAddr, MCAN_BitTimingParams *configParams)

    This API will get the configured bit timings for MCAN module.

    Return

      None.

    Parameters

      - `baseAddr`: Base Address of the MCAN Registers.

      - `configParams`: Configuration parameters for MCAN bit timing. Refer struct MCAN_BitTimingParams.

  void `MCAN_resetTSCounter`(uint32_t baseAddr)

    This API will reset timestamp counter value.

    Return

      None.

    Parameters

      - `baseAddr`: Base Address of the MCAN Registers.

  uint32_t `MCAN_getTOCounterVal`(uint32_t baseAddr)

    This API will return current time-out counter value.

    Return

      val Current Time-out counter value.

    Parameters

      - `baseAddr`: Base Address of the MCAN Registers.

  void `MCAN_eccAggrGetRevisionId`(uint32_t baseAddr, MCAN_ECCAggrRevisionId *revId)

    This API is used get the ECC AGGR revision ID.

    Return

      None.

    Parameters

      - `baseAddr`: Base Address of the MCAN Registers.

      - `revId`: Contains Revision ID of ECC AGGR. Refer struct MCAN_ECCAggrRevisionId.

  void `MCAN_eccWrapGetRevisionId`(uint32_t baseAddr, MCAN_ECCWrapRevisionId *revId)

    This API is used get the ECC Wrapper revision ID.

    Return

      None.

    Parameters

      - `baseAddr`: Base Address of the MCAN Registers.

      - `revId`: Contains Revision ID of ECC Wrapper Refer struct MCAN_ECCWrapRevisionId.

  uint32_t `MCAN_extTSIsIntrEnable`(uint32_t baseAddr)

    This API returns External TimeStamp Counter Overflow Interrupt enable status for MCAN module.

    Return

      status Returns TRUE if External TimeStamp Counter Overflow Interrupt is enabled. Else returns FALSE.

    Parameters

      - `baseAddr`: Base Address of the MCAN Registers.

  uint32_t `MCAN_getEndianVal`(uint32_t baseAddr)

    This function return endianness value of MCAN module.

    Parameters

      - `baseAddr`: Base Address of the MCAN Registers.

    Return Value

      - `val`: Endianness value. (0x87654321)

  uint32_t `MCAN_getExtIDANDMask`(uint32_t baseAddr)

    This API will get the configured Extended ID AND Mask.

    Return

      idMask Extended ID AND Mask.

    Parameters

      - `baseAddr`: Base Address of the MCAN Registers.

  uint32_t `MCAN_getMsgObjSize`(uint32_t elemSize)

    This API will return message object size.

    Return

      message object size Size of the message object stored in Message RAM.

    Parameters

      - `elemSize`: Element Size.

  struct `MCAN_BitTimingParams`
    #include <mcan.h>

    Structure for bit timing calculation. Bit timing related to data phase will be valid only in case where MCAN is put in CAN-FD mode and will be ‘0’ otherwise.

  struct `MCAN_TDCConfig`
    #include <mcan.h>

    Structure for MCAN Transmitter Delay Compensation parameters.

  struct `MCAN_GlobalFiltConfig`
    #include <mcan.h>

    Structure for MCAN Global Filter Configuration parameters.

  struct `MCAN_InitParams`
    #include <mcan.h>

    Structure for MCAN initialization parameters.

  struct `MCAN_ConfigParams`
    #include <mcan.h>

    Structure for MCAN configuration parameters.

  struct `MCAN_ErrCntStatus`
    #include <mcan.h>

    Structure for MCAN error logging counters status.

  struct `MCAN_ProtocolStatus`
    #include <mcan.h>

    Structure for MCAN protocol status.

  struct `MCAN_MsgRAMConfigParams`
    #include <mcan.h>

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

  struct `MCAN_HighPriorityMsgInfo`
    #include <mcan.h>

    Structure for MCAN High Priority Message.

  struct `MCAN_RxNewDataStatus`
    #include <mcan.h>

    Structure for MCAN new data flag for Rx buffer.

  struct `MCAN_RxFIFOStatus`
    #include <mcan.h>

    Structure for MCAN Rx FIFO Status.

  struct `MCAN_TxFIFOStatus`
    #include <mcan.h>

    Structure for MCAN Tx FIFO Status.

  struct `MCAN_TxEventFIFOStatus`
    #include <mcan.h>

    Structure for MCAN Tx Event FIFO Status.

  struct `MCAN_ECCErrForceParams`
    #include <mcan.h>

    Structure for ECC Error forcing.

  struct `MCAN_ECCErrStatus`
    #include <mcan.h>

    Structure for ECC Error Status.

  struct `MCAN_RevisionId`
    #include <mcan.h>

    Structure for accessing Revision ID and Core Release Info. of MCAN module.

  struct `MCAN_ECCAggrRevisionId`
    #include <mcan.h>

    Structure for accessing Revision ID of ECC AGGR.

  struct `MCAN_ECCConfigParams`
    #include <mcan.h>

    Structure for MCAN ECC configuration parameters.

  struct `MCAN_ECCWrapRevisionId`
    #include <mcan.h>

    Structure for accessing Revision ID of ECC wrapper.

  struct `MCAN_TxBufElement`
    #include <mcan.h>

    Structure for MCAN Tx Buffer element.

  struct `MCAN_RxBufElement`
    #include <mcan.h>

    Structure for MCAN Rx Buffer element.

  struct `MCAN_TxEventFIFOElement`
    #include <mcan.h>

    Structure for MCAN Tx Event FIFO element.

  struct `MCAN_StdMsgIDFilterElement`
    #include <mcan.h>

    Structure for MCAN Standard Message ID Filter Element.

  struct `MCAN_ExtMsgIDFilterElement`
    #include <mcan.h>

    Structure for MCAN Extended Message ID Filter Element.

The following describes important details and recommendations when using the MCAN API.

Once system control enables the MCAN module, MCAN_setOpMode() needs to be called to put the controller in SW initialization mode. The MCAN_init() intializes the CAN Controller and MCAN_config() configures the CAN Module which sets the MCAN bit timing values for the bit rate and timing parameters. For tighter timing requirements, use MCAN_setBitTime() and to configure the Message RAM use the API MCAN_msgRAMConfig.

Once all of the module configurations are setup, MCAN_setOpMode() starts the MCAN module’s operations and disables access to the configuration registers.

The code for this module is contained in driverlib/mcan.c, with driverlib/mcan.h containing the API declarations for use by applications.