SemiDrive SSDK Appication Program Interface PTG3.0
Data Structures | Typedefs | Enumerations | Functions
sdrv_flexcan.h File Reference
#include <stdbool.h>
#include <types.h>
#include "../source/flexcan/sdrv_flexcan_priv.h"
#include <sdrv_common.h>

Go to the source code of this file.

Data Structures

struct  flexcan_fd_config_t
 
struct  flexcan_pn_id_filter_t
 
struct  flexcan_pn_payload_filter_t
 
struct  flexcan_pn_config_t
 
struct  flexcan_timing_config_t
 
struct  flexcan_config_t
 
struct  flexcan_rx_fifo_filter_table
 
struct  flexcan_rx_fifo_config_t
 
struct  _flexcan_rx_mb_config
 
struct  _flexcan_frame
 
struct  _flexcan_mb_transfer
 
struct  _flexcan_fifo_transfer
 
struct  _flexcan_handle
 

Typedefs

typedef struct _flexcan_rx_mb_config flexcan_rx_mb_config_t
 
typedef void(* flexcan_transfer_callback_t) (flexcan_handle_t *handle, flexcan_status_e status, uint32_t result, void *userData)
 

Enumerations

enum  _flexcan_interrupt_enable {
  FLEXCAN_BusOffInterruptEnable , FLEXCAN_ErrorInterruptEnable , FLEXCAN_RxWarningInterruptEnable , FLEXCAN_TxWarningInterruptEnable ,
  FLEXCAN_WakeUpInterruptEnable
}
 

Functions

void flexcan_create_handle (flexcan_handle_t *handle, uint8_t controller_id, void *reg_base, uint8_t irq_num, flexcan_transfer_callback_t callback, void *userData)
 
flexcan_status_e flexcan_init (flexcan_handle_t *handle, const flexcan_config_t *config)
 
flexcan_status_e flexcan_enable (flexcan_handle_t *handle, bool enable)
 
flexcan_status_e flexcan_freeze (flexcan_handle_t *handle, bool freeze)
 
flexcan_status_e flexcan_reset (flexcan_handle_t *handle)
 
void flexcan_deinit (flexcan_handle_t *handle)
 
void flexcan_classic_set_timing_config (flexcan_handle_t *handle, const flexcan_timing_config_t *config)
 
void flexcan_fd_set_timing_config (flexcan_handle_t *handle, const flexcan_timing_config_t *arbitrPhaseConfig, const flexcan_timing_config_t *dataPhaseConfig)
 
void flexcan_read_wmb (flexcan_handle_t *handle, uint8_t wmbIndex, flexcan_frame_t *wmb)
 
flexcan_status_e flexcan_request_sleep (flexcan_handle_t *handle, bool request)
 
void flexcan_set_rx_mb_global_mask (flexcan_handle_t *handle, uint32_t mask)
 
void flexcan_set_rx_fifo_global_mask (flexcan_handle_t *handle, uint32_t mask)
 
void flexcan_set_rx_individual_mask (flexcan_handle_t *handle, uint8_t maskIdx, uint32_t mask)
 
void flexcan_set_tx_mb_config (flexcan_handle_t *handle, uint8_t mbIdx, bool tx_by_interrupt)
 
void flexcan_set_rx_mb_config (flexcan_handle_t *handle, uint8_t mbIdx, const flexcan_rx_mb_config_t *config)
 
void flexcan_set_rx_fifo_config (flexcan_handle_t *handle, const flexcan_rx_fifo_config_t *config)
 
void flexcan_enable_interrupts (flexcan_handle_t *handle, uint32_t mask)
 
void flexcan_disable_interrupts (flexcan_handle_t *handle, uint32_t mask)
 
uint32_t flexcan_get_mb_iflag (flexcan_handle_t *handle, uint8_t msgBufId)
 
flexcan_status_e flexcan_send_nonblocking (flexcan_handle_t *handle, flexcan_mb_transfer_t *xfer, uint8_t padding_val)
 
flexcan_status_e flexcan_receive_nonblocking (flexcan_handle_t *handle, flexcan_mb_transfer_t *xfer)
 
flexcan_status_e flexcan_receive_fifo_nonblocking (flexcan_handle_t *handle, flexcan_fifo_transfer_t *xfer)
 
flexcan_status_e flexcan_write_tx_mb (flexcan_handle_t *handle, uint8_t mbIdx, const flexcan_frame_t *txFrame, uint8_t padding_val)
 
flexcan_status_e flexcan_read_rx_mb (flexcan_handle_t *handle, uint8_t mbIdx, flexcan_frame_t *rxFrame)
 
flexcan_status_e flexcan_read_rx_fifo (flexcan_handle_t *handle, flexcan_frame_t *rxFrame)
 
void flexcan_abort_mb_send (flexcan_handle_t *handle, uint8_t mbIdx)
 
void flexcan_abort_mb_receive (flexcan_handle_t *handle, uint8_t mbIdx)
 
void flexcan_abort_receive_fifo (flexcan_handle_t *handle)
 
uint32_t flexcan_read_mb_int_status (flexcan_handle_t *handle, uint8_t mbIdx)
 
uint8_t flexcan_get_mb_state (flexcan_handle_t *handle, uint8_t mbIdx)
 
bool flexcan_is_mb_occupied (flexcan_handle_t *handle, uint8_t mbIdx)
 
uint32_t flexcan_get_error_status (flexcan_handle_t *handle)
 
void flexcan_clear_err_status_flag (flexcan_handle_t *handle, uint32_t mask)
 
int flexcan_irq_handler (uint32_t irq, void *arg)
 

Detailed Description

Macro Definition Documentation

◆ CORE_LITTLE_ENDIAN

#define CORE_LITTLE_ENDIAN   1

◆ EXTENDED_DATA_ID

#define EXTENDED_DATA_ID   1U

◆ EXTENDED_REMOTE_ID

#define EXTENDED_REMOTE_ID   3U

◆ FLEXCAN_COPY_USE_BURST

#define FLEXCAN_COPY_USE_BURST   1

◆ FLEXCAN_HAS_DOZE_MODE_SUPPORT

#define FLEXCAN_HAS_DOZE_MODE_SUPPORT   1

◆ FlexCanRxFifoAcceptExtFrame

#define FlexCanRxFifoAcceptExtFrame   1UL

◆ FlexCanRxFifoAcceptRemoteFrame

#define FlexCanRxFifoAcceptRemoteFrame   1UL

◆ IDX_CONVERT

#define IDX_CONVERT (   x)    (((x) & 0xFCU) + 3U - ((x) & 3U))

◆ MAKE_TYPE_A_FILTER

#define MAKE_TYPE_A_FILTER (   id,
  type 
)     (((type) << 30) | ((id) << (((type)&1U) ? 1 : 19)))

◆ MAKE_TYPE_B_FILTER

#define MAKE_TYPE_B_FILTER (   id1,
  id2,
  type1,
  type2 
)
Value:
(((type1) << 30) | ((id1) << (((type1)&1U) ? 16 : 19)) | ((type2) << 14) | \
((id2) << (((type2)&1U) ? 0 : 3)))

◆ MAKE_TYPE_C_FILTER

#define MAKE_TYPE_C_FILTER (   id1,
  id2,
  id3,
  id4 
)     (((id1)&0xFFU) | ((id2)&0xFFU) | ((id3)&0xFFU) | ((id4)&0xFFU))

◆ STANDARD_DATA_ID

#define STANDARD_DATA_ID   0U

◆ STANDARD_REMOTE_ID

#define STANDARD_REMOTE_ID   2U

Typedef Documentation

◆ flexcan_clock_source_e

FlexCAN clock source.

◆ flexcan_config_t

◆ flexcan_controller_id_e

◆ flexcan_fd_config_t

◆ flexcan_fd_data_size_e

◆ flexcan_fifo_transfer_t

FlexCAN Rx FIFO transfer.

◆ flexcan_frame_format_e

FlexCAN frame format.

◆ flexcan_frame_t

◆ flexcan_frame_type_e

FlexCAN frame type.

◆ flexcan_handle_t

FlexCAN handle structure definition.

◆ flexcan_mb_transfer_t

FlexCAN Message Buffer transfer.

◆ flexcan_pn_config_t

◆ flexcan_rx_fifo_config_t

◆ flexcan_rx_fifo_filter_table_t

◆ flexcan_rx_fifo_filter_type_e

◆ flexcan_rx_fifo_priority_e

◆ flexcan_rx_mb_config_t

FlexCAN Receive Message Buffer configuration structure.

This structure is used as the parameter of FLEXCAN_SetRxMbConfig() function. The FLEXCAN_SetRxMbConfig() function is used to configure FlexCAN Receive Message Buffer. The function abort previous receiving process, clean the Message Buffer and activate the Rx Message Buffer using given Message Buffer setting.

◆ flexcan_status_e

FlexCAN transfer status.

◆ flexcan_timing_config_t

◆ flexcan_transfer_callback_t

typedef void(* flexcan_transfer_callback_t) (flexcan_handle_t *handle, flexcan_status_e status, uint32_t result, void *userData)

FlexCAN transfer callback function.

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

Enumeration Type Documentation

◆ _flexcan_interrupt_enable

FlexCAN interrupt configuration structure, default settings all disabled.

This structure contains the settings for all of the FlexCAN Module interrupt configurations. Note: FlexCAN Message Buffers and Rx FIFO have their own interrupts.

Enumerator
FLEXCAN_BusOffInterruptEnable 

CAN_CTRL1_BOFFMSK_MASK, Bus Off interrupt.

FLEXCAN_ErrorInterruptEnable 

CAN_CTRL1_ERRMSK_MASK, Error interrupt.

FLEXCAN_RxWarningInterruptEnable 

CAN_CTRL1_RWRNMSK_MASK, Rx Warning interrupt.

FLEXCAN_TxWarningInterruptEnable 

CAN_CTRL1_TWRNMSK_MASK, Tx Warning interrupt.

FLEXCAN_WakeUpInterruptEnable 

CAN_MCR_WAKMSK_MASK, Wake Up interrupt.

◆ _flexcan_status

FlexCAN transfer status.

Enumerator
FLEXCAN_SUCCESS 

Operation succeeds.

FLEXCAN_FAIL 

Operation fails.

FLEXCAN_TX_BUSY 

Tx Message Buffer is Busy.

FLEXCAN_TX_IDLE 

Tx Message Buffer is Idle.

FLEXCAN_TX_SWITCH_TO_RX 

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

FLEXCAN_RX_BUSY 

Rx Message Buffer is Busy.

FLEXCAN_RX_IDLE 

Rx Message Buffer is Idle.

FLEXCAN_RX_OVERFLOW 

Rx Message Buffer is Overflowed.

FLEXCAN_RX_FIFO_BUSY 

Rx Message FIFO is Busy.

FLEXCAN_RX_FIFO_IDLE 

Rx Message FIFO is Idle.

FLEXCAN_RX_FIFO_OVERFLOW 

Rx Message FIFO is overflowed.

FLEXCAN_RX_FIFO_WARNING 

Rx Message FIFO is almost overflowed.

FLEXCAN_ERROR_STATUS 

FlexCAN Module Error and Status.

FLEXCAN_WAKEUP_TIMEOUT 

An wake up event occurred due to timeout.

FLEXCAN_WAKEUP_MATCH 

An wake up event occurred due to matching.

FLEXCAN_UNHANDLED 

UnHadled Interrupt asserted.

◆ flexcan_clock_source

FlexCAN clock source.

Enumerator
FLEXCAN_ClkSrcOsc 

FlexCAN Protocol Engine clock from Oscillator.

FLEXCAN_ClkSrcPeri 

FlexCAN Protocol Engine clock from Peripheral Clock.

◆ flexcan_controller_id

Enumerator
FLEXCAN1 
FLEXCAN2 
FLEXCAN3 
FLEXCAN4 
FLEXCAN5 
FLEXCAN6 
FLEXCAN7 
FLEXCAN8 
FLEXCAN9 
FLEXCAN10 
FLEXCAN11 
FLEXCAN12 
FLEXCAN13 
FLEXCAN14 
FLEXCAN15 
FLEXCAN16 
FLEXCAN17 
FLEXCAN18 
FLEXCAN19 
FLEXCAN20 
FLEXCAN21 
FLEXCAN22 
FLEXCAN23 
FLEXCAN24 
MAX_FLEXCAN_CH 

◆ flexcan_fd_data_size

Enumerator
CAN_FD_8BYTES_PER_MB 

8 bytes per message buffer.

CAN_FD_16BYTES_PER_MB 

16 bytes per message buffer.

CAN_FD_32BYTES_PER_MB 

32 bytes per message buffer.

CAN_FD_64BYTES_PER_MB 

64 bytes per message buffer.

◆ flexcan_frame_format

FlexCAN frame format.

Enumerator
FLEXCAN_STANDARD_FRAME 

Standard frame format attribute.

FLEXCAN_EXTEND_FRAME 

Extend frame format attribute.

◆ flexcan_frame_type

FlexCAN frame type.

Enumerator
FLEXCAN_FrameTypeData 

Data frame type attribute.

FLEXCAN_FrameTypeRemote 

Remote frame type attribute.

◆ flexcan_pn_filter_combination_e

Pretended Networking filtering combinations.

Enumerator
FLEXCAN_FILTER_ID 

Message ID filtering only

FLEXCAN_FILTER_ID_PAYLOAD 

Message ID and payload filtering

FLEXCAN_FILTER_ID_NTIMES 

Message ID filtering occurring a specified number of times

FLEXCAN_FILTER_ID_PAYLOAD_NTIMES 

Message ID and payload filtering occurring a specified number of times

◆ flexcan_pn_filter_selection_e

Pretended Networking matching schemes.

Enumerator
FLEXCAN_FILTER_MATCH_EXACT 

Match an exact target value.

FLEXCAN_FILTER_MATCH_GEQ 

Match greater than or equal to a specified target value.

FLEXCAN_FILTER_MATCH_LEQ 

Match less than or equal to a specified target value.

FLEXCAN_FILTER_MATCH_RANGE 

Match inside a range, greater than or equal to a specified lower limit and smaller than or equal to a specified upper limit.

◆ flexcan_rx_fifo_filter_type

Enumerator
FLEXCAN_RxFifoFilterTypeA 

One full ID (standard and extended) per ID Filter element.

FLEXCAN_RxFifoFilterTypeB 

Two full standard IDs or two partial 14-bit ID slices per ID Filter Table element.

FLEXCAN_RxFifoFilterTypeC 

Four partial 8-bit Standard or extended ID slices per ID Filter Table element.

FLEXCAN_RxFifoFilterTypeD 

All frames rejected.

◆ flexcan_rx_fifo_priority

Enumerator
FLEXCAN_RxFifoPrioLow 

Matching process start from Rx Message Buffer first

FLEXCAN_RxFifoPrioHigh 

Matching process start from Rx FIFO first

Function Documentation

◆ flexcan_abort_mb_receive()

void flexcan_abort_mb_receive ( flexcan_handle_t handle,
uint8_t  mbIdx 
)

Abort interrupt driven message receive process.

This function abort interrupt driven message receive process.

Parameters
[in]handleFlexCAN handle.
[in]mbIdxThe FlexCAN Message Buffer index.

◆ flexcan_abort_mb_send()

void flexcan_abort_mb_send ( flexcan_handle_t handle,
uint8_t  mbIdx 
)

Abort interrupt driven message send process.

This function aborts interrupt driven message send process.

Parameters
[in]handleFlexCAN handle.
[in]mbIdxThe FlexCAN Message Buffer index.

◆ flexcan_abort_receive_fifo()

void flexcan_abort_receive_fifo ( flexcan_handle_t handle)

Abort interrupt driven message receive from Rx FIFO process.

This function abort interrupt driven message receive from Rx FIFO process.

Parameters
[in]handleFlexCAN handle.

◆ flexcan_classic_set_timing_config()

void flexcan_classic_set_timing_config ( flexcan_handle_t handle,
const flexcan_timing_config_t config 
)

Setting FlexCAN classic protocol timing characteristic.

This function give user fine settings to CAN bus timing characteristic. The function is for user who is really versed in CAN protocol, for these users who just what to establish CAN communication among MCUs, just call flexcan_init() and fill the baud rate field with desired one. Doing this, default timing characteristic will provide to the module.

Note: Calling flexcan_classic_set_timing_config() will override the baud rate setted in flexcan_init().

Parameters
[in]handleFlexCAN handle.
[in]configPointer to the timing configuration structure.

◆ flexcan_clear_err_status_flag()

void flexcan_clear_err_status_flag ( flexcan_handle_t handle,
uint32_t  mask 
)

Clear all error interrupt status.

Parameters
[in]handleFlexCAN handle.
[in]maskFlexCAN status flags.

◆ flexcan_create_handle()

void flexcan_create_handle ( flexcan_handle_t handle,
uint8_t  controller_id,
void *  reg_base,
uint8_t  irq_num,
flexcan_transfer_callback_t  callback,
void *  userData 
)

Initialize the FlexCAN handle.

This function initializes the FlexCAN handle which can be used for other FlexCAN APIs. Usually, for a specified FlexCAN instance, user only need to call this API once to get the initialized handle. NOTE: This function should be called before all the other FlexCAN APIs.

Parameters
[in]handleFlexCAN handle pointer.
[in]controller_idFlexCAN controller_id.
[in]reg_baseFlexCAN peripheral base address.
[in]irq_numirq number.
[in]callbackThe callback function.
[in]userDataThe parameter of the callback function.

◆ flexcan_deinit()

void flexcan_deinit ( flexcan_handle_t handle)

De-initializes a FlexCAN instance.

This function disable the FlexCAN module clock and set all register value to reset value.

Parameters
[in]handleFlexCAN handle.

◆ flexcan_disable_interrupts()

void flexcan_disable_interrupts ( flexcan_handle_t handle,
uint32_t  mask 
)

Disable FlexCAN interrupts according to provided mask.

This function disables the FlexCAN interrupts according to provided mask. The mask is a logical OR of enumeration members, see _flexcan_interrupt_enable.

Parameters
[in]handleFlexCAN handle.
[in]maskThe interrupts to disable. Logical OR of _flexcan_interrupt_enable.

◆ flexcan_enable()

flexcan_status_e flexcan_enable ( flexcan_handle_t handle,
bool  enable 
)

Enables or disable the FlexCAN module operation.

This function enables or disables the FlexCAN module.

Parameters
[in]handleFlexCAN handle.
[in]enabletrue to enable, false to disable.
Return values
FLEXCAN_SUCCESSoperate successfully
FLEXCAN_FAILoperate timeout

◆ flexcan_enable_interrupts()

void flexcan_enable_interrupts ( flexcan_handle_t handle,
uint32_t  mask 
)

Enable FlexCAN interrupts according to provided mask.

This function enables the FlexCAN interrupts according to provided mask. The mask is a logical OR of enumeration members, see _flexcan_interrupt_enable.

Parameters
[in]handleFlexCAN handle.
[in]maskThe interrupts to enable. Logical OR of _flexcan_interrupt_enable.

◆ flexcan_fd_set_timing_config()

void flexcan_fd_set_timing_config ( flexcan_handle_t handle,
const flexcan_timing_config_t arbitrPhaseConfig,
const flexcan_timing_config_t dataPhaseConfig 
)

Setting FlexCAN FD protocol timing characteristic.

This function give user fine settings to CAN bus timing characteristic. The function is for user who is really versed in CAN protocol, for these users who just what to establish CAN communication among MCUs, just call flexcan_init() and fill the baud rate field with desired one. Doing this, default timing characteristic will provide to the module.

Note: Calling flexcan_fd_set_timing_config() will override the baud rate setted in flexcan_init().

Parameters
[in]handleFlexCAN handle.
[in]arbitrPhaseConfigPointer to the arbitration phase timing configuration structure.
[in]dataPhaseConfigPointer to the data phase timing configuration structure.

◆ flexcan_freeze()

flexcan_status_e flexcan_freeze ( flexcan_handle_t handle,
bool  freeze 
)

Enter or exit freeze mode.

This function makes the FlexCAN work under Freeze Mode if param freeze is true, or work under Normal Mode if param freeze is false.

Parameters
[in]handleFlexCAN handle.
[in]freezetrue to enter freeze mode, false to exit freeze mode
Return values
FLEXCAN_SUCCESSoperate successfully
FLEXCAN_FAILoperate timeout

◆ flexcan_get_error_status()

uint32_t flexcan_get_error_status ( flexcan_handle_t handle)

Get reported error conditons detected in the reception and transmission.

Parameters
[in]handleFlexCAN handle.
Return values
valueof register ESR1.

◆ flexcan_get_mb_iflag()

uint32_t flexcan_get_mb_iflag ( flexcan_handle_t handle,
uint8_t  msgBufId 
)

Get mailbox interrupt flag.

Parameters
[in]handleFlexCAN handle.
[in]msgBufIdThe FlexCAN Message Buffer index.
Return values
flagvalue of MB.

◆ flexcan_get_mb_state()

uint8_t flexcan_get_mb_state ( flexcan_handle_t handle,
uint8_t  mbIdx 
)

Get MB state.

Parameters
[in]handleFlexCAN handle.
[in]mbIdxThe FlexCAN Message Buffer index.
Returns
uint8_t flexcan mb state.

◆ flexcan_init()

flexcan_status_e flexcan_init ( flexcan_handle_t handle,
const flexcan_config_t config 
)

Initializes a FlexCAN instance.

This function initializes the FlexCAN module with user-defined settings. This example shows how to set up the flexcan_config_t parameters and how to call the flexcan_init function by passing in these parameters:

flexcan_config_t flexcanConfig;
flexcanConfig.clkSrc = FLEXCAN_ClkSrcOsc;
flexcanConfig.maxMbNum = 14;
flexcanConfig.enableLoopBack = false;
flexcanConfig.enableListenOnly = false;
flexcanConfig.enableSelfWakeup = false;
flexcanConfig.enableIndividMask = false;
flexcanConfig.enableDoze = false;
flexcanConfig.enableCANFD = false;
flexcanConfig.nominalBitTiming.preDivider = 0U;
flexcanConfig.nominalBitTiming.rJumpwidth = 1U;
flexcanConfig.nominalBitTiming.propSeg = 3U;
flexcanConfig.nominalBitTiming.phaseSeg1 = 4U;
flexcanConfig.nominalBitTiming.phaseSeg2 = 2U;
flexcan_init(&handle, &flexcanConfig);
flexcan_status_e flexcan_init(flexcan_handle_t *handle, const flexcan_config_t *config)
Initializes a FlexCAN instance.
@ FLEXCAN_ClkSrcOsc
Definition: sdrv_flexcan.h:69
FlexCAN handle structure.
Definition: sdrv_flexcan.h:357
Definition: sdrv_flexcan.h:193
bool enableCANFD
Definition: sdrv_flexcan.h:202
flexcan_clock_source_e clkSrc
Definition: sdrv_flexcan.h:194
bool enableLoopBack
Definition: sdrv_flexcan.h:196
bool enableSelfWakeup
Definition: sdrv_flexcan.h:199
flexcan_timing_config_t nominalBitTiming
Definition: sdrv_flexcan.h:204
uint8_t maxMbNum
Definition: sdrv_flexcan.h:195
bool enableDoze
Definition: sdrv_flexcan.h:201
bool enableListenOnly
Definition: sdrv_flexcan.h:198
bool enableIndividMask
Definition: sdrv_flexcan.h:200
uint8_t phaseSeg2
Definition: sdrv_flexcan.h:190
uint8_t phaseSeg1
Definition: sdrv_flexcan.h:189
uint8_t rJumpwidth
Definition: sdrv_flexcan.h:187
uint16_t preDivider
Definition: sdrv_flexcan.h:186
uint8_t propSeg
Definition: sdrv_flexcan.h:188

NOTE: The FlexCAN handle must be created before initializing self.

Parameters
[in]handleFlexCAN handle.
[in]configPointer to user-defined configuration structure.
Return values
FLEXCAN_SUCCESSoperate successfully
FLEXCAN_FAILoperate timeout

◆ flexcan_irq_handler()

int flexcan_irq_handler ( uint32_t  irq,
void *  arg 
)

FlexCAN IRQ handle function.

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

Parameters
[in]irqirq number.
[in]argFlexCAN handle.

◆ flexcan_is_mb_occupied()

bool flexcan_is_mb_occupied ( flexcan_handle_t handle,
uint8_t  mbIdx 
)

check whether mb is occupied by fifo along with filter table.

Parameters
[in]handleFlexCAN handle.
[in]mbIdxThe FlexCAN Message Buffer index.
Return values
TRUE- MB is occupied.
FALSE- MB isn't occupied.

◆ flexcan_read_mb_int_status()

uint32_t flexcan_read_mb_int_status ( flexcan_handle_t handle,
uint8_t  mbIdx 
)

Read MB interrupt status.

Parameters
[in]handleFlexCAN handle.
[in]mbIdxThe FlexCAN Message Buffer index.
Returns
uint32_t If MB interupt triggered.

◆ flexcan_read_rx_fifo()

flexcan_status_e flexcan_read_rx_fifo ( flexcan_handle_t handle,
flexcan_frame_t rxFrame 
)

Read a FlexCAN Message from Rx FIFO.

This function Read a CAN message from the FlexCAN build-in Rx FIFO.

Parameters
[in]handleFlexCAN handle.
[out]rxFramePointer to CAN message frame structure.
Return values
FLEXCAN_SUCCESS- Read Message from Rx FIFO successfully.
FLEXCAN_FAIL- Rx FIFO is not enabled.

◆ flexcan_read_rx_mb()

flexcan_status_e flexcan_read_rx_mb ( flexcan_handle_t handle,
uint8_t  mbIdx,
flexcan_frame_t rxFrame 
)

Read a FlexCAN Message from Receive Message Buffer.

This function read a CAN message from a specified Receive Message Buffer. The function will fill receive CAN message frame structure with just received data and activate the Message Buffer again. The function will return immediately.

Parameters
[in]handleFlexCAN handle.
[in]mbIdxThe FlexCAN Message Buffer index.
[out]rxFramePointer to CAN message frame structure.
Return values
FLEXCAN_SUCCESS- Rx Message Buffer is full and has been read successfully.
FLEXCAN_RX_OVERFLOW- Rx Message Buffer is already overflowed and has been read successfully.
FLEXCAN_FAIL- Rx Message Buffer is empty.

◆ flexcan_read_wmb()

void flexcan_read_wmb ( flexcan_handle_t handle,
uint8_t  wmbIndex,
flexcan_frame_t wmb 
)

read a can message from wakeup message buffer.

Parameters
[in]handleFlexCAN handle.
[in]wmbIndexThe FlexCAN wakeup message Buffer Index.
[out]wmbPointer to frame buffer to store information of incoming rx message.

◆ flexcan_receive_fifo_nonblocking()

flexcan_status_e flexcan_receive_fifo_nonblocking ( flexcan_handle_t handle,
flexcan_fifo_transfer_t xfer 
)

Receive message from Rx FIFO using IRQ.

This function receive message using IRQ, this is non-blocking function, will return right away, when all messages have been received, the receive callback function will be called.

Parameters
[in]handleFlexCAN handle.
[in]xferFlexCAN Rx FIFO transfer structure, refer to flexcan_fifo_transfer_t.
Return values
FLEXCAN_SUCCESS- Start Rx FIFO receiving process successfully.
FLEXCAN_RX_FIFO_BUSY- Rx FIFO is currently in use.

◆ flexcan_receive_nonblocking()

flexcan_status_e flexcan_receive_nonblocking ( flexcan_handle_t handle,
flexcan_mb_transfer_t xfer 
)

Receive message using IRQ.

This function receive message using IRQ, this is non-blocking function, will return right away, when message have been received, the receive callback function will be called.

Parameters
[in]handleFlexCAN handle.
[in]xferFlexCAN Message Buffer transfer structure, refer to flexcan_mb_transfer_t.
Return values
FLEXCAN_SUCCESSStart Rx Message Buffer receiving process successfully.
FLEXCAN_RX_BUSYRx Message Buffer is in use.

◆ flexcan_request_sleep()

flexcan_status_e flexcan_request_sleep ( flexcan_handle_t handle,
bool  request 
)

Enter or exit lowpower mode.

This function makes the FlexCAN work under lowpower Mode if param request is true, or exit sleep Mode if param request is false.

Parameters
[in]handleFlexCAN handle.
[in]requesttrue to enter lowpower mode, false to exit lowpower mode.
Return values
FLEXCAN_SUCCESSoperate successfully
FLEXCAN_FAILoperate timeout

◆ flexcan_reset()

flexcan_status_e flexcan_reset ( flexcan_handle_t handle)

Reset the FlexCAN Instance.

Restores the FlexCAN module to reset state, notice that this function will set all the registers to reset state so the FlexCAN module can not work after calling this API.

Parameters
[in]handleFlexCAN handle.
Return values
FLEXCAN_SUCCESSoperate successfully
FLEXCAN_FAILoperate timeout

◆ flexcan_send_nonblocking()

flexcan_status_e flexcan_send_nonblocking ( flexcan_handle_t handle,
flexcan_mb_transfer_t xfer,
uint8_t  padding_val 
)

send message using IRQ

This function send message using IRQ, this is non-blocking function, will return right away, when message have been sent out, the send callback function will be called.

Parameters
[in]handleFlexCAN handle.
[in]xferFlexCAN Message Buffer transfer structure, refer to flexcan_mb_transfer_t.
[in]padding_valvalue used to pad unspecified data in CAN FD frames > 8bytes.
Return values
FLEXCAN_SUCCESSStart Tx Message Buffer sending process successfully.
FLEXCAN_FAILWrite Tx Message Buffer failed.
FLEXCAN_TX_BUSYTx Message Buffer is in use.

◆ flexcan_set_rx_fifo_config()

void flexcan_set_rx_fifo_config ( flexcan_handle_t handle,
const flexcan_rx_fifo_config_t config 
)

Configure the FlexCAN Rx FIFO.

This function Configure the Rx FIFO with given Rx FIFO configuration.

Parameters
[in]handleFlexCAN handle.
[in]configPointer to FlexCAN Rx FIFO configuration structure.

◆ flexcan_set_rx_fifo_global_mask()

void flexcan_set_rx_fifo_global_mask ( flexcan_handle_t handle,
uint32_t  mask 
)

Set the FlexCAN Receive FIFO Global Mask.

This function Set the global mask for FlexCAN FIFO in matching process.

Parameters
[in]handleFlexCAN handle.
[in]maskRx Fifo Global Mask value.

◆ flexcan_set_rx_individual_mask()

void flexcan_set_rx_individual_mask ( flexcan_handle_t handle,
uint8_t  maskIdx,
uint32_t  mask 
)

Set the FlexCAN Receive Individual Mask.

This function Set the Individual mask for FlexCAN matching process. The configuration is only effective when Rx Individual Mask is enabled in FLEXCAN_Init(). If Rx FIFO is disabled, the Individual Mask is applied to corresponding Message Buffer. If Rx FIFO is enabled, the Individual Mask for Rx FIFO occupied Message Buffer will be applied to Rx Filter with same index. What calls for special attention is that only the first 32 Individual Mask can be used as Rx FIFO Filter Mask.

Parameters
[in]handleFlexCAN handle.
[in]maskIdxThe Index of individual Mask.
[in]maskRx Individual Mask value.

◆ flexcan_set_rx_mb_config()

void flexcan_set_rx_mb_config ( flexcan_handle_t handle,
uint8_t  mbIdx,
const flexcan_rx_mb_config_t config 
)

Configure a FlexCAN Receive Message Buffer.

This function clean a FlexCAN build-in Message Buffer and configure it as a Receive Message Buffer.

Parameters
[in]handleFlexCAN handle.
[in]mbIdxThe Message Buffer index.
[in]configPointer to FlexCAN Message Buffer configuration structure.

◆ flexcan_set_rx_mb_global_mask()

void flexcan_set_rx_mb_global_mask ( flexcan_handle_t handle,
uint32_t  mask 
)

Set the FlexCAN Receive Message Buffer Global Mask.

This function Set the global mask for FlexCAN Message Buffer in matching process. The configuration is only effective when Rx Individual Mask is disabled in flexcan_init().

Parameters
[in]handleFlexCAN handle.
[in]maskRx Message Buffer Global Mask value.

◆ flexcan_set_tx_mb_config()

void flexcan_set_tx_mb_config ( flexcan_handle_t handle,
uint8_t  mbIdx,
bool  tx_by_interrupt 
)

Configure a FlexCAN Transmit Message Buffer.

This function abort privious transmission, clean the Message Buffer and configure it as a Transmit Message Buffer.

Parameters
[in]handleFlexCAN handle.
[in]mbIdxThe Message Buffer index.
[in]tx_by_interruptTx by interrupt (true) or polling (false).

◆ flexcan_write_tx_mb()

flexcan_status_e flexcan_write_tx_mb ( flexcan_handle_t handle,
uint8_t  mbIdx,
const flexcan_frame_t txFrame,
uint8_t  padding_val 
)

Write FlexCAN Message to Transmit Message Buffer.

This function write a CAN Message to the specified Transmit Message Buffer. and change the Message Buffer state to start CAN Message transmit, after that the function will return immediately.

Parameters
[in]handleFlexCAN handle.
[in]mbIdxThe FlexCAN Message Buffer index.
[in]txFramePointer to CAN message frame to be sent.
[in]padding_valvalue used to pad unspecified data in CAN FD frames > 8bytes.
Returns
FLEXCAN_SUCCESS - Write Tx Message Buffer Successfully. FLEXCAN_FAIL - Tx Message Buffer is currently in use.