MCUXpresso SDK API Reference Manual  Rev 2.16.000
NXP Semiconductors
 All Data Structures Functions Variables Typedefs Enumerations Enumerator Groups Pages
MCAN: Controller Area Network Driver

Overview

The MCUXpresso SDK provides a peripheral driver for the Controller Area Network (MCAN) module of MCUXpresso SDK devices.

Data Structures

struct  _mcan_tx_buffer_frame
 MCAN Tx Buffer structure. More...
 
struct  _mcan_rx_buffer_frame
 MCAN Rx FIFO/Buffer structure. More...
 
struct  _mcan_rx_fifo_config
 MCAN Rx FIFO configuration. More...
 
struct  _mcan_rx_buffer_config
 MCAN Rx Buffer configuration. More...
 
struct  _mcan_tx_fifo_config
 MCAN Tx Event FIFO configuration. More...
 
struct  _mcan_tx_buffer_config
 MCAN Tx Buffer configuration. More...
 
struct  _mcan_std_filter_element_config
 MCAN Standard Message ID Filter Element. More...
 
struct  _mcan_ext_filter_element_config
 MCAN Extended Message ID Filter Element. More...
 
struct  _mcan_frame_filter_config
 MCAN Rx filter configuration. More...
 
struct  _mcan_timing_config
 MCAN protocol timing characteristic configuration structure. More...
 
struct  _mcan_timing_param
 MCAN bit timing parameter configuration structure. More...
 
struct  _mcan_memory_config
 MCAN Message RAM related configuration structure. More...
 
struct  _mcan_config
 MCAN module configuration structure. More...
 
struct  _mcan_buffer_transfer
 MCAN Buffer transfer. More...
 
struct  _mcan_fifo_transfer
 MCAN Rx FIFO transfer. More...
 
struct  _mcan_handle
 MCAN handle structure. More...
 

Typedefs

typedef enum _mcan_frame_idformat mcan_frame_idformat_t
 MCAN frame format. More...
 
typedef enum _mcan_frame_type mcan_frame_type_t
 MCAN frame type. More...
 
typedef enum
_mcan_bytes_in_datafield 
mcan_bytes_in_datafield_t
 MCAN frame datafield size. More...
 
typedef struct
_mcan_tx_buffer_frame 
mcan_tx_buffer_frame_t
 MCAN Tx Buffer structure. More...
 
typedef struct
_mcan_rx_buffer_frame 
mcan_rx_buffer_frame_t
 MCAN Rx FIFO/Buffer structure. More...
 
typedef enum _mcan_fifo_type mcan_fifo_type_t
 MCAN Rx FIFO block number. More...
 
typedef enum
_mcan_fifo_opmode_config 
mcan_fifo_opmode_config_t
 MCAN FIFO Operation Mode. More...
 
typedef enum _mcan_txmode_config mcan_txmode_config_t
 MCAN Tx FIFO/Queue Mode. More...
 
typedef enum
_mcan_remote_frame_config 
mcan_remote_frame_config_t
 MCAN remote frames treatment. More...
 
typedef enum
_mcan_nonmasking_frame_config 
mcan_nonmasking_frame_config_t
 MCAN non-masking frames treatment. More...
 
typedef enum _mcan_fec_config mcan_fec_config_t
 MCAN Filter Element Configuration. More...
 
typedef struct _mcan_rx_fifo_config mcan_rx_fifo_config_t
 MCAN Rx FIFO configuration. More...
 
typedef struct
_mcan_rx_buffer_config 
mcan_rx_buffer_config_t
 MCAN Rx Buffer configuration. More...
 
typedef struct _mcan_tx_fifo_config mcan_tx_fifo_config_t
 MCAN Tx Event FIFO configuration. More...
 
typedef struct
_mcan_tx_buffer_config 
mcan_tx_buffer_config_t
 MCAN Tx Buffer configuration. More...
 
typedef enum _mcan_std_filter_type mcan_filter_type_t
 MCAN Filter Type. More...
 
typedef struct
_mcan_std_filter_element_config 
mcan_std_filter_element_config_t
 MCAN Standard Message ID Filter Element. More...
 
typedef struct
_mcan_ext_filter_element_config 
mcan_ext_filter_element_config_t
 MCAN Extended Message ID Filter Element. More...
 
typedef struct
_mcan_frame_filter_config 
mcan_frame_filter_config_t
 MCAN Rx filter configuration. More...
 
typedef struct _mcan_timing_config mcan_timing_config_t
 MCAN protocol timing characteristic configuration structure. More...
 
typedef struct _mcan_timing_param mcan_timing_param_t
 MCAN bit timing parameter configuration structure. More...
 
typedef struct _mcan_memory_config mcan_memory_config_t
 MCAN Message RAM related configuration structure. More...
 
typedef struct _mcan_config mcan_config_t
 MCAN module configuration structure. More...
 
typedef struct
_mcan_buffer_transfer 
mcan_buffer_transfer_t
 MCAN Buffer transfer. More...
 
typedef struct _mcan_fifo_transfer mcan_fifo_transfer_t
 MCAN Rx FIFO transfer. More...
 
typedef struct _mcan_handle mcan_handle_t
 MCAN handle structure definition. More...
 
typedef void(* mcan_transfer_callback_t )(CAN_Type *base, mcan_handle_t *handle, status_t status, uint32_t result, void *userData)
 MCAN transfer callback function. More...
 

Enumerations

enum  {
  kStatus_MCAN_TxBusy = MAKE_STATUS(kStatusGroup_MCAN, 0),
  kStatus_MCAN_TxIdle = MAKE_STATUS(kStatusGroup_MCAN, 1),
  kStatus_MCAN_RxBusy = MAKE_STATUS(kStatusGroup_MCAN, 2),
  kStatus_MCAN_RxIdle = MAKE_STATUS(kStatusGroup_MCAN, 3),
  kStatus_MCAN_RxFifo0New = MAKE_STATUS(kStatusGroup_MCAN, 4),
  kStatus_MCAN_RxFifo0Idle = MAKE_STATUS(kStatusGroup_MCAN, 5),
  kStatus_MCAN_RxFifo0Watermark = MAKE_STATUS(kStatusGroup_MCAN, 6),
  kStatus_MCAN_RxFifo0Full = MAKE_STATUS(kStatusGroup_MCAN, 7),
  kStatus_MCAN_RxFifo0Lost = MAKE_STATUS(kStatusGroup_MCAN, 8),
  kStatus_MCAN_RxFifo1New = MAKE_STATUS(kStatusGroup_MCAN, 9),
  kStatus_MCAN_RxFifo1Idle = MAKE_STATUS(kStatusGroup_MCAN, 10),
  kStatus_MCAN_RxFifo1Watermark = MAKE_STATUS(kStatusGroup_MCAN, 11),
  kStatus_MCAN_RxFifo1Full = MAKE_STATUS(kStatusGroup_MCAN, 12),
  kStatus_MCAN_RxFifo1Lost = MAKE_STATUS(kStatusGroup_MCAN, 13),
  kStatus_MCAN_RxFifo0Busy = MAKE_STATUS(kStatusGroup_MCAN, 14),
  kStatus_MCAN_RxFifo1Busy = MAKE_STATUS(kStatusGroup_MCAN, 15),
  kStatus_MCAN_ErrorStatus = MAKE_STATUS(kStatusGroup_MCAN, 16),
  kStatus_MCAN_UnHandled = MAKE_STATUS(kStatusGroup_MCAN, 17)
}
 MCAN transfer status. More...
 
enum  _mcan_flags {
  kMCAN_AccesstoRsvdFlag = CAN_IR_ARA_MASK,
  kMCAN_ProtocolErrDIntFlag = CAN_IR_PED_MASK,
  kMCAN_ProtocolErrAIntFlag = CAN_IR_PEA_MASK,
  kMCAN_BusOffIntFlag = CAN_IR_BO_MASK,
  kMCAN_ErrorWarningIntFlag = CAN_IR_EW_MASK,
  kMCAN_ErrorPassiveIntFlag = CAN_IR_EP_MASK
}
 MCAN status flags. More...
 
enum  _mcan_rx_fifo_flags {
  kMCAN_RxFifo0NewFlag = CAN_IR_RF0N_MASK,
  kMCAN_RxFifo0WatermarkFlag = CAN_IR_RF0W_MASK,
  kMCAN_RxFifo0FullFlag = CAN_IR_RF0F_MASK,
  kMCAN_RxFifo0LostFlag = CAN_IR_RF0L_MASK,
  kMCAN_RxFifo1NewFlag = CAN_IR_RF1N_MASK,
  kMCAN_RxFifo1WatermarkFlag = CAN_IR_RF1W_MASK,
  kMCAN_RxFifo1FullFlag = CAN_IR_RF1F_MASK,
  kMCAN_RxFifo1LostFlag = CAN_IR_RF1L_MASK
}
 MCAN Rx FIFO status flags. More...
 
enum  _mcan_tx_flags {
  kMCAN_TxTransmitCompleteFlag = CAN_IR_TC_MASK,
  kMCAN_TxTransmitCancelFinishFlag = CAN_IR_TCF_MASK,
  kMCAN_TxEventFifoLostFlag = CAN_IR_TEFL_MASK,
  kMCAN_TxEventFifoFullFlag = CAN_IR_TEFF_MASK,
  kMCAN_TxEventFifoWatermarkFlag = CAN_IR_TEFW_MASK,
  kMCAN_TxEventFifoNewFlag = CAN_IR_TEFN_MASK,
  kMCAN_TxEventFifoEmptyFlag = CAN_IR_TFE_MASK
}
 MCAN Tx status flags. More...
 
enum  _mcan_interrupt_enable {
  kMCAN_BusOffInterruptEnable = CAN_IE_BOE_MASK,
  kMCAN_ErrorInterruptEnable = CAN_IE_EPE_MASK,
  kMCAN_WarningInterruptEnable = CAN_IE_EWE_MASK
}
 MCAN interrupt configuration structure, default settings all disabled. More...
 
enum  _mcan_frame_idformat {
  kMCAN_FrameIDStandard = 0x0U,
  kMCAN_FrameIDExtend = 0x1U
}
 MCAN frame format. More...
 
enum  _mcan_frame_type {
  kMCAN_FrameTypeData = 0x0U,
  kMCAN_FrameTypeRemote = 0x1U
}
 MCAN frame type. More...
 
enum  _mcan_bytes_in_datafield {
  kMCAN_8ByteDatafield = 0x0U,
  kMCAN_12ByteDatafield = 0x1U,
  kMCAN_16ByteDatafield = 0x2U,
  kMCAN_20ByteDatafield = 0x3U,
  kMCAN_24ByteDatafield = 0x4U,
  kMCAN_32ByteDatafield = 0x5U,
  kMCAN_48ByteDatafield = 0x6U,
  kMCAN_64ByteDatafield = 0x7U
}
 MCAN frame datafield size. More...
 
enum  _mcan_fifo_type {
  kMCAN_Fifo0 = 0x0U,
  kMCAN_Fifo1 = 0x1U
}
 MCAN Rx FIFO block number. More...
 
enum  _mcan_fifo_opmode_config {
  kMCAN_FifoBlocking = 0x0U,
  kMCAN_FifoOverwrite = 0x1U
}
 MCAN FIFO Operation Mode. More...
 
enum  _mcan_txmode_config {
  kMCAN_txFifo = 0x0U,
  kMCAN_txQueue = 0x1U
}
 MCAN Tx FIFO/Queue Mode. More...
 
enum  _mcan_remote_frame_config {
  kMCAN_filterFrame = 0x0U,
  kMCAN_rejectFrame = 0x1U
}
 MCAN remote frames treatment. More...
 
enum  _mcan_nonmasking_frame_config {
  kMCAN_acceptinFifo0 = 0x0U,
  kMCAN_acceptinFifo1 = 0x1U,
  kMCAN_reject0 = 0x2U,
  kMCAN_reject1 = 0x3U
}
 MCAN non-masking frames treatment. More...
 
enum  _mcan_fec_config {
  kMCAN_disable = 0x0U,
  kMCAN_storeinFifo0 = 0x1U,
  kMCAN_storeinFifo1 = 0x2U,
  kMCAN_reject = 0x3U,
  kMCAN_setprio = 0x4U,
  kMCAN_setpriofifo0 = 0x5U,
  kMCAN_setpriofifo1 = 0x6U,
  kMCAN_storeinbuffer = 0x7U
}
 MCAN Filter Element Configuration. More...
 
enum  _mcan_std_filter_type {
  kMCAN_range = 0x0U,
  kMCAN_dual = 0x1U,
  kMCAN_classic = 0x2U,
  kMCAN_disableORrange2 = 0x3U
}
 MCAN Filter Type. More...
 

Driver version

#define FSL_MCAN_DRIVER_VERSION   (MAKE_VERSION(2, 4, 2))
 MCAN driver version. More...
 

Initialization and deinitialization

void MCAN_Init (CAN_Type *base, const mcan_config_t *config, uint32_t sourceClock_Hz)
 Initializes an MCAN instance. More...
 
void MCAN_Deinit (CAN_Type *base)
 Deinitializes an MCAN instance. More...
 
void MCAN_GetDefaultConfig (mcan_config_t *config)
 Gets the default configuration structure. More...
 
static void MCAN_EnterInitialMode (CAN_Type *base)
 MCAN enters initialization mode. More...
 
static void MCAN_EnterNormalMode (CAN_Type *base)
 MCAN enters normal mode. More...
 

Configuration.

static void MCAN_SetMsgRAMBase (CAN_Type *base, uint32_t value)
 Sets the MCAN Message RAM base address. More...
 
static uint32_t MCAN_GetMsgRAMBase (CAN_Type *base)
 Gets the MCAN Message RAM base address. More...
 
bool MCAN_CalculateImprovedTimingValues (uint32_t baudRate, uint32_t sourceClock_Hz, mcan_timing_config_t *pconfig)
 Calculates the improved timing values by specific baudrates for classical CAN. More...
 
bool MCAN_CalculateSpecifiedTimingValues (uint32_t sourceClock_Hz, mcan_timing_config_t *pconfig, const mcan_timing_param_t *pParamConfig)
 Calculates the specified timing values for classical CAN with user-defined settings. More...
 
void MCAN_SetArbitrationTimingConfig (CAN_Type *base, const mcan_timing_config_t *config)
 Sets the MCAN protocol arbitration phase timing characteristic. More...
 
status_t MCAN_SetBaudRate (CAN_Type *base, uint32_t sourceClock_Hz, uint32_t baudRate_Bps)
 Set Baud Rate of MCAN classic mode. More...
 
bool MCAN_FDCalculateImprovedTimingValues (uint32_t baudRate, uint32_t baudRateFD, uint32_t sourceClock_Hz, mcan_timing_config_t *pconfig)
 Calculates the improved timing values by specific baudrates for CANFD. More...
 
bool MCAN_FDCalculateSpecifiedTimingValues (uint32_t sourceClock_Hz, mcan_timing_config_t *pconfig, const mcan_timing_param_t *pParamConfig)
 Calculates the specified timing values for CANFD with user-defined settings. More...
 
status_t MCAN_SetBaudRateFD (CAN_Type *base, uint32_t sourceClock_Hz, uint32_t baudRateN_Bps, uint32_t baudRateD_Bps)
 Set Baud Rate of MCAN FD mode. More...
 
void MCAN_SetDataTimingConfig (CAN_Type *base, const mcan_timing_config_t *config)
 Sets the MCAN protocol data phase timing characteristic. More...
 
void MCAN_SetRxFifo0Config (CAN_Type *base, const mcan_rx_fifo_config_t *config)
 Configures an MCAN receive fifo 0 buffer. More...
 
void MCAN_SetRxFifo1Config (CAN_Type *base, const mcan_rx_fifo_config_t *config)
 Configures an MCAN receive fifo 1 buffer. More...
 
void MCAN_SetRxBufferConfig (CAN_Type *base, const mcan_rx_buffer_config_t *config)
 Configures an MCAN receive buffer. More...
 
void MCAN_SetTxEventFifoConfig (CAN_Type *base, const mcan_tx_fifo_config_t *config)
 Configures an MCAN transmit event fifo. More...
 
void MCAN_SetTxBufferConfig (CAN_Type *base, const mcan_tx_buffer_config_t *config)
 Configures an MCAN transmit buffer. More...
 
void MCAN_SetFilterConfig (CAN_Type *base, const mcan_frame_filter_config_t *config)
 Set filter configuration. More...
 
status_t MCAN_SetMessageRamConfig (CAN_Type *base, const mcan_memory_config_t *config)
 Set Message RAM related configuration. More...
 
void MCAN_SetSTDFilterElement (CAN_Type *base, const mcan_frame_filter_config_t *config, const mcan_std_filter_element_config_t *filter, uint8_t idx)
 Set standard message ID filter element configuration. More...
 
void MCAN_SetEXTFilterElement (CAN_Type *base, const mcan_frame_filter_config_t *config, const mcan_ext_filter_element_config_t *filter, uint8_t idx)
 Set extended message ID filter element configuration. More...
 

Status

static uint32_t MCAN_GetStatusFlag (CAN_Type *base, uint32_t mask)
 Gets the MCAN module interrupt flags. More...
 
static void MCAN_ClearStatusFlag (CAN_Type *base, uint32_t mask)
 Clears the MCAN module interrupt flags. More...
 
static bool MCAN_GetRxBufferStatusFlag (CAN_Type *base, uint8_t idx)
 Gets the new data flag of specific Rx Buffer. More...
 
static void MCAN_ClearRxBufferStatusFlag (CAN_Type *base, uint8_t idx)
 Clears the new data flag of specific Rx Buffer. More...
 

Interrupts

static void MCAN_EnableInterrupts (CAN_Type *base, uint32_t line, uint32_t mask)
 Enables MCAN interrupts according to the provided interrupt line and mask. More...
 
static void MCAN_EnableTransmitBufferInterrupts (CAN_Type *base, uint8_t idx)
 Enables MCAN Tx Buffer interrupts according to the provided index. More...
 
static void MCAN_DisableTransmitBufferInterrupts (CAN_Type *base, uint8_t idx)
 Disables MCAN Tx Buffer interrupts according to the provided index. More...
 
static void MCAN_DisableInterrupts (CAN_Type *base, uint32_t mask)
 Disables MCAN interrupts according to the provided mask. More...
 

Bus Operations

uint32_t MCAN_IsTransmitRequestPending (CAN_Type *base, uint8_t idx)
 Gets the Tx buffer request pending status. More...
 
uint32_t MCAN_IsTransmitOccurred (CAN_Type *base, uint8_t idx)
 Gets the Tx buffer transmission occurred status. More...
 
status_t MCAN_WriteTxBuffer (CAN_Type *base, uint8_t idx, const mcan_tx_buffer_frame_t *pTxFrame)
 Writes an MCAN Message to the Transmit Buffer. More...
 
status_t MCAN_ReadRxBuffer (CAN_Type *base, uint8_t idx, mcan_rx_buffer_frame_t *pRxFrame)
 Reads an MCAN Message from Rx Buffer. More...
 
status_t MCAN_ReadRxFifo (CAN_Type *base, uint8_t fifoBlock, mcan_rx_buffer_frame_t *pRxFrame)
 Reads an MCAN Message from Rx FIFO. More...
 

Transactional

static void MCAN_TransmitAddRequest (CAN_Type *base, uint8_t idx)
 Tx Buffer add request to send message out. More...
 
static void MCAN_TransmitCancelRequest (CAN_Type *base, uint8_t idx)
 Tx Buffer cancel sending request. More...
 
status_t MCAN_TransferSendBlocking (CAN_Type *base, uint8_t idx, mcan_tx_buffer_frame_t *pTxFrame)
 Performs a polling send transaction on the CAN bus. More...
 
status_t MCAN_TransferReceiveBlocking (CAN_Type *base, uint8_t idx, mcan_rx_buffer_frame_t *pRxFrame)
 Performs a polling receive transaction on the CAN bus. More...
 
status_t MCAN_TransferReceiveFifoBlocking (CAN_Type *base, uint8_t fifoBlock, mcan_rx_buffer_frame_t *pRxFrame)
 Performs a polling receive transaction from Rx FIFO on the CAN bus. More...
 
void MCAN_TransferCreateHandle (CAN_Type *base, mcan_handle_t *handle, mcan_transfer_callback_t callback, void *userData)
 Initializes the MCAN handle. More...
 
status_t MCAN_TransferSendNonBlocking (CAN_Type *base, mcan_handle_t *handle, mcan_buffer_transfer_t *xfer)
 Sends a message using IRQ. More...
 
status_t MCAN_TransferReceiveFifoNonBlocking (CAN_Type *base, uint8_t fifoBlock, mcan_handle_t *handle, mcan_fifo_transfer_t *xfer)
 Receives a message from Rx FIFO using IRQ. More...
 
void MCAN_TransferAbortSend (CAN_Type *base, mcan_handle_t *handle, uint8_t bufferIdx)
 Aborts the interrupt driven message send process. More...
 
void MCAN_TransferAbortReceiveFifo (CAN_Type *base, uint8_t fifoBlock, mcan_handle_t *handle)
 Aborts the interrupt driven message receive from Rx FIFO process. More...
 
void MCAN_TransferHandleIRQ (CAN_Type *base, mcan_handle_t *handle)
 MCAN IRQ handle function. More...
 

Data Structure Documentation

struct _mcan_tx_buffer_frame

Data Fields

uint8_t size
 classical CAN is 8(bytes), FD is 12/64 such. More...
 
uint32_t id: 29
 CAN Frame Identifier. More...
 
uint32_t rtr: 1
 CAN Frame Type(DATA or REMOTE). More...
 
uint32_t xtd: 1
 CAN Frame Type(STD or EXT). More...
 
uint32_t esi: 1
 CAN Frame Error State Indicator. More...
 
uint32_t dlc: 4
 Data Length Code 9 10 11 12 13 14 15 Number of data bytes 12 16 20 24 32 48 64.
 
uint32_t brs: 1
 Bit Rate Switch. More...
 
uint32_t fdf: 1
 CAN FD format. More...
 
uint32_t __pad1__: 1
 Reserved. More...
 
uint32_t efc: 1
 Event FIFO control. More...
 
uint32_t mm: 8
 Message Marker. More...
 

Field Documentation

uint32_t _mcan_tx_buffer_frame::id
uint32_t _mcan_tx_buffer_frame::rtr
uint32_t _mcan_tx_buffer_frame::xtd
uint32_t _mcan_tx_buffer_frame::esi
uint32_t _mcan_tx_buffer_frame::brs
uint32_t _mcan_tx_buffer_frame::fdf
uint32_t _mcan_tx_buffer_frame::__pad1__
uint32_t _mcan_tx_buffer_frame::efc
uint32_t _mcan_tx_buffer_frame::mm
uint8_t _mcan_tx_buffer_frame::size
struct _mcan_rx_buffer_frame

Data Fields

uint8_t size
 classical CAN is 8(bytes), FD is 12/64 such. More...
 
uint32_t id: 29
 CAN Frame Identifier. More...
 
uint32_t rtr: 1
 CAN Frame Type(DATA or REMOTE). More...
 
uint32_t xtd: 1
 CAN Frame Type(STD or EXT). More...
 
uint32_t esi: 1
 CAN Frame Error State Indicator. More...
 
uint32_t rxts: 16
 Rx Timestamp. More...
 
uint32_t dlc: 4
 Data Length Code 9 10 11 12 13 14 15 Number of data bytes 12 16 20 24 32 48 64.
 
uint32_t brs: 1
 Bit Rate Switch. More...
 
uint32_t fdf: 1
 CAN FD format. More...
 
uint32_t __pad0__: 2
 Reserved. More...
 
uint32_t fidx: 7
 Filter Index. More...
 
uint32_t anmf: 1
 Accepted Non-matching Frame. More...
 

Field Documentation

uint32_t _mcan_rx_buffer_frame::id
uint32_t _mcan_rx_buffer_frame::rtr
uint32_t _mcan_rx_buffer_frame::xtd
uint32_t _mcan_rx_buffer_frame::esi
uint32_t _mcan_rx_buffer_frame::rxts
uint32_t _mcan_rx_buffer_frame::brs
uint32_t _mcan_rx_buffer_frame::fdf
uint32_t _mcan_rx_buffer_frame::__pad0__
uint32_t _mcan_rx_buffer_frame::fidx
uint32_t _mcan_rx_buffer_frame::anmf
uint8_t _mcan_rx_buffer_frame::size
struct _mcan_rx_fifo_config

Data Fields

uint32_t address
 FIFOn start address. More...
 
uint32_t elementSize
 FIFOn element number. More...
 
uint32_t watermark
 FIFOn watermark level. More...
 
mcan_fifo_opmode_config_t opmode
 FIFOn blocking/overwrite mode. More...
 
mcan_bytes_in_datafield_t datafieldSize
 Data field size per frame, size>8 is for CANFD. More...
 

Field Documentation

uint32_t _mcan_rx_fifo_config::address
uint32_t _mcan_rx_fifo_config::elementSize
uint32_t _mcan_rx_fifo_config::watermark
mcan_fifo_opmode_config_t _mcan_rx_fifo_config::opmode
mcan_bytes_in_datafield_t _mcan_rx_fifo_config::datafieldSize
struct _mcan_rx_buffer_config

Data Fields

uint32_t address
 Rx Buffer start address. More...
 
mcan_bytes_in_datafield_t datafieldSize
 Data field size per frame, size>8 is for CANFD. More...
 

Field Documentation

uint32_t _mcan_rx_buffer_config::address
mcan_bytes_in_datafield_t _mcan_rx_buffer_config::datafieldSize
struct _mcan_tx_fifo_config

Data Fields

uint32_t address
 Event fifo start address. More...
 
uint32_t elementSize
 FIFOn element number. More...
 
uint32_t watermark
 FIFOn watermark level. More...
 

Field Documentation

uint32_t _mcan_tx_fifo_config::address
uint32_t _mcan_tx_fifo_config::elementSize
uint32_t _mcan_tx_fifo_config::watermark
struct _mcan_tx_buffer_config

Data Fields

uint32_t address
 Tx Buffers Start Address. More...
 
uint32_t dedicatedSize
 Number of Dedicated Transmit Buffers. More...
 
uint32_t fqSize
 Transmit FIFO/Queue Size. More...
 
mcan_txmode_config_t mode
 Tx FIFO/Queue Mode. More...
 
mcan_bytes_in_datafield_t datafieldSize
 Data field size per frame, size>8 is for CANFD. More...
 

Field Documentation

uint32_t _mcan_tx_buffer_config::address
uint32_t _mcan_tx_buffer_config::dedicatedSize
uint32_t _mcan_tx_buffer_config::fqSize
mcan_txmode_config_t _mcan_tx_buffer_config::mode
mcan_bytes_in_datafield_t _mcan_tx_buffer_config::datafieldSize
struct _mcan_std_filter_element_config

Data Fields

uint32_t sfid2: 11
 Standard Filter ID 2. More...
 
uint32_t __pad0__: 5
 Reserved. More...
 
uint32_t sfid1: 11
 Standard Filter ID 1. More...
 
uint32_t sfec: 3
 Standard Filter Element Configuration. More...
 
uint32_t sft: 2
 Standard Filter Type. More...
 

Field Documentation

uint32_t _mcan_std_filter_element_config::sfid2
uint32_t _mcan_std_filter_element_config::__pad0__
uint32_t _mcan_std_filter_element_config::sfid1
uint32_t _mcan_std_filter_element_config::sfec
uint32_t _mcan_std_filter_element_config::sft
struct _mcan_ext_filter_element_config

Data Fields

uint32_t efid1: 29
 Extended Filter ID 1. More...
 
uint32_t efec: 3
 Extended Filter Element Configuration. More...
 
uint32_t efid2: 29
 Extended Filter ID 2. More...
 
uint32_t __pad0__: 1
 Reserved. More...
 
uint32_t eft: 2
 Extended Filter Type. More...
 

Field Documentation

uint32_t _mcan_ext_filter_element_config::efid1
uint32_t _mcan_ext_filter_element_config::efec
uint32_t _mcan_ext_filter_element_config::efid2
uint32_t _mcan_ext_filter_element_config::__pad0__
uint32_t _mcan_ext_filter_element_config::eft
struct _mcan_frame_filter_config

Data Fields

uint32_t address
 Filter start address. More...
 
uint32_t listSize
 Filter list size. More...
 
mcan_frame_idformat_t idFormat
 Frame format. More...
 
mcan_remote_frame_config_t remFrame
 Remote frame treatment. More...
 
mcan_nonmasking_frame_config_t nmFrame
 Non-masking frame treatment. More...
 

Field Documentation

uint32_t _mcan_frame_filter_config::address
uint32_t _mcan_frame_filter_config::listSize
mcan_frame_idformat_t _mcan_frame_filter_config::idFormat
mcan_remote_frame_config_t _mcan_frame_filter_config::remFrame
mcan_nonmasking_frame_config_t _mcan_frame_filter_config::nmFrame
struct _mcan_timing_config

Data Fields

uint16_t preDivider
 Nominal Clock Pre-scaler Division Factor. More...
 
uint8_t rJumpwidth
 Nominal Re-sync Jump Width. More...
 
uint8_t seg1
 Nominal Time Segment 1. More...
 
uint8_t seg2
 Nominal Time Segment 2. More...
 
uint16_t datapreDivider
 Data Clock Pre-scaler Division Factor. More...
 
uint8_t datarJumpwidth
 Data Re-sync Jump Width. More...
 
uint8_t dataseg1
 Data Time Segment 1. More...
 
uint8_t dataseg2
 Data Time Segment 2. More...
 

Field Documentation

uint16_t _mcan_timing_config::preDivider
uint8_t _mcan_timing_config::rJumpwidth
uint8_t _mcan_timing_config::seg1
uint8_t _mcan_timing_config::seg2
uint16_t _mcan_timing_config::datapreDivider
uint8_t _mcan_timing_config::datarJumpwidth
uint8_t _mcan_timing_config::dataseg1
uint8_t _mcan_timing_config::dataseg2
struct _mcan_timing_param

Data Fields

uint32_t busLength
 Maximum Bus length in meter. More...
 
uint32_t propTxRx
 Transceiver propagation delay in nanosecond. More...
 
uint32_t nominalbaudRate
 Baud rate of Arbitration phase in bps. More...
 
uint32_t nominalSP
 Sample point of Arbitration phase, range in 10 ~ 990, 800 means 80%. More...
 
uint32_t databaudRate
 Baud rate of Data phase in bps. More...
 
uint32_t dataSP
 Sample point of Data phase, range in 0 ~ 1000, 800 means 80%. More...
 

Field Documentation

uint32_t _mcan_timing_param::busLength
uint32_t _mcan_timing_param::propTxRx
uint32_t _mcan_timing_param::nominalbaudRate
uint32_t _mcan_timing_param::nominalSP
uint32_t _mcan_timing_param::databaudRate
uint32_t _mcan_timing_param::dataSP
struct _mcan_memory_config

Data Fields

uint32_t baseAddr
 Message RAM base address, should be 4k alignment. More...
 

Field Documentation

uint32_t _mcan_memory_config::baseAddr
struct _mcan_config

Data Fields

uint32_t baudRateA
 Baud rate of Arbitration phase in bps. More...
 
uint32_t baudRateD
 Baud rate of Data phase in bps. More...
 
bool enableCanfdNormal
 Enable or Disable CANFD normal. More...
 
bool enableCanfdSwitch
 Enable or Disable CANFD with baudrate switch. More...
 
bool enableLoopBackInt
 Enable or Disable Internal Back. More...
 
bool enableLoopBackExt
 Enable or Disable External Loop Back. More...
 
bool enableBusMon
 Enable or Disable Bus Monitoring Mode. More...
 
mcan_timing_config_t timingConfig
 Protocol timing . More...
 

Field Documentation

uint32_t _mcan_config::baudRateA
uint32_t _mcan_config::baudRateD
bool _mcan_config::enableCanfdNormal
bool _mcan_config::enableCanfdSwitch
bool _mcan_config::enableLoopBackInt
bool _mcan_config::enableLoopBackExt
bool _mcan_config::enableBusMon
mcan_timing_config_t _mcan_config::timingConfig
struct _mcan_buffer_transfer

Data Fields

mcan_tx_buffer_frame_tframe
 The buffer of CAN Message to be transfer. More...
 
uint8_t bufferIdx
 The index of Message buffer used to transfer Message. More...
 

Field Documentation

mcan_tx_buffer_frame_t* _mcan_buffer_transfer::frame
uint8_t _mcan_buffer_transfer::bufferIdx
struct _mcan_fifo_transfer

Data Fields

mcan_rx_buffer_frame_tframe
 The buffer of CAN Message to be received from Rx FIFO. More...
 

Field Documentation

mcan_rx_buffer_frame_t* _mcan_fifo_transfer::frame
struct _mcan_handle

Data Fields

mcan_transfer_callback_t callback
 Callback function. More...
 
void * userData
 MCAN callback function parameter. More...
 
mcan_tx_buffer_frame_t *volatile bufferFrameBuf [64]
 The buffer for received data from Buffers. More...
 
mcan_rx_buffer_frame_t *volatile rxFifoFrameBuf
 The buffer for received data from Rx FIFO. More...
 
volatile uint8_t bufferState [64]
 Message Buffer transfer state. More...
 
volatile uint8_t rxFifoState
 Rx FIFO transfer state. More...
 

Field Documentation

mcan_transfer_callback_t _mcan_handle::callback
void* _mcan_handle::userData
mcan_tx_buffer_frame_t* volatile _mcan_handle::bufferFrameBuf[64]
mcan_rx_buffer_frame_t* volatile _mcan_handle::rxFifoFrameBuf
volatile uint8_t _mcan_handle::bufferState[64]
volatile uint8_t _mcan_handle::rxFifoState

Macro Definition Documentation

#define FSL_MCAN_DRIVER_VERSION   (MAKE_VERSION(2, 4, 2))

Typedef Documentation

typedef struct _mcan_config mcan_config_t
typedef struct _mcan_handle mcan_handle_t
typedef void(* mcan_transfer_callback_t)(CAN_Type *base, mcan_handle_t *handle, status_t status, uint32_t result, void *userData)

The MCAN transfer callback returns a value from the underlying layer. If the status equals to kStatus_MCAN_ErrorStatus, the result parameter is the Content of MCAN status register which can be used to get the working status(or error status) of MCAN module. If the status equals to other MCAN Message Buffer transfer status, the result is the index of Message Buffer that generate transfer event. If the status equals to other MCAN Message Buffer transfer status, the result is meaningless and should be Ignored.

Enumeration Type Documentation

anonymous enum
Enumerator
kStatus_MCAN_TxBusy 

Tx Buffer is Busy.

kStatus_MCAN_TxIdle 

Tx Buffer is Idle.

kStatus_MCAN_RxBusy 

Rx Buffer is Busy.

kStatus_MCAN_RxIdle 

Rx Buffer is Idle.

kStatus_MCAN_RxFifo0New 

New message written to Rx FIFO 0.

kStatus_MCAN_RxFifo0Idle 

Rx FIFO 0 is Idle.

kStatus_MCAN_RxFifo0Watermark 

Rx FIFO 0 fill level reached watermark.

kStatus_MCAN_RxFifo0Full 

Rx FIFO 0 full.

kStatus_MCAN_RxFifo0Lost 

Rx FIFO 0 message lost.

kStatus_MCAN_RxFifo1New 

New message written to Rx FIFO 1.

kStatus_MCAN_RxFifo1Idle 

Rx FIFO 1 is Idle.

kStatus_MCAN_RxFifo1Watermark 

Rx FIFO 1 fill level reached watermark.

kStatus_MCAN_RxFifo1Full 

Rx FIFO 1 full.

kStatus_MCAN_RxFifo1Lost 

Rx FIFO 1 message lost.

kStatus_MCAN_RxFifo0Busy 

Rx FIFO 0 is busy.

kStatus_MCAN_RxFifo1Busy 

Rx FIFO 1 is busy.

kStatus_MCAN_ErrorStatus 

MCAN Module Error and Status.

kStatus_MCAN_UnHandled 

UnHadled Interrupt asserted.

This provides constants for the MCAN status flags for use in the MCAN functions. Note: The CPU read action clears MCAN_ErrorFlag, therefore user need to read MCAN_ErrorFlag and distinguish which error is occur using _mcan_error_flags enumerations.

Enumerator
kMCAN_AccesstoRsvdFlag 

CAN Synchronization Status.

kMCAN_ProtocolErrDIntFlag 

Tx Warning Interrupt Flag.

kMCAN_ProtocolErrAIntFlag 

Rx Warning Interrupt Flag.

kMCAN_BusOffIntFlag 

Tx Error Warning Status.

kMCAN_ErrorWarningIntFlag 

Rx Error Warning Status.

kMCAN_ErrorPassiveIntFlag 

Rx Error Warning Status.

The MCAN Rx FIFO Status enumerations are used to determine the status of the Rx FIFO.

Enumerator
kMCAN_RxFifo0NewFlag 

Rx FIFO 0 new message flag.

kMCAN_RxFifo0WatermarkFlag 

Rx FIFO 0 watermark reached flag.

kMCAN_RxFifo0FullFlag 

Rx FIFO 0 full flag.

kMCAN_RxFifo0LostFlag 

Rx FIFO 0 message lost flag.

kMCAN_RxFifo1NewFlag 

Rx FIFO 0 new message flag.

kMCAN_RxFifo1WatermarkFlag 

Rx FIFO 0 watermark reached flag.

kMCAN_RxFifo1FullFlag 

Rx FIFO 0 full flag.

kMCAN_RxFifo1LostFlag 

Rx FIFO 0 message lost flag.

The MCAN Tx Status enumerations are used to determine the status of the Tx Buffer/Event FIFO.

Enumerator
kMCAN_TxTransmitCompleteFlag 

Transmission completed flag.

kMCAN_TxTransmitCancelFinishFlag 

Transmission cancellation finished flag.

kMCAN_TxEventFifoLostFlag 

Tx Event FIFO element lost.

kMCAN_TxEventFifoFullFlag 

Tx Event FIFO full.

kMCAN_TxEventFifoWatermarkFlag 

Tx Event FIFO fill level reached watermark.

kMCAN_TxEventFifoNewFlag 

Tx Handler wrote Tx Event FIFO element flag.

kMCAN_TxEventFifoEmptyFlag 

Tx FIFO empty flag.

This structure contains the settings for all of the MCAN Module interrupt configurations.

Enumerator
kMCAN_BusOffInterruptEnable 

Bus Off interrupt.

kMCAN_ErrorInterruptEnable 

Error interrupt.

kMCAN_WarningInterruptEnable 

Rx Warning interrupt.

Enumerator
kMCAN_FrameIDStandard 

Standard frame format attribute.

kMCAN_FrameIDExtend 

Extend frame format attribute.

Enumerator
kMCAN_FrameTypeData 

Data frame type attribute.

kMCAN_FrameTypeRemote 

Remote frame type attribute.

Enumerator
kMCAN_8ByteDatafield 

8 byte data field.

kMCAN_12ByteDatafield 

12 byte data field.

kMCAN_16ByteDatafield 

16 byte data field.

kMCAN_20ByteDatafield 

20 byte data field.

kMCAN_24ByteDatafield 

24 byte data field.

kMCAN_32ByteDatafield 

32 byte data field.

kMCAN_48ByteDatafield 

48 byte data field.

kMCAN_64ByteDatafield 

64 byte data field.

Enumerator
kMCAN_Fifo0 

CAN Rx FIFO 0.

kMCAN_Fifo1 

CAN Rx FIFO 1.

Enumerator
kMCAN_FifoBlocking 

FIFO blocking mode.

kMCAN_FifoOverwrite 

FIFO overwrite mode.

Enumerator
kMCAN_txFifo 

Tx FIFO operation.

kMCAN_txQueue 

Tx Queue operation.

Enumerator
kMCAN_filterFrame 

Filter remote frames.

kMCAN_rejectFrame 

Reject all remote frames.

Enumerator
kMCAN_acceptinFifo0 

Accept non-masking frames in Rx FIFO 0.

kMCAN_acceptinFifo1 

Accept non-masking frames in Rx FIFO 1.

kMCAN_reject0 

Reject non-masking frames.

kMCAN_reject1 

Reject non-masking frames.

Enumerator
kMCAN_disable 

Disable filter element.

kMCAN_storeinFifo0 

Store in Rx FIFO 0 if filter matches.

kMCAN_storeinFifo1 

Store in Rx FIFO 1 if filter matches.

kMCAN_reject 

Reject ID if filter matches.

kMCAN_setprio 

Set priority if filter matches.

kMCAN_setpriofifo0 

Set priority and store in FIFO 0 if filter matches.

kMCAN_setpriofifo1 

Set priority and store in FIFO 1 if filter matches.

kMCAN_storeinbuffer 

Store into Rx Buffer or as debug message.

Enumerator
kMCAN_range 

Range filter from SFID1 to SFID2.

kMCAN_dual 

Dual ID filter for SFID1 or SFID2.

kMCAN_classic 

Classic filter: SFID1 = filter, SFID2 = mask.

kMCAN_disableORrange2 

Filter element disabled for standard filter or Range filter, XIDAM mask not applied for extended filter.

Function Documentation

void MCAN_Init ( CAN_Type *  base,
const mcan_config_t config,
uint32_t  sourceClock_Hz 
)

This function initializes the MCAN module with user-defined settings. This example shows how to set up the mcan_config_t parameters and how to call the MCAN_Init function by passing in these parameters.

* mcan_config_t config;
* config->baudRateA = 500000U;
* config->baudRateD = 1000000U;
* config->enableCanfdNormal = false;
* config->enableCanfdSwitch = false;
* config->enableLoopBackInt = false;
* config->enableLoopBackExt = false;
* config->enableBusMon = false;
* MCAN_Init(CANFD0, &config, 8000000UL);
*
Parameters
baseMCAN peripheral base address.
configPointer to the user-defined configuration structure.
sourceClock_HzMCAN Protocol Engine clock source frequency in Hz.
void MCAN_Deinit ( CAN_Type *  base)

This function deinitializes the MCAN module.

Parameters
baseMCAN peripheral base address.
void MCAN_GetDefaultConfig ( mcan_config_t config)

This function initializes the MCAN configuration structure to default values. The default values are as follows. config->baudRateA = 500000U; config->baudRateD = 1000000U; config->enableCanfdNormal = false; config->enableCanfdSwitch = false; config->enableLoopBackInt = false; config->enableLoopBackExt = false; config->enableBusMon = false;

Parameters
configPointer to the MCAN configuration structure.
static void MCAN_EnterInitialMode ( CAN_Type *  base)
inlinestatic

After enter initialization mode, users can write access to the protected configuration registers.

Parameters
baseMCAN peripheral base address.
static void MCAN_EnterNormalMode ( CAN_Type *  base)
inlinestatic

After initialization, INIT bit in CCCR register must be cleared to enter normal mode thus synchronizes to the CAN bus and ready for communication.

Parameters
baseMCAN peripheral base address.
static void MCAN_SetMsgRAMBase ( CAN_Type *  base,
uint32_t  value 
)
inlinestatic

This function sets the Message RAM base address.

Parameters
baseMCAN peripheral base address.
valueDesired Message RAM base.
static uint32_t MCAN_GetMsgRAMBase ( CAN_Type *  base)
inlinestatic

This function gets the Message RAM base address.

Parameters
baseMCAN peripheral base address.
Returns
Message RAM base address.
bool MCAN_CalculateImprovedTimingValues ( uint32_t  baudRate,
uint32_t  sourceClock_Hz,
mcan_timing_config_t pconfig 
)
Parameters
baudRateThe classical CAN speed in bps defined by user
sourceClock_HzThe Source clock data speed in bps. Zero to disable baudrate switching
pconfigPointer to the MCAN timing configuration structure.
Returns
TRUE if timing configuration found, FALSE if failed to find configuration
bool MCAN_CalculateSpecifiedTimingValues ( uint32_t  sourceClock_Hz,
mcan_timing_config_t pconfig,
const mcan_timing_param_t pParamConfig 
)

User can specify baudrates, sample point position, bus length, and transceiver propagation delay. This example shows how to set up the mcan_timing_param_t parameters and how to call the this function by passing in these parameters.

* mcan_timing_config_t timing_config;
* mcan_timing_param_t timing_param;
* timing_param.busLength = 1U;
* timing_param.propTxRx = 230U;
* timing_param.nominalbaudRate = 500000U;
* timing_param.nominalSP = 800U;
* MCAN_CalculateSpecifiedTimingValues(MCAN_CLK_FREQ, &timing_config, &timing_param);
*

Note that due to integer division will sacrifice the precision, actual sample point may not equal to expected. If actual sample point is not in allowed 2% range, this function will return false. So it is better to select higher source clock when baudrate is relatively high. This will ensure more time quanta and higher precision of sample point. Parameter busLength and propTxRx are optional and intended to verify whether propagation delay is too long to corrupt sample point. User can set these parameter zero if you do not want to consider this factor.

Parameters
sourceClock_HzThe Source clock data speed in bps.
pconfigPointer to the MCAN timing configuration structure.
configPointer to the MCAN timing parameters structure.
Returns
TRUE if timing configuration found, FALSE if failed to find configuration
void MCAN_SetArbitrationTimingConfig ( CAN_Type *  base,
const mcan_timing_config_t config 
)

This function gives user settings to CAN bus timing characteristic. The function is for an experienced user. For less experienced users, call the MCAN_Init() and fill the baud rate field with a desired value. This provides the default arbitration phase timing characteristics.

Note that calling MCAN_SetArbitrationTimingConfig() overrides the baud rate set in MCAN_Init().

Parameters
baseMCAN peripheral base address.
configPointer to the timing configuration structure.
status_t MCAN_SetBaudRate ( CAN_Type *  base,
uint32_t  sourceClock_Hz,
uint32_t  baudRate_Bps 
)

This function set the baud rate of MCAN base on MCAN_CalculateImprovedTimingValues() API calculated timing values.

Parameters
baseMCAN peripheral base address.
sourceClock_HzSource Clock in Hz.
baudRate_BpsBaud Rate in Bps.
Returns
kStatus_Success - Set CAN baud rate (only has Nominal phase) successfully.
bool MCAN_FDCalculateImprovedTimingValues ( uint32_t  baudRate,
uint32_t  baudRateFD,
uint32_t  sourceClock_Hz,
mcan_timing_config_t pconfig 
)
Parameters
baudRateThe CANFD bus control speed in bps defined by user
baudRateFDThe CANFD bus data speed in bps defined by user
sourceClock_HzThe Source clock data speed in bps.
pconfigPointer to the MCAN timing configuration structure.
Returns
TRUE if timing configuration found, FALSE if failed to find configuration
bool MCAN_FDCalculateSpecifiedTimingValues ( uint32_t  sourceClock_Hz,
mcan_timing_config_t pconfig,
const mcan_timing_param_t pParamConfig 
)

User can specify baudrates, sample point position, bus length, and transceiver propagation delay. This example shows how to set up the mcan_timing_param_t parameters and how to call the this function by passing in these parameters.

* mcan_timing_config_t timing_config;
* mcan_timing_param_t timing_param;
* timing_param.busLength = 1U;
* timing_param.propTxRx = 230U;
* timing_param.nominalbaudRate = 500000U;
* timing_param.nominalSP = 800U;
* timing_param.databaudRate = 4000000U;
* timing_param.dataSP = 700U;
* MCAN_FDCalculateSpecifiedTimingValues(MCAN_CLK_FREQ, &timing_config, &timing_param);
*

Note that due to integer division will sacrifice the precision, actual sample point may not equal to expected. So it is better to select higher source clock when baudrate is relatively high. Select higher nominal baudrate when source clock is relatively high because large clock predivider will lead to less time quanta in data phase. This function will set predivider in arbitration phase equal to data phase. These methods will ensure more time quanta and higher precision of sample point. Parameter busLength and propTxRx are optional and intended to verify whether propagation delay is too long to corrupt sample point. User can set these parameter zero if you do not want to consider this factor.

Parameters
sourceClock_HzThe Source clock data speed in bps.
pconfigPointer to the MCAN timing configuration structure.
configPointer to the MCAN timing parameters structure.
Returns
TRUE if timing configuration found, FALSE if failed to find configuration
status_t MCAN_SetBaudRateFD ( CAN_Type *  base,
uint32_t  sourceClock_Hz,
uint32_t  baudRateN_Bps,
uint32_t  baudRateD_Bps 
)

This function set the baud rate of MCAN FD base on MCAN_FDCalculateImprovedTimingValues API calculated timing values.

Parameters
baseMCAN peripheral base address.
sourceClock_HzSource Clock in Hz.
baudRateN_BpsNominal Baud Rate in Bps.
baudRateD_BpsData Baud Rate in Bps.
Returns
kStatus_Success - Set CAN FD baud rate (include Nominal and Data phase) successfully.
void MCAN_SetDataTimingConfig ( CAN_Type *  base,
const mcan_timing_config_t config 
)

This function gives user settings to CAN bus timing characteristic. The function is for an experienced user. For less experienced users, call the MCAN_Init() and fill the baud rate field with a desired value. This provides the default data phase timing characteristics.

Note that calling MCAN_SetArbitrationTimingConfig() overrides the baud rate set in MCAN_Init().

Parameters
baseMCAN peripheral base address.
configPointer to the timing configuration structure.
void MCAN_SetRxFifo0Config ( CAN_Type *  base,
const mcan_rx_fifo_config_t config 
)

This function sets start address, element size, watermark, operation mode and datafield size of the recieve fifo 0.

Parameters
baseMCAN peripheral base address.
configThe receive fifo 0 configuration structure.
void MCAN_SetRxFifo1Config ( CAN_Type *  base,
const mcan_rx_fifo_config_t config 
)

This function sets start address, element size, watermark, operation mode and datafield size of the recieve fifo 1.

Parameters
baseMCAN peripheral base address.
configThe receive fifo 1 configuration structure.
void MCAN_SetRxBufferConfig ( CAN_Type *  base,
const mcan_rx_buffer_config_t config 
)

This function sets start address and datafield size of the recieve buffer.

Parameters
baseMCAN peripheral base address.
configThe receive buffer configuration structure.
void MCAN_SetTxEventFifoConfig ( CAN_Type *  base,
const mcan_tx_fifo_config_t config 
)

This function sets start address, element size, watermark of the transmit event fifo.

Parameters
baseMCAN peripheral base address.
configThe transmit event fifo configuration structure.
void MCAN_SetTxBufferConfig ( CAN_Type *  base,
const mcan_tx_buffer_config_t config 
)

This function sets start address, element size, fifo/queue mode and datafield size of the transmit buffer.

Parameters
baseMCAN peripheral base address.
configThe transmit buffer configuration structure.
void MCAN_SetFilterConfig ( CAN_Type *  base,
const mcan_frame_filter_config_t config 
)

This function sets remote and non masking frames in global filter configuration, also the start address, list size in standard/extended ID filter configuration.

Parameters
baseMCAN peripheral base address.
configThe MCAN filter configuration.
status_t MCAN_SetMessageRamConfig ( CAN_Type *  base,
const mcan_memory_config_t config 
)
Note
This function include Standard/extended ID filter, Rx FIFO 0/1, Rx buffer, Tx event FIFO and Tx buffer configurations
Parameters
baseMCAN peripheral base address.
configThe MCAN filter configuration.
Return values
kStatus_Success- Message RAM related configuration Successfully.
kStatus_Fail- Message RAM related configure fail due to wrong address parameter.
void MCAN_SetSTDFilterElement ( CAN_Type *  base,
const mcan_frame_filter_config_t config,
const mcan_std_filter_element_config_t filter,
uint8_t  idx 
)
Parameters
baseMCAN peripheral base address.
configThe MCAN filter configuration.
filterThe MCAN standard message ID filter element configuration.
idxThe standard message ID filter element index.
void MCAN_SetEXTFilterElement ( CAN_Type *  base,
const mcan_frame_filter_config_t config,
const mcan_ext_filter_element_config_t filter,
uint8_t  idx 
)
Parameters
baseMCAN peripheral base address.
configThe MCAN filter configuration.
filterThe MCAN extended message ID filter element configuration.
idxThe extended message ID filter element index.
static uint32_t MCAN_GetStatusFlag ( CAN_Type *  base,
uint32_t  mask 
)
inlinestatic

This function gets all MCAN interrupt status flags.

Parameters
baseMCAN peripheral base address.
maskThe ORed MCAN interrupt mask.
Returns
MCAN status flags which are ORed.
static void MCAN_ClearStatusFlag ( CAN_Type *  base,
uint32_t  mask 
)
inlinestatic

This function clears MCAN interrupt status flags.

Parameters
baseMCAN peripheral base address.
maskThe ORed MCAN interrupt mask.
static bool MCAN_GetRxBufferStatusFlag ( CAN_Type *  base,
uint8_t  idx 
)
inlinestatic

This function gets new data flag of specific Rx Buffer.

Parameters
baseMCAN peripheral base address.
idxRx Buffer index.
Returns
Rx Buffer new data status flag.
static void MCAN_ClearRxBufferStatusFlag ( CAN_Type *  base,
uint8_t  idx 
)
inlinestatic

This function clears new data flag of specific Rx Buffer.

Parameters
baseMCAN peripheral base address.
idxRx Buffer index.
static void MCAN_EnableInterrupts ( CAN_Type *  base,
uint32_t  line,
uint32_t  mask 
)
inlinestatic

This function enables the MCAN interrupts according to the provided interrupt line and mask. The mask is a logical OR of enumeration members.

Parameters
baseMCAN peripheral base address.
lineInterrupt line number, 0 or 1.
maskThe interrupts to enable.
static void MCAN_EnableTransmitBufferInterrupts ( CAN_Type *  base,
uint8_t  idx 
)
inlinestatic

This function enables the MCAN Tx Buffer interrupts.

Parameters
baseMCAN peripheral base address.
idxTx Buffer index.
static void MCAN_DisableTransmitBufferInterrupts ( CAN_Type *  base,
uint8_t  idx 
)
inlinestatic

This function disables the MCAN Tx Buffer interrupts.

Parameters
baseMCAN peripheral base address.
idxTx Buffer index.
static void MCAN_DisableInterrupts ( CAN_Type *  base,
uint32_t  mask 
)
inlinestatic

This function disables the MCAN interrupts according to the provided mask. The mask is a logical OR of enumeration members.

Parameters
baseMCAN peripheral base address.
maskThe interrupts to disable.
uint32_t MCAN_IsTransmitRequestPending ( CAN_Type *  base,
uint8_t  idx 
)

This function returns Tx Message Buffer transmission request pending status.

Parameters
baseMCAN peripheral base address.
idxThe MCAN Tx Buffer index.
uint32_t MCAN_IsTransmitOccurred ( CAN_Type *  base,
uint8_t  idx 
)

This function returns Tx Message Buffer transmission occurred status.

Parameters
baseMCAN peripheral base address.
idxThe MCAN Tx Buffer index.
status_t MCAN_WriteTxBuffer ( CAN_Type *  base,
uint8_t  idx,
const mcan_tx_buffer_frame_t pTxFrame 
)

This function writes a CAN Message to the specified Transmit Message Buffer and changes the Message Buffer state to start CAN Message transmit. After that the function returns immediately.

Parameters
baseMCAN peripheral base address.
idxThe MCAN Tx Buffer index.
pTxFramePointer to CAN message frame to be sent.
status_t MCAN_ReadRxBuffer ( CAN_Type *  base,
uint8_t  idx,
mcan_rx_buffer_frame_t pRxFrame 
)

This function reads a CAN message from the Rx Buffer in the Message RAM.

Parameters
baseMCAN peripheral base address.
idxThe MCAN Rx Buffer index.
pRxFramePointer to CAN message frame structure for reception.
Return values
kStatus_Success- Read Message from Rx Buffer successfully.
status_t MCAN_ReadRxFifo ( CAN_Type *  base,
uint8_t  fifoBlock,
mcan_rx_buffer_frame_t pRxFrame 
)

This function reads a CAN message from the Rx FIFO in the Message RAM.

Parameters
baseMCAN peripheral base address.
fifoBlockRx FIFO block 0 or 1.
pRxFramePointer to CAN message frame structure for reception.
Return values
kStatus_Success- Read Message from Rx FIFO successfully.
static void MCAN_TransmitAddRequest ( CAN_Type *  base,
uint8_t  idx 
)
inlinestatic

This function add sending request to corresponding Tx Buffer.

Parameters
baseMCAN peripheral base address.
idxTx Buffer index.
static void MCAN_TransmitCancelRequest ( CAN_Type *  base,
uint8_t  idx 
)
inlinestatic

This function clears Tx buffer request pending bit.

Parameters
baseMCAN peripheral base address.
idxTx Buffer index.
status_t MCAN_TransferSendBlocking ( CAN_Type *  base,
uint8_t  idx,
mcan_tx_buffer_frame_t pTxFrame 
)

Note that a transfer handle does not need to be created before calling this API.

Parameters
baseMCAN peripheral base pointer.
idxThe MCAN buffer index.
pTxFramePointer to CAN message frame to be sent.
Return values
kStatus_Success- Write Tx Message Buffer Successfully.
kStatus_Fail- Tx Message Buffer is currently in use.
status_t MCAN_TransferReceiveBlocking ( CAN_Type *  base,
uint8_t  idx,
mcan_rx_buffer_frame_t pRxFrame 
)

Note that a transfer handle does not need to be created before calling this API.

Parameters
baseMCAN peripheral base pointer.
idxThe MCAN buffer index.
pRxFramePointer to CAN message frame structure for reception.
Return values
kStatus_Success- Read Rx Message Buffer Successfully.
kStatus_Fail- No new message.
status_t MCAN_TransferReceiveFifoBlocking ( CAN_Type *  base,
uint8_t  fifoBlock,
mcan_rx_buffer_frame_t pRxFrame 
)

Note that a transfer handle does not need to be created before calling this API.

Parameters
baseMCAN peripheral base pointer.
fifoBlockRx FIFO block, 0 or 1.
pRxFramePointer to CAN message frame structure for reception.
Return values
kStatus_Success- Read Message from Rx FIFO successfully.
kStatus_Fail- No new message in Rx FIFO.
void MCAN_TransferCreateHandle ( CAN_Type *  base,
mcan_handle_t handle,
mcan_transfer_callback_t  callback,
void *  userData 
)

This function initializes the MCAN handle, which can be used for other MCAN transactional APIs. Usually, for a specified MCAN instance, call this API once to get the initialized handle.

Parameters
baseMCAN peripheral base address.
handleMCAN handle pointer.
callbackThe callback function.
userDataThe parameter of the callback function.
status_t MCAN_TransferSendNonBlocking ( CAN_Type *  base,
mcan_handle_t handle,
mcan_buffer_transfer_t xfer 
)

This function sends a message using IRQ. This is a non-blocking function, which returns right away. When messages have been sent out, the send callback function is called.

Parameters
baseMCAN peripheral base address.
handleMCAN handle pointer.
xferMCAN Buffer transfer structure. See the mcan_buffer_transfer_t.
Return values
kStatus_SuccessStart Tx Buffer sending process successfully.
kStatus_FailWrite Tx Buffer failed.
kStatus_MCAN_TxBusyTx Buffer is in use.
status_t MCAN_TransferReceiveFifoNonBlocking ( CAN_Type *  base,
uint8_t  fifoBlock,
mcan_handle_t handle,
mcan_fifo_transfer_t xfer 
)

This function receives a message using IRQ. This is a non-blocking function, which returns right away. When all messages have been received, the receive callback function is called.

Parameters
baseMCAN peripheral base address.
handleMCAN handle pointer.
fifoBlockRx FIFO block, 0 or 1.
xferMCAN Rx FIFO transfer structure. See the mcan_fifo_transfer_t.
Return values
kStatus_Success- Start Rx FIFO receiving process successfully.
kStatus_MCAN_RxFifo0Busy- Rx FIFO 0 is currently in use.
kStatus_MCAN_RxFifo1Busy- Rx FIFO 1 is currently in use.
void MCAN_TransferAbortSend ( CAN_Type *  base,
mcan_handle_t handle,
uint8_t  bufferIdx 
)

This function aborts the interrupt driven message send process.

Parameters
baseMCAN peripheral base address.
handleMCAN handle pointer.
bufferIdxThe MCAN Buffer index.
void MCAN_TransferAbortReceiveFifo ( CAN_Type *  base,
uint8_t  fifoBlock,
mcan_handle_t handle 
)

This function aborts the interrupt driven message receive from Rx FIFO process.

Parameters
baseMCAN peripheral base address.
fifoBlockMCAN Fifo block, 0 or 1.
handleMCAN handle pointer.
void MCAN_TransferHandleIRQ ( CAN_Type *  base,
mcan_handle_t handle 
)

This function handles the MCAN Error, the Buffer, and the Rx FIFO IRQ request.

Parameters
baseMCAN peripheral base address.
handleMCAN handle pointer.