MCUXpresso SDK API Reference Manual  Rev. 0
NXP Semiconductors
 All Data Structures Functions Variables Typedefs Enumerations Enumerator Groups Pages

Overview

This section describes the programming interface of the MSCAN driver. The MSCAN driver configures MSCAN module and provides functional and transactional interfaces to build the MSCAN application.

Typical use case

Message Buffer Send Operation

Refer to the driver examples codes located at <SDK_ROOT>/boards/<BOARD>/driver_examples/mscan

Message Buffer Receive Operation

Refer to the driver examples codes located at <SDK_ROOT>/boards/<BOARD>/driver_examples/mscan

Receive FIFO Operation

Refer to the driver examples codes located at <SDK_ROOT>/boards/<BOARD>/driver_examples/mscan

Calculate

Provides static functions to calculate improved timing configuration.

The feature need to be enabled by user like that.

#define FSL_FEATURE_FLEXCAN_HAS_IMPROVED_TIMING_CONFIG (1)

Data Structures

struct  MSCAN_IDR1Type
 MSCAN IDR1 struct. More...
 
struct  MSCAN_IDR3Type
 MSCAN IDR3 struct. More...
 
union  IDR1_3_UNION
 MSCAN idr1 and idr3 union. More...
 
struct  MSCAN_ExtendIDType
 MSCAN extend ID struct. More...
 
struct  MSCAN_StandardIDType
 MSCAN standard ID struct. More...
 
struct  mscan_mb_t
 MsCAN message buffer structure. More...
 
struct  mscan_frame_t
 MsCAN frame structure. More...
 
struct  mscan_idfilter_config_t
 MsCAN module acceptance filter configuration structure. More...
 
struct  mscan_config_t
 MsCAN module configuration structure. More...
 
struct  mscan_timing_config_t
 MsCAN protocol timing characteristic configuration structure. More...
 
struct  mscan_mb_transfer_t
 MSCAN Message Buffer transfer. More...
 
struct  mscan_handle_t
 MsCAN handle structure. More...
 

Macros

#define MSCAN_RX_MB_STD_MASK(id)
 MsCAN Rx Message Buffer Mask helper macro. More...
 
#define MSCAN_RX_MB_EXT_MASK(id)
 Extend Rx Message Buffer Mask helper macro. More...
 

Typedefs

typedef void(* mscan_transfer_callback_t )(MSCAN_Type *base, mscan_handle_t *handle, status_t status, void *userData)
 MsCAN transfer callback function. More...
 

Enumerations

enum  {
  kStatus_MSCAN_TxBusy = MAKE_STATUS(kStatusGroup_MSCAN, 0),
  kStatus_MSCAN_TxIdle = MAKE_STATUS(kStatusGroup_MSCAN, 1),
  kStatus_MSCAN_TxSwitchToRx,
  kStatus_MSCAN_RxBusy = MAKE_STATUS(kStatusGroup_MSCAN, 3),
  kStatus_MSCAN_RxIdle = MAKE_STATUS(kStatusGroup_MSCAN, 4),
  kStatus_MSCAN_RxOverflow = MAKE_STATUS(kStatusGroup_MSCAN, 5),
  kStatus_MSCAN_RxFifoBusy = MAKE_STATUS(kStatusGroup_MSCAN, 6),
  kStatus_MSCAN_RxFifoIdle = MAKE_STATUS(kStatusGroup_MSCAN, 7),
  kStatus_MSCAN_RxFifoOverflow = MAKE_STATUS(kStatusGroup_MSCAN, 8),
  kStatus_MSCAN_RxFifoWarning = MAKE_STATUS(kStatusGroup_MSCAN, 9),
  kStatus_MSCAN_ErrorStatus = MAKE_STATUS(kStatusGroup_MSCAN, 10),
  kStatus_MSCAN_UnHandled = MAKE_STATUS(kStatusGroup_MSCAN, 11)
}
 FlexCAN transfer status. More...
 
enum  mscan_frame_format_t {
  kMSCAN_FrameFormatStandard = 0x0U,
  kMSCAN_FrameFormatExtend = 0x1U
}
 MsCAN frame format. More...
 
enum  mscan_frame_type_t {
  kMSCAN_FrameTypeData = 0x0U,
  kMSCAN_FrameTypeRemote = 0x1U
}
 MsCAN frame type. More...
 
enum  mscan_clock_source_t {
  kMSCAN_ClkSrcOsc = 0x0U,
  kMSCAN_ClkSrcBus = 0x1U
}
 MsCAN clock source. More...
 
enum  mscan_busoffrec_mode_t {
  kMSCAN_BusoffrecAuto = 0x0U,
  kMSCAN_BusoffrecUsr = 0x1U
}
 MsCAN bus-off recovery mode. More...
 
enum  _mscan_tx_buffer_empty_flag {
  kMSCAN_TxBuf0Empty = 0x1U,
  kMSCAN_TxBuf1Empty = 0x2U,
  kMSCAN_TxBuf2Empty = 0x4U,
  kMSCAN_TxBufFull = 0x0U
}
 MsCAN Tx buffer empty flag. More...
 
enum  mscan_id_filter_mode_t {
  kMSCAN_Filter32Bit = 0x0U,
  kMSCAN_Filter16Bit = 0x1U,
  kMSCAN_Filter8Bit = 0x2U,
  kMSCAN_FilterClose = 0x3U
}
 MsCAN id filter mode. More...
 
enum  _mscan_interrupt_enable {
  kMSCAN_WakeUpInterruptEnable = MSCAN_CANRIER_WUPIE_MASK,
  kMSCAN_StatusChangeInterruptEnable = MSCAN_CANRIER_CSCIE_MASK,
  kMSCAN_RxStatusChangeInterruptEnable = MSCAN_CANRIER_RSTATE_MASK,
  kMSCAN_TxStatusChangeInterruptEnable = MSCAN_CANRIER_TSTATE_MASK,
  kMSCAN_OverrunInterruptEnable = MSCAN_CANRIER_OVRIE_MASK,
  kMSCAN_RxFullInterruptEnable = MSCAN_CANRIER_RXFIE_MASK,
  kMSCAN_TxEmptyInterruptEnable = MSCAN_CANTIER_TXEIE_MASK
}
 MsCAN interrupt configuration structure, default settings all disabled. More...
 

Driver version

#define FSL_MSCAN_DRIVER_VERSION   (MAKE_VERSION(2, 0, 5))
 MsCAN driver version. More...
 

Initialization and deinitialization

void MSCAN_Init (MSCAN_Type *base, const mscan_config_t *config, uint32_t sourceClock_Hz)
 Initializes a MsCAN instance. More...
 
void MSCAN_Deinit (MSCAN_Type *base)
 De-initializes a MsCAN instance. More...
 
void MSCAN_GetDefaultConfig (mscan_config_t *config)
 Gets the default configuration structure. More...
 

Configuration.

static uint8_t MSCAN_GetTxBufferEmptyFlag (MSCAN_Type *base)
 Get the transmit buffer empty status. More...
 
static void MSCAN_TxBufferSelect (MSCAN_Type *base, uint8_t txBuf)
 The selection of the actual transmit message buffer. More...
 
static uint8_t MSCAN_GetTxBufferSelect (MSCAN_Type *base)
 Get the actual transmit message buffer. More...
 
static void MSCAN_TxBufferLaunch (MSCAN_Type *base, uint8_t txBuf)
 Clear TFLG to schedule for transmission. More...
 
static uint8_t MSCAN_GetTxBufferStatusFlags (MSCAN_Type *base, uint8_t mask)
 Get Tx buffer status flag. More...
 
static uint8_t MSCAN_GetRxBufferFullFlag (MSCAN_Type *base)
 Check Receive Buffer Full Flag. More...
 
static void MSCAN_ClearRxBufferFullFlag (MSCAN_Type *base)
 Clear Receive buffer Full flag. More...
 
static uint8_t MSCAN_ReadRIDR0 (MSCAN_Type *base)
 
static uint8_t MSCAN_ReadRIDR1 (MSCAN_Type *base)
 
static uint8_t MSCAN_ReadRIDR2 (MSCAN_Type *base)
 
static uint8_t MSCAN_ReadRIDR3 (MSCAN_Type *base)
 
static void MSCAN_WriteTIDR0 (MSCAN_Type *base, uint8_t id)
 
static void MSCAN_WriteTIDR1 (MSCAN_Type *base, uint8_t id)
 
static void MSCAN_WriteTIDR2 (MSCAN_Type *base, uint8_t id)
 
static void MSCAN_WriteTIDR3 (MSCAN_Type *base, uint8_t id)
 
static void MSCAN_SetIDFilterMode (MSCAN_Type *base, mscan_id_filter_mode_t mode)
 
static void MSCAN_WriteIDAR0 (MSCAN_Type *base, uint8_t *pID)
 
static void MSCAN_WriteIDAR1 (MSCAN_Type *base, uint8_t *pID)
 
static void MSCAN_WriteIDMR0 (MSCAN_Type *base, uint8_t *pID)
 
static void MSCAN_WriteIDMR1 (MSCAN_Type *base, uint8_t *pID)
 
void MSCAN_SetTimingConfig (MSCAN_Type *base, const mscan_timing_config_t *config)
 Sets the MsCAN protocol timing characteristic. More...
 

Status

static uint8_t MSCAN_GetTxBufEmptyFlags (MSCAN_Type *base)
 Gets the MsCAN Tx buffer empty flags. More...
 

Interrupts

static void MSCAN_EnableTxInterrupts (MSCAN_Type *base, uint8_t mask)
 Enables MsCAN Transmitter interrupts according to the provided mask. More...
 
static void MSCAN_DisableTxInterrupts (MSCAN_Type *base, uint8_t mask)
 Disables MsCAN Transmitter interrupts according to the provided mask. More...
 
static void MSCAN_EnableRxInterrupts (MSCAN_Type *base, uint8_t mask)
 Enables MsCAN Receiver interrupts according to the provided mask. More...
 
static void MSCAN_DisableRxInterrupts (MSCAN_Type *base, uint8_t mask)
 Disables MsCAN Receiver interrupts according to the provided mask. More...
 
static void MSCAN_AbortTxRequest (MSCAN_Type *base, uint8_t mask)
 Abort MsCAN Tx request. More...
 

Bus Operations

static void MSCAN_Enable (MSCAN_Type *base, bool enable)
 Enables or disables the MsCAN module operation. More...
 
status_t MSCAN_WriteTxMb (MSCAN_Type *base, mscan_frame_t *pTxFrame)
 Writes a MsCAN Message to the Transmit Message Buffer. More...
 
status_t MSCAN_ReadRxMb (MSCAN_Type *base, mscan_frame_t *pRxFrame)
 Reads a MsCAN Message from Receive Message Buffer. More...
 

Transactional

void MSCAN_TransferCreateHandle (MSCAN_Type *base, mscan_handle_t *handle, mscan_transfer_callback_t callback, void *userData)
 Initializes the MsCAN handle. More...
 
status_t MSCAN_TransferSendBlocking (MSCAN_Type *base, mscan_frame_t *pTxFrame)
 Performs a polling send transaction on the CAN bus. More...
 
status_t MSCAN_TransferReceiveBlocking (MSCAN_Type *base, mscan_frame_t *pRxFrame)
 Performs a polling receive transaction on the CAN bus. More...
 
status_t MSCAN_TransferSendNonBlocking (MSCAN_Type *base, mscan_handle_t *handle, mscan_mb_transfer_t *xfer)
 Sends a message using IRQ. More...
 
status_t MSCAN_TransferReceiveNonBlocking (MSCAN_Type *base, mscan_handle_t *handle, mscan_mb_transfer_t *xfer)
 Receives a message using IRQ. More...
 
void MSCAN_TransferAbortSend (MSCAN_Type *base, mscan_handle_t *handle, uint8_t mask)
 Aborts the interrupt driven message send process. More...
 
void MSCAN_TransferAbortReceive (MSCAN_Type *base, mscan_handle_t *handle, uint8_t mask)
 Aborts the interrupt driven message receive process. More...
 
void MSCAN_TransferHandleIRQ (MSCAN_Type *base, mscan_handle_t *handle)
 MSCAN IRQ handle function. More...
 

Data Structure Documentation

struct MSCAN_IDR1Type

Data Fields

uint8_t EID17_15: 3
 Extended Format Identifier 17-15.
 
uint8_t R_TEIDE: 1
 ID Extended.
 
uint8_t R_TSRR: 1
 Substitute Remote Request.
 
uint8_t EID20_18_OR_SID2_0: 3
 Extended Format Identifier 18-20 or standard format bit 0-2.
 
struct MSCAN_IDR3Type

Data Fields

uint8_t ERTR: 1
 Remote Transmission Request.
 
uint8_t EID6_0: 7
 Extended Format Identifier 6-0.
 
union IDR1_3_UNION

Data Fields

MSCAN_IDR1Type IDR1
 structure for identifier 1
 
MSCAN_IDR3Type IDR3
 structure for identifier 3
 
uint8_t Bytes
 bytes
 
struct MSCAN_ExtendIDType

Data Fields

uint32_t EID6_0: 7
 ID[0:6].
 
uint32_t EID14_7: 8
 ID[14:7].
 
uint32_t EID17_15: 3
 ID[17:15].
 
uint32_t EID20_18: 3
 ID[20:18].
 
uint32_t EID28_21: 8
 ID[28:21].
 
struct MSCAN_StandardIDType

Data Fields

uint32_t EID2_0: 3
 ID[0:2].
 
uint32_t EID10_3: 8
 ID[10:3].
 
struct mscan_mb_t

Data Fields

uint8_t EIDR0
 Extended Identifier Register 0.
 
uint8_t EIDR1
 Extended Identifier Register 1.
 
uint8_t EIDR2
 Extended Identifier Register 2.
 
uint8_t EIDR3
 Extended Identifier Register 3.
 
uint8_t EDSR [8]
 Extended Data Segment Register.
 
uint8_t DLR
 data length field
 
uint8_t BPR
 Buffer Priority Register.
 
uint8_t TSRH
 Time Stamp Register High.
 
uint8_t TSRL
 Time Stamp Register Low.
 
struct mscan_frame_t

Data Fields

union {
   MSCAN_StandardIDType   StdID
 standard format
 
   MSCAN_ExtendIDType   ExtID
 extend format
 
   uint32_t   ID
 Identifire with 32 bit format.
 
ID_Type
 identifier union
 
uint8_t DLR
 data length
 
uint8_t BPR
 transmit buffer priority
 
mscan_frame_type_t type
 remote frame or data frame
 
mscan_frame_format_t format
 extend frame or standard frame
 
uint8_t TSRH
 time stamp high byte
 
uint8_t TSRL
 time stamp low byte
 
uint8_t DSR [8]
 data segment
 
uint32_t dataWord0
 MSCAN Frame payload word0. More...
 
uint32_t dataWord1
 MSCAN Frame payload word1. More...
 
uint8_t dataByte0
 MSCAN Frame payload byte0. More...
 
uint8_t dataByte1
 MSCAN Frame payload byte1. More...
 
uint8_t dataByte2
 MSCAN Frame payload byte2. More...
 
uint8_t dataByte3
 MSCAN Frame payload byte3. More...
 
uint8_t dataByte4
 MSCAN Frame payload byte4. More...
 
uint8_t dataByte5
 MSCAN Frame payload byte5. More...
 
uint8_t dataByte6
 MSCAN Frame payload byte6. More...
 
uint8_t dataByte7
 MSCAN Frame payload byte7. More...
 

Field Documentation

uint32_t mscan_frame_t::dataWord0
uint32_t mscan_frame_t::dataWord1
uint8_t mscan_frame_t::dataByte0
uint8_t mscan_frame_t::dataByte1
uint8_t mscan_frame_t::dataByte2
uint8_t mscan_frame_t::dataByte3
uint8_t mscan_frame_t::dataByte4
uint8_t mscan_frame_t::dataByte5
uint8_t mscan_frame_t::dataByte6
uint8_t mscan_frame_t::dataByte7
struct mscan_idfilter_config_t

Data Fields

mscan_id_filter_mode_t filterMode
 MSCAN Identifier Acceptance Filter Mode.
 
uint32_t u32IDAR0
 MSCAN Identifier Acceptance Register n of First Bank.
 
uint32_t u32IDAR1
 MSCAN Identifier Acceptance Register n of Second Bank.
 
uint32_t u32IDMR0
 MSCAN Identifier Mask Register n of First Bank.
 
uint32_t u32IDMR1
 MSCAN Identifier Mask Register n of Second Bank.
 
struct mscan_config_t

Data Fields

uint32_t baudRate
 MsCAN baud rate in bps. More...
 
bool enableTimer
 Enable or Disable free running timer. More...
 
bool enableWakeup
 Enable or Disable Wakeup Mode. More...
 
mscan_clock_source_t clkSrc
 Clock source for MsCAN Protocol Engine. More...
 
bool enableLoopBack
 Enable or Disable Loop Back Self Test Mode. More...
 
bool enableListen
 Enable or Disable Listen Only Mode. More...
 
mscan_busoffrec_mode_t busoffrecMode
 Bus-Off Recovery Mode. More...
 

Field Documentation

uint32_t mscan_config_t::baudRate
bool mscan_config_t::enableTimer
bool mscan_config_t::enableWakeup
mscan_clock_source_t mscan_config_t::clkSrc
bool mscan_config_t::enableLoopBack
bool mscan_config_t::enableListen
mscan_busoffrec_mode_t mscan_config_t::busoffrecMode
struct mscan_timing_config_t

Data Fields

uint8_t priDiv
 Baud rate prescaler. More...
 
uint8_t sJumpwidth
 Sync Jump Width. More...
 
uint8_t timeSeg1
 Time Segment 1. More...
 
uint8_t timeSeg2
 Time Segment 2. More...
 
uint8_t samp
 Number of samples per bit time. More...
 

Field Documentation

uint8_t mscan_timing_config_t::priDiv
uint8_t mscan_timing_config_t::sJumpwidth
uint8_t mscan_timing_config_t::timeSeg1
uint8_t mscan_timing_config_t::timeSeg2
uint8_t mscan_timing_config_t::samp
struct mscan_mb_transfer_t

Data Fields

mscan_frame_tframe
 The buffer of CAN Message to be transfer. More...
 
uint8_t mask
 The mask of Tx buffer. More...
 

Field Documentation

mscan_frame_t* mscan_mb_transfer_t::frame
uint8_t mscan_mb_transfer_t::mask
struct _mscan_handle

MsCAN handle structure definition.

Data Fields

mscan_transfer_callback_t callback
 Callback function. More...
 
void * userData
 MsCAN callback function parameter. More...
 
mscan_frame_t *volatile mbFrameBuf
 The buffer for received data from Message Buffers. More...
 
volatile uint8_t mbStateTx
 Message Buffer transfer state. More...
 
volatile uint8_t mbStateRx
 Message Buffer transfer state. More...
 

Field Documentation

mscan_transfer_callback_t mscan_handle_t::callback
void* mscan_handle_t::userData
mscan_frame_t* volatile mscan_handle_t::mbFrameBuf
volatile uint8_t mscan_handle_t::mbStateTx
volatile uint8_t mscan_handle_t::mbStateRx

Macro Definition Documentation

#define FSL_MSCAN_DRIVER_VERSION   (MAKE_VERSION(2, 0, 5))
#define MSCAN_RX_MB_STD_MASK (   id)
Value:
((uint32_t)((((uint32_t)(id)&0x7) << 21) | \
((((uint32_t)(id) >> 3) & 0xFF) << 24)))

Standard Rx Message Buffer Mask helper macro.

#define MSCAN_RX_MB_EXT_MASK (   id)
Value:
((uint32_t)(((((uint32_t)(id) >> 21) & 0xFF) << 24) | ((((uint32_t)(id) >> 18) & 0x7) << 21) | \
((((uint32_t)(id) >> 15) & 0x7) << 16) | (((((uint32_t)(id) >> 7) & 0xFF)) << 8) | \
(((uint32_t)(id)&0x7F) << 1)))

Typedef Documentation

typedef void(* mscan_transfer_callback_t)(MSCAN_Type *base, mscan_handle_t *handle, status_t status, void *userData)

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

Enumeration Type Documentation

anonymous enum
Enumerator
kStatus_MSCAN_TxBusy 

Tx Message Buffer is Busy.

kStatus_MSCAN_TxIdle 

Tx Message Buffer is Idle.

kStatus_MSCAN_TxSwitchToRx 

Remote Message is send out and Message buffer changed to Receive one.

kStatus_MSCAN_RxBusy 

Rx Message Buffer is Busy.

kStatus_MSCAN_RxIdle 

Rx Message Buffer is Idle.

kStatus_MSCAN_RxOverflow 

Rx Message Buffer is Overflowed.

kStatus_MSCAN_RxFifoBusy 

Rx Message FIFO is Busy.

kStatus_MSCAN_RxFifoIdle 

Rx Message FIFO is Idle.

kStatus_MSCAN_RxFifoOverflow 

Rx Message FIFO is overflowed.

kStatus_MSCAN_RxFifoWarning 

Rx Message FIFO is almost overflowed.

kStatus_MSCAN_ErrorStatus 

FlexCAN Module Error and Status.

kStatus_MSCAN_UnHandled 

UnHadled Interrupt asserted.

Enumerator
kMSCAN_FrameFormatStandard 

Standard frame format attribute.

kMSCAN_FrameFormatExtend 

Extend frame format attribute.

Enumerator
kMSCAN_FrameTypeData 

Data frame type attribute.

kMSCAN_FrameTypeRemote 

Remote frame type attribute.

Enumerator
kMSCAN_ClkSrcOsc 

MsCAN Protocol Engine clock from Oscillator.

kMSCAN_ClkSrcBus 

MsCAN Protocol Engine clock from Bus Clock.

Enumerator
kMSCAN_BusoffrecAuto 

MsCAN automatic bus-off recovery.

kMSCAN_BusoffrecUsr 

MsCAN bus-off recovery upon user request.

Enumerator
kMSCAN_TxBuf0Empty 

MsCAN Tx Buffer 0 empty.

kMSCAN_TxBuf1Empty 

MsCAN Tx Buffer 1 empty.

kMSCAN_TxBuf2Empty 

MsCAN Tx Buffer 2 empty.

kMSCAN_TxBufFull 

MsCAN Tx Buffer all not empty.

Enumerator
kMSCAN_Filter32Bit 

Two 32-bit acceptance filters.

kMSCAN_Filter16Bit 

Four 16-bit acceptance filters.

kMSCAN_Filter8Bit 

Eight 8-bit acceptance filters.

kMSCAN_FilterClose 

Filter closed.

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

Enumerator
kMSCAN_WakeUpInterruptEnable 

Wake Up interrupt.

kMSCAN_StatusChangeInterruptEnable 

Status change interrupt.

kMSCAN_RxStatusChangeInterruptEnable 

Rx status change interrupt.

kMSCAN_TxStatusChangeInterruptEnable 

Tx status change interrupt.

kMSCAN_OverrunInterruptEnable 

Overrun interrupt.

kMSCAN_RxFullInterruptEnable 

Rx buffer full interrupt.

kMSCAN_TxEmptyInterruptEnable 

Tx buffer empty interrupt.

Function Documentation

void MSCAN_Init ( MSCAN_Type *  base,
const mscan_config_t config,
uint32_t  sourceClock_Hz 
)

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

* mscan_config_t mscanConfig;
* mscanConfig.clkSrc = kMSCAN_ClkSrcOsc;
* mscanConfig.baudRate = 1250000U;
* mscanConfig.enableTimer = false;
* mscanConfig.enableLoopBack = false;
* mscanConfig.enableWakeup = false;
* mscanConfig.enableListen = false;
* mscanConfig.filterConfig.filterMode = kMSCAN_Filter32Bit;
* MSCAN_Init(MSCAN, &mscanConfig, 8000000UL);
*
Parameters
baseMsCAN peripheral base address.
configPointer to the user-defined configuration structure.
sourceClock_HzMsCAN Protocol Engine clock source frequency in Hz.
void MSCAN_Deinit ( MSCAN_Type *  base)

This function disables the MsCAN module clock and sets all register values to the reset value.

Parameters
baseMsCAN peripheral base address.
void MSCAN_GetDefaultConfig ( mscan_config_t config)

This function initializes the MsCAN configuration structure to default values.

Parameters
configPointer to the MsCAN configuration structure.
static uint8_t MSCAN_GetTxBufferEmptyFlag ( MSCAN_Type *  base)
inlinestatic

This flag indicates that the associated transmit message buffer is empty.

Parameters
baseMsCAN peripheral base address.
static void MSCAN_TxBufferSelect ( MSCAN_Type *  base,
uint8_t  txBuf 
)
inlinestatic

To get the next available transmit buffer, read the CANTFLG register and write its value back into the CANTBSEL register.

Parameters
baseMsCAN peripheral base address.
txBufThe value read from CANTFLG.
static uint8_t MSCAN_GetTxBufferSelect ( MSCAN_Type *  base)
inlinestatic

After write TFLG value back into the CANTBSEL register, read again CANBSEL to get the actual trasnsmit message buffer.

Parameters
baseMsCAN peripheral base address.
static void MSCAN_TxBufferLaunch ( MSCAN_Type *  base,
uint8_t  txBuf 
)
inlinestatic

The CPU must clear the flag after a message is set up in the transmit buffer and is due for transmission.

Parameters
baseMsCAN peripheral base address.
txBufMessage buffer(s) to be cleared.
static uint8_t MSCAN_GetTxBufferStatusFlags ( MSCAN_Type *  base,
uint8_t  mask 
)
inlinestatic

The bit is set after successful transmission.

Parameters
baseMsCAN peripheral base address.
maskMessage buffer(s) mask.
static uint8_t MSCAN_GetRxBufferFullFlag ( MSCAN_Type *  base)
inlinestatic

RXF is set by the MSCAN when a new message is shifted in the receiver FIFO. This flag indicates whether the shifted buffer is loaded with a correctly received message.

Parameters
baseMsCAN peripheral base address.
static void MSCAN_ClearRxBufferFullFlag ( MSCAN_Type *  base)
inlinestatic

After the CPU has read that message from the RxFG buffer in the receiver FIFO The RXF flag must be cleared to release the buffer.

Parameters
baseMsCAN peripheral base address.
void MSCAN_SetTimingConfig ( MSCAN_Type *  base,
const mscan_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 MSCAN_Init() and fill the baud rate field with a desired value. This provides the default timing characteristics to the module.

Note that calling MSCAN_SetTimingConfig() overrides the baud rate set in MSCAN_Init().

Parameters
baseMsCAN peripheral base address.
configPointer to the timing configuration structure.
static uint8_t MSCAN_GetTxBufEmptyFlags ( MSCAN_Type *  base)
inlinestatic

This function gets MsCAN Tx buffer empty flags. It's returned as the value of the enumerators _mscan_tx_buffer_empty_flag.

Parameters
baseMsCAN peripheral base address.
Returns
Tx buffer empty flags in the _mscan_tx_buffer_empty_flag.
static void MSCAN_EnableTxInterrupts ( MSCAN_Type *  base,
uint8_t  mask 
)
inlinestatic

This function enables the MsCAN Tx empty interrupts according to the mask.

Parameters
baseMsCAN peripheral base address.
maskThe Tx interrupts mask to enable.
static void MSCAN_DisableTxInterrupts ( MSCAN_Type *  base,
uint8_t  mask 
)
inlinestatic

This function disables the MsCAN Tx emtpy interrupts according to the mask.

Parameters
baseMsCAN peripheral base address.
maskThe Tx interrupts mask to disable.
static void MSCAN_EnableRxInterrupts ( MSCAN_Type *  base,
uint8_t  mask 
)
inlinestatic

This function enables the MsCAN Rx interrupts according to the provided mask which is a logical OR of enumeration members, see _mscan_interrupt_enable.

Parameters
baseMsCAN peripheral base address.
maskThe interrupts to enable. Logical OR of _mscan_interrupt_enable.
static void MSCAN_DisableRxInterrupts ( MSCAN_Type *  base,
uint8_t  mask 
)
inlinestatic

This function disables the MsCAN Rx interrupts according to the provided mask which is a logical OR of enumeration members, see _mscan_interrupt_enable.

Parameters
baseMsCAN peripheral base address.
maskThe interrupts to disable. Logical OR of _mscan_interrupt_enable.
static void MSCAN_AbortTxRequest ( MSCAN_Type *  base,
uint8_t  mask 
)
inlinestatic

This function allows abort request of queued messages.

Parameters
baseMsCAN peripheral base address.
maskThe Tx mask to abort.
static void MSCAN_Enable ( MSCAN_Type *  base,
bool  enable 
)
inlinestatic

This function enables or disables the MsCAN module.

Parameters
baseMsCAN base pointer.
enabletrue to enable, false to disable.
status_t MSCAN_WriteTxMb ( MSCAN_Type *  base,
mscan_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
baseMsCAN peripheral base address.
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 MSCAN_ReadRxMb ( MSCAN_Type *  base,
mscan_frame_t pRxFrame 
)

This function reads a CAN message from a specified Receive Message Buffer. The function fills a receive CAN message frame structure with just received data and activates the Message Buffer again. The function returns immediately.

Parameters
baseMsCAN peripheral base address.
pRxFramePointer to CAN message frame structure for reception.
Return values
kStatus_Success- Rx Message Buffer is full and has been read successfully.
kStatus_Fail- Rx Message Buffer is empty.
void MSCAN_TransferCreateHandle ( MSCAN_Type *  base,
mscan_handle_t *  handle,
mscan_transfer_callback_t  callback,
void *  userData 
)

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

Parameters
baseMsCAN peripheral base address.
handleMsCAN handle pointer.
callbackThe callback function.
userDataThe parameter of the callback function.
status_t MSCAN_TransferSendBlocking ( MSCAN_Type *  base,
mscan_frame_t pTxFrame 
)

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

Parameters
baseMsCAN peripheral base pointer.
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 MSCAN_TransferReceiveBlocking ( MSCAN_Type *  base,
mscan_frame_t pRxFrame 
)

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

Parameters
baseMsCAN peripheral base pointer.
pRxFramePointer to CAN message frame to be received.
Return values
kStatus_Success- Read Rx Message Buffer Successfully.
kStatus_Fail- Tx Message Buffer is currently in use.
status_t MSCAN_TransferSendNonBlocking ( MSCAN_Type *  base,
mscan_handle_t *  handle,
mscan_mb_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
baseMsCAN peripheral base address.
handleMsCAN handle pointer.
xferMsCAN Message Buffer transfer structure. See the mscan_mb_transfer_t.
Return values
kStatus_SuccessStart Tx Message Buffer sending process successfully.
kStatus_FailWrite Tx Message Buffer failed.
status_t MSCAN_TransferReceiveNonBlocking ( MSCAN_Type *  base,
mscan_handle_t *  handle,
mscan_mb_transfer_t xfer 
)

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

Parameters
baseMsCAN peripheral base address.
handleMsCAN handle pointer.
xferMsCAN Message Buffer transfer structure. See the mscan_mb_transfer_t.
Return values
kStatus_Success- Start Rx Message Buffer receiving process successfully.
kStatus_MSCAN_RxBusy- Rx Message Buffer is in use.
void MSCAN_TransferAbortSend ( MSCAN_Type *  base,
mscan_handle_t *  handle,
uint8_t  mask 
)

This function aborts the interrupt driven message send process.

Parameters
baseMsCAN peripheral base address.
handleMsCAN handle pointer.
maskThe MsCAN Tx Message Buffer mask.
void MSCAN_TransferAbortReceive ( MSCAN_Type *  base,
mscan_handle_t *  handle,
uint8_t  mask 
)

This function aborts the interrupt driven message receive process.

Parameters
baseMsCAN peripheral base address.
handleMsCAN handle pointer.
maskThe MsCAN Rx Message Buffer mask.
void MSCAN_TransferHandleIRQ ( MSCAN_Type *  base,
mscan_handle_t *  handle 
)

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

Parameters
baseMSCAN peripheral base address.
handleMSCAN handle pointer.