S32 SDK
flexcan_driver.c File Reference
#include <assert.h>
#include <stdint.h>
#include <stdbool.h>
#include <stddef.h>
#include "flexcan_hw_access.h"
#include "flexcan_irq.h"
#include "interrupt_manager.h"

Go to the source code of this file.

Macros

#define FLEXCAN_MB_HANDLE_RXFIFO   0U
 

Functions

static status_t FLEXCAN_StartSendData (uint8_t instance, uint8_t mb_idx, const flexcan_data_info_t *tx_info, uint32_t msg_id, const uint8_t *mb_data, bool isBlocking)
 
static status_t FLEXCAN_StartRxMessageBufferData (uint8_t instance, uint8_t mb_idx, flexcan_msgbuff_t *data, bool isBlocking)
 
static status_t FLEXCAN_StartRxMessageFifoData (uint8_t instance, flexcan_msgbuff_t *data, bool isBlocking)
 
static void FLEXCAN_CompleteTransfer (uint8_t instance, uint32_t mb_idx)
 
static void FLEXCAN_CompleteRxMessageFifoData (uint8_t instance)
 
void FLEXCAN_DRV_SetBitrate (uint8_t instance, const flexcan_time_segment_t *bitrate)
 Sets the FlexCAN bit rate for standard frames or the arbitration phase of FD frames. More...
 
void FLEXCAN_DRV_SetBitrateCbt (uint8_t instance, const flexcan_time_segment_t *bitrate)
 Sets the FlexCAN bit rate for the data phase of FD frames (BRS enabled). More...
 
void FLEXCAN_DRV_GetBitrate (uint8_t instance, flexcan_time_segment_t *bitrate)
 Gets the FlexCAN bit rate for standard frames or the arbitration phase of FD frames. More...
 
void FLEXCAN_DRV_GetBitrateFD (uint8_t instance, flexcan_time_segment_t *bitrate)
 Gets the FlexCAN bit rate for the data phase of FD frames (BRS enabled). More...
 
void FLEXCAN_DRV_SetRxMaskType (uint8_t instance, flexcan_rx_mask_type_t type)
 Sets the Rx masking type. More...
 
void FLEXCAN_DRV_SetRxFifoGlobalMask (uint8_t instance, flexcan_msgbuff_id_type_t id_type, uint32_t mask)
 Sets the FlexCAN Rx FIFO global mask (standard or extended). More...
 
void FLEXCAN_DRV_SetRxMbGlobalMask (uint8_t instance, flexcan_msgbuff_id_type_t id_type, uint32_t mask)
 Sets the FlexCAN Rx MB global mask (standard or extended). More...
 
void FLEXCAN_DRV_SetRxMb14Mask (uint8_t instance, flexcan_msgbuff_id_type_t id_type, uint32_t mask)
 Sets the FlexCAN Rx MB 14 mask (standard or extended). More...
 
void FLEXCAN_DRV_SetRxMb15Mask (uint8_t instance, flexcan_msgbuff_id_type_t id_type, uint32_t mask)
 Sets the FlexCAN Rx MB 15 mask (standard or extended). More...
 
status_t FLEXCAN_DRV_SetRxIndividualMask (uint8_t instance, flexcan_msgbuff_id_type_t id_type, uint8_t mb_idx, uint32_t mask)
 Sets the FlexCAN Rx individual mask (standard or extended). More...
 
status_t FLEXCAN_DRV_Init (uint8_t instance, flexcan_state_t *state, const flexcan_user_config_t *data)
 Initializes the FlexCAN peripheral. More...
 
status_t FLEXCAN_DRV_ConfigTxMb (uint8_t instance, uint8_t mb_idx, const flexcan_data_info_t *tx_info, uint32_t msg_id)
 FlexCAN transmit message buffer field configuration. More...
 
status_t FLEXCAN_DRV_SendBlocking (uint8_t instance, uint8_t mb_idx, const flexcan_data_info_t *tx_info, uint32_t msg_id, const uint8_t *mb_data, uint32_t timeout_ms)
 Sends a CAN frame using the specified message buffer, in a blocking manner. More...
 
status_t FLEXCAN_DRV_Send (uint8_t instance, uint8_t mb_idx, const flexcan_data_info_t *tx_info, uint32_t msg_id, const uint8_t *mb_data)
 Sends a CAN frame using the specified message buffer. More...
 
status_t FLEXCAN_DRV_ConfigRxMb (uint8_t instance, uint8_t mb_idx, const flexcan_data_info_t *rx_info, uint32_t msg_id)
 FlexCAN receive message buffer field configuration. More...
 
void FLEXCAN_DRV_ConfigRxFifo (uint8_t instance, flexcan_rx_fifo_id_element_format_t id_format, const flexcan_id_table_t *id_filter_table)
 FlexCAN Rx FIFO field configuration. More...
 
status_t FLEXCAN_DRV_ReceiveBlocking (uint8_t instance, uint8_t mb_idx, flexcan_msgbuff_t *data, uint32_t timeout_ms)
 Receives a CAN frame using the specified message buffer, in a blocking manner. More...
 
status_t FLEXCAN_DRV_Receive (uint8_t instance, uint8_t mb_idx, flexcan_msgbuff_t *data)
 Receives a CAN frame using the specified message buffer. More...
 
status_t FLEXCAN_DRV_RxFifoBlocking (uint8_t instance, flexcan_msgbuff_t *data, uint32_t timeout_ms)
 Receives a CAN frame using the message FIFO, in a blocking manner. More...
 
status_t FLEXCAN_DRV_RxFifo (uint8_t instance, flexcan_msgbuff_t *data)
 Receives a CAN frame using the message FIFO. More...
 
status_t FLEXCAN_DRV_Deinit (uint8_t instance)
 Shuts down a FlexCAN instance. More...
 
void FLEXCAN_DRV_SetTDCOffset (uint8_t instance, bool enable, uint8_t offset)
 Enables/Disables the Transceiver Delay Compensation feature and sets the Transceiver Delay Compensation Offset (offset value to be added to the measured transceiver's loop delay in order to define the position of the delayed comparison point when bit rate switching is active). More...
 
uint8_t FLEXCAN_DRV_GetTDCValue (uint8_t instance)
 Gets the value of the Transceiver Delay Compensation. More...
 
bool FLEXCAN_DRV_GetTDCFail (uint8_t instance)
 Gets the value of the TDC Fail flag. More...
 
void FLEXCAN_DRV_ClearTDCFail (uint8_t instance)
 Clears the TDC Fail flag. More...
 
void FLEXCAN_IRQHandler (uint8_t instance)
 Interrupt handler for a FlexCAN instance. More...
 
status_t FLEXCAN_DRV_GetTransferStatus (uint8_t instance, uint8_t mb_idx)
 Returns whether the previous FlexCAN transfer has finished. More...
 
status_t FLEXCAN_DRV_AbortTransfer (uint8_t instance, uint8_t mb_idx)
 Ends a non-blocking FlexCAN transfer early. More...
 
void FLEXCAN_DRV_InstallEventCallback (uint8_t instance, flexcan_callback_t callback, void *callbackParam)
 Installs a callback function for the IRQ handler. More...
 
void FLEXCAN_DRV_GetDefaultConfig (flexcan_user_config_t *config)
 Gets the default configuration structure. More...
 

Variables

static CAN_Type *const g_flexcanBase [] = CAN_BASE_PTRS
 
static const IRQn_Type g_flexcanErrorIrqId [] = CAN_Error_IRQS
 
static const IRQn_Type g_flexcanBusOffIrqId [] = CAN_Bus_Off_IRQS
 
static const IRQn_Type g_flexcanOredMessageBufferIrqId [FEATURE_CAN_MB_IRQS_MAX_COUNT][CAN_INSTANCE_COUNT] = FEATURE_CAN_MB_IRQS
 
static flexcan_state_tg_flexcanStatePtr [CAN_INSTANCE_COUNT] = { NULL }
 

Macro Definition Documentation

#define FLEXCAN_MB_HANDLE_RXFIFO   0U

Definition at line 77 of file flexcan_driver.c.

Function Documentation

static void FLEXCAN_CompleteRxMessageFifoData ( uint8_t  instance)
static

Definition at line 1527 of file flexcan_driver.c.

static void FLEXCAN_CompleteTransfer ( uint8_t  instance,
uint32_t  mb_idx 
)
static

Definition at line 1481 of file flexcan_driver.c.

void FLEXCAN_IRQHandler ( uint8_t  instance)

Interrupt handler for a FlexCAN instance.

Parameters
instanceThe FlexCAN instance number.

Definition at line 1072 of file flexcan_driver.c.

static status_t FLEXCAN_StartRxMessageBufferData ( uint8_t  instance,
uint8_t  mb_idx,
flexcan_msgbuff_t data,
bool  isBlocking 
)
static

Definition at line 1349 of file flexcan_driver.c.

static status_t FLEXCAN_StartRxMessageFifoData ( uint8_t  instance,
flexcan_msgbuff_t data,
bool  isBlocking 
)
static

Definition at line 1393 of file flexcan_driver.c.

static status_t FLEXCAN_StartSendData ( uint8_t  instance,
uint8_t  mb_idx,
const flexcan_data_info_t tx_info,
uint32_t  msg_id,
const uint8_t *  mb_data,
bool  isBlocking 
)
static

Definition at line 1292 of file flexcan_driver.c.

Variable Documentation

CAN_Type* const g_flexcanBase[] = CAN_BASE_PTRS
static

Definition at line 84 of file flexcan_driver.c.

const IRQn_Type g_flexcanBusOffIrqId[] = CAN_Bus_Off_IRQS
static

Definition at line 91 of file flexcan_driver.c.

const IRQn_Type g_flexcanErrorIrqId[] = CAN_Error_IRQS
static

Definition at line 90 of file flexcan_driver.c.

const IRQn_Type g_flexcanOredMessageBufferIrqId[FEATURE_CAN_MB_IRQS_MAX_COUNT][CAN_INSTANCE_COUNT] = FEATURE_CAN_MB_IRQS
static

Definition at line 93 of file flexcan_driver.c.

flexcan_state_t* g_flexcanStatePtr[CAN_INSTANCE_COUNT] = { NULL }
static

Definition at line 96 of file flexcan_driver.c.