MCUXpresso SDK API Reference Manual
Rev. 0
NXP Semiconductors
|
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_t |
MCAN Tx Buffer structure. More... | |
struct | mcan_rx_buffer_frame_t |
MCAN Rx FIFO/Buffer structure. More... | |
struct | mcan_rx_fifo_config_t |
MCAN Rx FIFO configuration. More... | |
struct | mcan_rx_buffer_config_t |
MCAN Rx Buffer configuration. More... | |
struct | mcan_tx_fifo_config_t |
MCAN Tx Event FIFO configuration. More... | |
struct | mcan_tx_buffer_config_t |
MCAN Tx Buffer configuration. More... | |
struct | mcan_std_filter_element_config_t |
MCAN Standard Message ID Filter Element. More... | |
struct | mcan_ext_filter_element_config_t |
MCAN Extended Message ID Filter Element. More... | |
struct | mcan_frame_filter_config_t |
MCAN Rx filter configuration. More... | |
struct | mcan_config_t |
MCAN module configuration structure. More... | |
struct | mcan_timing_config_t |
MCAN protocol timing characteristic configuration structure. More... | |
struct | mcan_buffer_transfer_t |
MCAN Buffer transfer. More... | |
struct | mcan_fifo_transfer_t |
MCAN Rx FIFO transfer. More... | |
struct | mcan_handle_t |
MCAN handle structure. More... | |
Typedefs | |
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 | _mcan_status { 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_t { kMCAN_FrameIDStandard = 0x0U, kMCAN_FrameIDExtend = 0x1U } |
MCAN frame format. More... | |
enum | mcan_frame_type_t { kMCAN_FrameTypeData = 0x0U, kMCAN_FrameTypeRemote = 0x1U } |
MCAN frame type. More... | |
enum | mcan_bytes_in_datafield_t { 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_t { kMCAN_Fifo0 = 0x0U, kMCAN_Fifo1 = 0x1U } |
MCAN Rx FIFO block number. More... | |
enum | mcan_fifo_opmode_config_t { kMCAN_FifoBlocking = 0, kMCAN_FifoOverwrite = 1 } |
MCAN FIFO Operation Mode. More... | |
enum | mcan_txmode_config_t { kMCAN_txFifo = 0, kMCAN_txQueue = 1 } |
MCAN Tx FIFO/Queue Mode. More... | |
enum | mcan_remote_frame_config_t { kMCAN_filterFrame = 0, kMCAN_rejectFrame = 1 } |
MCAN remote frames treatment. More... | |
enum | mcan_nonmasking_frame_config_t { kMCAN_acceptinFifo0 = 0, kMCAN_acceptinFifo1 = 1, kMCAN_reject0 = 2, kMCAN_reject1 = 3 } |
MCAN non-masking frames treatment. More... | |
enum | mcan_fec_config_t { kMCAN_disable = 0, kMCAN_storeinFifo0 = 1, kMCAN_storeinFifo1 = 2, kMCAN_reject = 3, kMCAN_setprio = 4, kMCAN_setpriofifo0 = 5, kMCAN_setpriofifo1 = 6, kMCAN_storeinbuffer = 7 } |
MCAN Filter Element Configuration. More... | |
enum | mcan_filter_type_t { kMCAN_range = 0, kMCAN_dual = 1, kMCAN_classic = 2, kMCAN_disableORrange2 = 3 } |
MCAN Filter Type. More... | |
Driver version | |
#define | MCAN_DRIVER_VERSION (MAKE_VERSION(2, 0, 0)) |
MCAN driver version 2.0.0. 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... | |
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... | |
void | MCAN_SetArbitrationTimingConfig (CAN_Type *base, const mcan_timing_config_t *config) |
Sets the MCAN protocol arbitration 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... | |
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 filter 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 filter 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 | |
status_t | MCAN_WriteTxBuffer (CAN_Type *base, uint8_t idx, const mcan_tx_buffer_frame_t *txFrame) |
Writes an MCAN Message to the Transmit Buffer. More... | |
status_t | MCAN_ReadRxFifo (CAN_Type *base, uint8_t fifoBlock, mcan_rx_buffer_frame_t *rxFrame) |
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 *txFrame) |
Performs a polling send transaction on the CAN bus. More... | |
status_t | MCAN_TransferReceiveFifoBlocking (CAN_Type *base, uint8_t fifoBlock, mcan_rx_buffer_frame_t *rxFrame) |
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... | |
struct mcan_tx_buffer_frame_t |
uint32_t mcan_tx_buffer_frame_t::id |
uint32_t mcan_tx_buffer_frame_t::rtr |
uint32_t mcan_tx_buffer_frame_t::xtd |
uint32_t mcan_tx_buffer_frame_t::esi |
uint32_t mcan_tx_buffer_frame_t::dlc |
uint32_t mcan_tx_buffer_frame_t::brs |
uint32_t mcan_tx_buffer_frame_t::fdf |
uint32_t mcan_tx_buffer_frame_t::__pad1__ |
uint32_t mcan_tx_buffer_frame_t::efc |
uint32_t mcan_tx_buffer_frame_t::mm |
struct mcan_rx_buffer_frame_t |
uint32_t mcan_rx_buffer_frame_t::id |
uint32_t mcan_rx_buffer_frame_t::rtr |
uint32_t mcan_rx_buffer_frame_t::xtd |
uint32_t mcan_rx_buffer_frame_t::esi |
uint32_t mcan_rx_buffer_frame_t::rxts |
uint32_t mcan_rx_buffer_frame_t::dlc |
uint32_t mcan_rx_buffer_frame_t::brs |
uint32_t mcan_rx_buffer_frame_t::fdf |
uint32_t mcan_rx_buffer_frame_t::__pad0__ |
uint32_t mcan_rx_buffer_frame_t::fidx |
uint32_t mcan_rx_buffer_frame_t::anmf |
struct mcan_rx_fifo_config_t |
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... | |
uint32_t mcan_rx_fifo_config_t::address |
uint32_t mcan_rx_fifo_config_t::elementSize |
uint32_t mcan_rx_fifo_config_t::watermark |
mcan_fifo_opmode_config_t mcan_rx_fifo_config_t::opmode |
mcan_bytes_in_datafield_t mcan_rx_fifo_config_t::datafieldSize |
struct mcan_rx_buffer_config_t |
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... | |
uint32_t mcan_rx_buffer_config_t::address |
mcan_bytes_in_datafield_t mcan_rx_buffer_config_t::datafieldSize |
struct mcan_tx_fifo_config_t |
Data Fields | |
uint32_t | address |
Event fifo start address. More... | |
uint32_t | elementSize |
FIFOn element number. More... | |
uint32_t | watermark |
FIFOn watermark level. More... | |
uint32_t mcan_tx_fifo_config_t::address |
uint32_t mcan_tx_fifo_config_t::elementSize |
uint32_t mcan_tx_fifo_config_t::watermark |
struct mcan_tx_buffer_config_t |
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... | |
uint32_t mcan_tx_buffer_config_t::address |
uint32_t mcan_tx_buffer_config_t::dedicatedSize |
uint32_t mcan_tx_buffer_config_t::fqSize |
mcan_txmode_config_t mcan_tx_buffer_config_t::mode |
mcan_bytes_in_datafield_t mcan_tx_buffer_config_t::datafieldSize |
struct mcan_std_filter_element_config_t |
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... | |
mcan_fec_config_t | sfec: 3 |
Standard Filter Element Configuration. More... | |
mcan_filter_type_t | sft: 2 |
Standard Filter Type/. | |
uint32_t mcan_std_filter_element_config_t::sfid2 |
uint32_t mcan_std_filter_element_config_t::__pad0__ |
uint32_t mcan_std_filter_element_config_t::sfid1 |
mcan_fec_config_t mcan_std_filter_element_config_t::sfec |
struct mcan_ext_filter_element_config_t |
Data Fields | |
uint32_t | efid1: 29 |
Extended Filter ID 1. More... | |
mcan_fec_config_t | efec: 3 |
Extended Filter Element Configuration. More... | |
uint32_t | efid2: 29 |
Extended Filter ID 2. More... | |
uint32_t | __pad0__: 1 |
Reserved. More... | |
mcan_filter_type_t | eft: 2 |
Extended Filter Type. More... | |
uint32_t mcan_ext_filter_element_config_t::efid1 |
mcan_fec_config_t mcan_ext_filter_element_config_t::efec |
uint32_t mcan_ext_filter_element_config_t::efid2 |
uint32_t mcan_ext_filter_element_config_t::__pad0__ |
mcan_filter_type_t mcan_ext_filter_element_config_t::eft |
struct mcan_frame_filter_config_t |
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... | |
uint32_t mcan_frame_filter_config_t::address |
uint32_t mcan_frame_filter_config_t::listSize |
mcan_frame_idformat_t mcan_frame_filter_config_t::idFormat |
mcan_remote_frame_config_t mcan_frame_filter_config_t::remFrame |
mcan_nonmasking_frame_config_t mcan_frame_filter_config_t::nmFrame |
struct mcan_config_t |
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... | |
uint32_t mcan_config_t::baudRateA |
uint32_t mcan_config_t::baudRateD |
bool mcan_config_t::enableCanfdNormal |
bool mcan_config_t::enableCanfdSwitch |
bool mcan_config_t::enableLoopBackInt |
bool mcan_config_t::enableLoopBackExt |
bool mcan_config_t::enableBusMon |
struct mcan_timing_config_t |
Data Fields | |
uint16_t | preDivider |
Clock Pre-scaler Division Factor. More... | |
uint8_t | rJumpwidth |
Re-sync Jump Width. More... | |
uint8_t | seg1 |
Data Time Segment 1. More... | |
uint8_t | seg2 |
Data Time Segment 2. More... | |
uint16_t mcan_timing_config_t::preDivider |
uint8_t mcan_timing_config_t::rJumpwidth |
uint8_t mcan_timing_config_t::seg1 |
uint8_t mcan_timing_config_t::seg2 |
struct mcan_buffer_transfer_t |
Data Fields | |
mcan_tx_buffer_frame_t * | frame |
The buffer of CAN Message to be transfer. More... | |
uint8_t | bufferIdx |
The index of Message buffer used to transfer Message. More... | |
mcan_tx_buffer_frame_t* mcan_buffer_transfer_t::frame |
uint8_t mcan_buffer_transfer_t::bufferIdx |
struct mcan_fifo_transfer_t |
Data Fields | |
mcan_rx_buffer_frame_t * | frame |
The buffer of CAN Message to be received from Rx FIFO. More... | |
mcan_rx_buffer_frame_t* mcan_fifo_transfer_t::frame |
struct _mcan_handle |
MCAN handle structure definition.
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 | txbufferIdx |
Message Buffer transfer state. More... | |
volatile uint8_t | bufferState [64] |
Message Buffer transfer state. More... | |
volatile uint8_t | rxFifoState |
Rx FIFO transfer state. More... | |
mcan_transfer_callback_t mcan_handle_t::callback |
void* mcan_handle_t::userData |
mcan_tx_buffer_frame_t* volatile mcan_handle_t::bufferFrameBuf[64] |
mcan_rx_buffer_frame_t* volatile mcan_handle_t::rxFifoFrameBuf |
volatile uint8_t mcan_handle_t::txbufferIdx |
volatile uint8_t mcan_handle_t::bufferState[64] |
volatile uint8_t mcan_handle_t::rxFifoState |
#define MCAN_DRIVER_VERSION (MAKE_VERSION(2, 0, 0)) |
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.
enum _mcan_status |
enum _mcan_flags |
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.
enum _mcan_rx_fifo_flags |
The MCAN Rx FIFO Status enumerations are used to determine the status of the Rx FIFO.
enum _mcan_tx_flags |
The MCAN Tx Status enumerations are used to determine the status of the Tx Buffer/Event FIFO.
enum mcan_frame_type_t |
enum mcan_fifo_type_t |
enum mcan_txmode_config_t |
enum mcan_fec_config_t |
enum mcan_filter_type_t |
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.
base | MCAN peripheral base address. |
config | Pointer to the user-defined configuration structure. |
sourceClock_Hz | MCAN Protocol Engine clock source frequency in Hz. |
void MCAN_Deinit | ( | CAN_Type * | base | ) |
This function deinitializes the MCAN module.
base | MCAN 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 = 500000U; config->enableCanfdNormal = false; config->enableCanfdSwitch = false; config->enableLoopBackInt = false; config->enableLoopBackExt = false; config->enableBusMon = false;
config | Pointer to the MCAN configuration structure. |
void MCAN_EnterNormalMode | ( | CAN_Type * | base | ) |
After initialization, INIT bit in CCCR register must be cleared to enter normal mode thus synchronizes to the CAN bus and ready for communication.
base | MCAN peripheral base address. |
|
inlinestatic |
This function sets the Message RAM base address.
base | MCAN peripheral base address. |
value | Desired Message RAM base. |
|
inlinestatic |
This function gets the Message RAM base address.
base | MCAN peripheral base address. |
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().
base | MCAN peripheral base address. |
config | Pointer 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.
base | MCAN peripheral base address. |
config | The 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.
base | MCAN peripheral base address. |
config | The 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.
base | MCAN peripheral base address. |
config | The 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.
base | MCAN peripheral base address. |
config | The 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.
base | MCAN peripheral base address. |
config | The 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.
base | MCAN peripheral base address. |
config | The MCAN filter configuration. |
void MCAN_SetSTDFilterElement | ( | CAN_Type * | base, |
const mcan_frame_filter_config_t * | config, | ||
const mcan_std_filter_element_config_t * | filter, | ||
uint8_t | idx | ||
) |
This function sets remote and non masking frames in global filter configuration, also the start address, list size in standard/extended ID filter configuration.
base | MCAN peripheral base address. |
config | The MCAN filter configuration. |
void MCAN_SetEXTFilterElement | ( | CAN_Type * | base, |
const mcan_frame_filter_config_t * | config, | ||
const mcan_ext_filter_element_config_t * | filter, | ||
uint8_t | idx | ||
) |
This function sets remote and non masking frames in global filter configuration, also the start address, list size in standard/extended ID filter configuration.
base | MCAN peripheral base address. |
config | The MCAN filter configuration. |
|
inlinestatic |
This function gets all MCAN interrupt status flags.
base | MCAN peripheral base address. |
mask | The ORed MCAN interrupt mask. |
|
inlinestatic |
This function clears MCAN interrupt status flags.
base | MCAN peripheral base address. |
mask | The ORed MCAN interrupt mask. |
|
inlinestatic |
This function gets new data flag of specific Rx Buffer.
base | MCAN peripheral base address. |
idx | Rx Buffer index. |
|
inlinestatic |
This function clears new data flag of specific Rx Buffer.
base | MCAN peripheral base address. |
idx | Rx Buffer index. |
|
inlinestatic |
This function enables the MCAN interrupts according to the provided interrupt line and mask. The mask is a logical OR of enumeration members.
base | MCAN peripheral base address. |
line | Interrupt line number, 0 or 1. |
mask | The interrupts to enable. |
|
inlinestatic |
This function enables the MCAN Tx Buffer interrupts.
base | MCAN peripheral base address. |
idx | Tx Buffer index. |
|
inlinestatic |
This function disables the MCAN Tx Buffer interrupts.
base | MCAN peripheral base address. |
idx | Tx Buffer index. |
|
inlinestatic |
This function disables the MCAN interrupts according to the provided mask. The mask is a logical OR of enumeration members.
base | MCAN peripheral base address. |
mask | The interrupts to disable. |
status_t MCAN_WriteTxBuffer | ( | CAN_Type * | base, |
uint8_t | idx, | ||
const mcan_tx_buffer_frame_t * | txFrame | ||
) |
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.
base | MCAN peripheral base address. |
idx | The MCAN Tx Buffer index. |
txFrame | Pointer to CAN message frame to be sent. |
status_t MCAN_ReadRxFifo | ( | CAN_Type * | base, |
uint8_t | fifoBlock, | ||
mcan_rx_buffer_frame_t * | rxFrame | ||
) |
This function reads a CAN message from the Rx FIFO in the Message RAM.
base | MCAN peripheral base address. |
fifoBlock | Rx FIFO block 0 or 1. |
rxFrame | Pointer to CAN message frame structure for reception. |
kStatus_Success | - Read Message from Rx FIFO successfully. |
|
inlinestatic |
This function add sending request to corresponding Tx Buffer.
base | MCAN peripheral base address. |
idx | Tx Buffer index. |
|
inlinestatic |
This function clears Tx buffer request pending bit.
base | MCAN peripheral base address. |
idx | Tx Buffer index. |
status_t MCAN_TransferSendBlocking | ( | CAN_Type * | base, |
uint8_t | idx, | ||
mcan_tx_buffer_frame_t * | txFrame | ||
) |
Note that a transfer handle does not need to be created before calling this API.
base | MCAN peripheral base pointer. |
idx | The MCAN buffer index. |
txFrame | Pointer to CAN message frame to be sent. |
kStatus_Success | - Write Tx Message Buffer Successfully. |
kStatus_Fail | - Tx Message Buffer is currently in use. |
status_t MCAN_TransferReceiveFifoBlocking | ( | CAN_Type * | base, |
uint8_t | fifoBlock, | ||
mcan_rx_buffer_frame_t * | rxFrame | ||
) |
Note that a transfer handle does not need to be created before calling this API.
base | MCAN peripheral base pointer. |
fifoBlock | Rx FIFO block, 0 or 1. |
rxFrame | Pointer to CAN message frame structure for reception. |
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.
base | MCAN peripheral base address. |
handle | MCAN handle pointer. |
callback | The callback function. |
userData | The 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.
base | MCAN peripheral base address. |
handle | MCAN handle pointer. |
xfer | MCAN Buffer transfer structure. See the mcan_buffer_transfer_t. |
kStatus_Success | Start Tx Buffer sending process successfully. |
kStatus_Fail | Write Tx Buffer failed. |
kStatus_MCAN_TxBusy | Tx 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.
base | MCAN peripheral base address. |
handle | MCAN handle pointer. |
fifoBlock | Rx FIFO block, 0 or 1. |
xfer | MCAN Rx FIFO transfer structure. See the mcan_fifo_transfer_t. |
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.
base | MCAN peripheral base address. |
handle | MCAN handle pointer. |
bufferIdx | The 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.
base | MCAN peripheral base address. |
fifoBlock | MCAN Fifo block, 0 or 1. |
handle | MCAN 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.
base | MCAN peripheral base address. |
handle | MCAN handle pointer. |