74 #define FLEXCAN_MB_HANDLE_RXFIFO 0U
91 const uint8_t *mb_data,
107 #if FEATURE_CAN_HAS_DMA_ENABLE
108 static void FLEXCAN_DRV_CompleteRxFifoDataDMA(
void *parameter,
edma_chn_status_t status);
311 #if FEATURE_CAN_HAS_PE_CLKSRC_SELECT
351 #if FEATURE_CAN_HAS_DMA_ENABLE
404 for (j = 0; j < i; j++)
417 #if FEATURE_CAN_HAS_DMA_ENABLE
422 g_flexcanStatePtr[instance] = state;
479 const uint8_t *mb_data,
532 const uint8_t *mb_data)
817 while ((flag_reg & 1U) == 0U)
912 #if FEATURE_CAN_HAS_PRETENDED_NETWORKING
923 void FLEXCAN_DRV_WakeUpHandler(uint8_t instance)
930 uint32_t flag = base->
WU_MTC;
938 state->
callback(instance, FLEXCAN_EVENT_WAKEUP_TIMEOUT, state);
943 state->
callback(instance, FLEXCAN_EVENT_WAKEUP_MATCH, state);
1021 const uint8_t *mb_data,
1127 #if FEATURE_CAN_HAS_DMA_ENABLE
1149 #if FEATURE_CAN_HAS_DMA_ENABLE
1155 FLEXCAN_DRV_CompleteRxFifoDataDMA,
1156 (
void *)((uint32_t)instance));
1166 (uint32_t)(base->
RAMn),
1227 #if FEATURE_CAN_HAS_DMA_ENABLE
1236 static void FLEXCAN_DRV_CompleteRxFifoDataDMA(
void *parameter,
edma_chn_status_t status)
1238 uint32_t instance = (uint32_t)parameter;
1270 #if FEATURE_CAN_HAS_DMA_ENABLE
1274 uint32_t *msgData_32 = (uint32_t *)fifo_message->
data;
1317 #if FEATURE_CAN_HAS_PRETENDED_NETWORKING
1326 void FLEXCAN_DRV_ConfigPN(uint8_t instance,
bool enable,
const flexcan_pn_config_t *pnConfig)
const IRQn_Type g_flexcanOredMessageBufferIrqId[CAN_INSTANCE_COUNT][FEATURE_CAN_MB_IRQS_MAX_COUNT]
Table to save message buffer IRQ numbers for FlexCAN instances.
const IRQn_Type g_flexcanBusOffIrqId[CAN_INSTANCE_COUNT]
Table to save Bus off IRQ numbers for FlexCAN instances.
#define FEATURE_CAN_RXFIFO_FRAME_AVAILABLE
status_t FLEXCAN_HAL_SetRxFifoDMA(CAN_Type *base, bool enable)
Enables/Disables the DMA support for RxFIFO.
void FLEXCAN_HAL_SetRxMsgBuffGlobalExtMask(CAN_Type *base, uint32_t extMask)
Sets the FlexCAN RX Message Buffer global extended mask.
void FLEXCAN_HAL_SetTimeSegmentsCbt(CAN_Type *base, const flexcan_time_segment_t *timeSeg)
Sets the FlexCAN time segments for setting up bit rate for FD BRS.
void FLEXCAN_HAL_ClearErrIntStatusFlag(CAN_Type *base)
Clears all other interrupts in ERRSTAT register (Error, Busoff, Wakeup).
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.
status_t FLEXCAN_DRV_Deinit(uint8_t instance)
Shuts down a FlexCAN instance.
Internal driver state information.
void FLEXCAN_HAL_ConfigPN(CAN_Type *base, const flexcan_pn_config_t *pnConfig)
Configures the Pretended Networking mode.
void FLEXCAN_HAL_SetTimeSegments(CAN_Type *base, const flexcan_time_segment_t *timeSeg)
Sets the FlexCAN time segments for setting up bit rate.
void FLEXCAN_HAL_GetTimeSegments(const CAN_Type *base, flexcan_time_segment_t *timeSeg)
Gets the FlexCAN time segments to calculate the bit rate.
void FLEXCAN_HAL_ExitFreezeMode(CAN_Type *base)
Un freezes the FlexCAN module.
flexcan_operation_modes_t flexcanMode
void FLEXCAN_HAL_Enable(CAN_Type *base)
Enables FlexCAN controller.
flexcan_fd_payload_size_t payload
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.
status_t OSIF_SemaDestroy(const semaphore_t *const pSem)
Destroys a previously created semaphore.
flexcan_time_segment_t bitrate
status_t FLEXCAN_HAL_EnableRxFifo(CAN_Type *base, uint32_t numOfFilters)
Enables the Rx FIFO.
__IO uint32_t RAMn[CAN_RAMn_COUNT]
bool FLEXCAN_HAL_IsFDEnabled(const CAN_Type *base)
Checks if the Flexible Data rate feature is enabled.
flexcan_rx_fifo_id_filter_num_t num_id_filters
static uint32_t FLEXCAN_HAL_GetAllMsgBuffIntStatusFlag(const CAN_Type *base)
Gets all FlexCAN Message Buffer interrupt flags.
status_t FLEXCAN_DRV_RxFifo(uint8_t instance, flexcan_msgbuff_t *data)
Receives a CAN frame using the message FIFO.
status_t FLEXCAN_HAL_GetMsgBuff(CAN_Type *base, uint32_t msgBuffIdx, flexcan_msgbuff_t *msgBuff)
Gets the FlexCAN message buffer fields.
status_t FLEXCAN_HAL_SetMsgBuffIntCmd(CAN_Type *base, uint32_t msgBuffIdx, bool enable)
Enables/Disables the FlexCAN Message Buffer interrupt.
static status_t FLEXCAN_DRV_StartRxMessageFifoData(uint8_t instance, flexcan_msgbuff_t *data, bool isBlocking)
void FLEXCAN_HAL_Disable(CAN_Type *base)
Disables FlexCAN controller.
status_t EDMA_DRV_StopChannel(uint8_t channel)
Stops the eDMA channel.
#define FEATURE_CAN_MAX_MB_NUM
status_t FLEXCAN_HAL_LockRxMsgBuff(CAN_Type *base, uint32_t msgBuffIdx)
Locks the FlexCAN Rx message buffer.
void FLEXCAN_HAL_SetRxFifoGlobalStdMask(CAN_Type *base, uint32_t stdMask)
Sets the FlexCAN RX FIFO global standard mask.
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.
void FLEXCAN_HAL_EnterFreezeMode(CAN_Type *base)
Freezes the FlexCAN module.
status_t OSIF_SemaCreate(semaphore_t *const pSem, const uint8_t initValue)
Creates a semaphore with a given value.
flexcan_msgbuff_id_type_t msg_id_type
void FLEXCAN_HAL_SetSelfReception(CAN_Type *base, bool enable)
Enables/Disables the Self Reception feature.
void FLEXCAN_DRV_InstallEventCallback(uint8_t instance, flexcan_callback_t callback, void *callbackParam)
Installs a callback function for the IRQ handler.
#define CAN_WU_MTC_WTOF_MASK
static flexcan_state_t * g_flexcanStatePtr[CAN_INSTANCE_COUNT]
#define REV_BYTES_32(a, b)
Reverse byte order in a word.
void INT_SYS_DisableIRQ(IRQn_Type irqNumber)
Disables an interrupt for a given IRQ number.
#define FLEXCAN_MB_HANDLE_RXFIFO
void FLEXCAN_HAL_SetErrIntCmd(CAN_Type *base, flexcan_int_type_t errType, bool enable)
Enables error interrupt of the FlexCAN module.
#define CAN_INSTANCE_COUNT
static void FLEXCAN_DRV_CompleteRxMessageFifoData(uint32_t instance)
edma_chn_status_t
Channel status for eDMA channel.
flexcan_rxfifo_transfer_type_t transferType
const IRQn_Type g_flexcanWakeUpIrqId[CAN_INSTANCE_COUNT]
Table to save wakeup IRQ numbers for FlexCAN instances.
#define CAN_WU_MTC_WUMF_MASK
void FLEXCAN_DRV_SetRxMaskType(uint8_t instance, flexcan_rx_mask_type_t type)
Sets the RX masking type.
void FLEXCAN_HAL_SetOperationMode(CAN_Type *base, flexcan_operation_modes_t mode)
Set operation mode.
void FLEXCAN_HAL_SetRxMsgBuffGlobalStdMask(CAN_Type *base, uint32_t stdMask)
Sets the FlexCAN Rx Message Buffer global standard mask.
FlexCAN timing related structures Implements : flexcan_time_segment_t_Class.
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.
void FLEXCAN_HAL_SetRxMaskType(CAN_Type *base, flexcan_rx_mask_type_t type)
Sets the Rx masking type.
status_t FLEXCAN_DRV_GetTransferStatus(uint32_t instance, uint8_t mb_idx)
Returns whether the previous FLEXCAN transfer has finished.
#define FEATURE_CAN_MB_IRQS_MAX_COUNT
status_t
Status return codes. Common error codes will be a unified enumeration (C enum) that will contain all ...
#define FEATURE_CAN_RXFIFO_WARNING
status_t FLEXCAN_DRV_Init(uint32_t instance, flexcan_state_t *state, const flexcan_user_config_t *data)
Initializes the FlexCAN peripheral.
static void FLEXCAN_HAL_UnlockRxMsgBuff(const CAN_Type *base)
Unlocks the FlexCAN Rx message buffer.
static void FLEXCAN_DRV_CompleteTransfer(uint32_t instance, uint8_t mb_idx)
void FLEXCAN_HAL_SetRxFifoFilter(CAN_Type *base, flexcan_rx_fifo_id_element_format_t idFormat, const flexcan_id_table_t *idFilterTable)
Sets the FlexCAN Rx FIFO fields.
void(* flexcan_callback_t)(uint8_t instance, flexcan_event_type_t eventType, flexcan_state_t *flexcanState)
FlexCAN Driver callback function type Implements : flexcan_callback_t_Class.
static bool FLEXCAN_HAL_IsRxFifoEnabled(const CAN_Type *base)
Checks if Rx FIFO is enabled.
status_t FLEXCAN_DRV_AbortTransfer(uint32_t instance, uint8_t mb_idx)
Ends a non-blocking FlexCAN transfer early.
flexcan_rx_fifo_id_element_format_t
ID formats for RxFIFO Implements : flexcan_rx_fifo_id_element_format_t_Class.
void FLEXCAN_HAL_ReadRxFifo(const CAN_Type *base, flexcan_msgbuff_t *rxFifo)
Gets the FlexCAN Rx FIFO data.
status_t FLEXCAN_HAL_SetRxMsgBuff(CAN_Type *base, uint32_t msgBuffIdx, const flexcan_msgbuff_code_status_t *cs, uint32_t msgId)
Sets the FlexCAN message buffer fields for receiving.
FlexCAN message buffer structure Implements : flexcan_msgbuff_t_Class.
flexcan_msgbuff_id_type_t msgIdType
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.
static status_t FLEXCAN_DRV_StartRxMessageBufferData(uint8_t instance, uint8_t mb_idx, flexcan_msgbuff_t *data, bool isBlocking)
FlexCAN RX FIFO ID filter table structure Implements : flexcan_id_table_t_Class.
CAN_Type *const g_flexcanBase[CAN_INSTANCE_COUNT]
Table of base addresses for FlexCAN instances.
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.
static void FLEXCAN_HAL_SetPN(CAN_Type *base, bool enable)
Enables/Disables the Pretended Networking mode.
void(* callback)(uint8_t instance, flexcan_event_type_t eventType, struct FlexCANState *state)
flexcan_time_segment_t bitrate_cbt
flexcan_rxfifo_transfer_type_t transfer_type
status_t FLEXCAN_HAL_SetRxIndividualStdMask(CAN_Type *base, uint32_t msgBuffIdx, uint32_t stdMask)
Sets the FlexCAN Rx individual standard mask for ID filtering in the Rx MBs and the Rx FIFO...
Pretended Networking configuration structure Implements : flexcan_pn_config_t_Class.
status_t OSIF_SemaWait(semaphore_t *const pSem, const uint32_t timeout)
Decrement a semaphore with timeout.
status_t EDMA_DRV_StartChannel(uint8_t channel)
Starts an eDMA channel.
const IRQn_Type g_flexcanErrorIrqId[CAN_INSTANCE_COUNT]
Table to save error IRQ numbers for FlexCAN instances.
void FLEXCAN_HAL_Init(CAN_Type *base)
Initializes the FlexCAN controller.
status_t FLEXCAN_HAL_SetTxMsgBuff(CAN_Type *base, uint32_t msgBuffIdx, const flexcan_msgbuff_code_status_t *cs, uint32_t msgId, const uint8_t *msgData)
Sets the FlexCAN message buffer fields for transmitting.
void FLEXCAN_DRV_SetRxFifoGlobalMask(uint8_t instance, flexcan_msgbuff_id_type_t id_type, uint32_t mask)
Sets the FlexCAN RX FIFO global standard or extended mask.
status_t FLEXCAN_HAL_SetMaxMsgBuffNum(CAN_Type *base, uint32_t maxMsgBuffNum)
Sets the maximum number of Message Buffers.
status_t OSIF_SemaPost(semaphore_t *const pSem)
Increment a semaphore.
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.
void FLEXCAN_DRV_SetBitrateCbt(uint8_t instance, const flexcan_time_segment_t *bitrate)
Sets the FlexCAN bit rate for FD BRS.
void FLEXCAN_HAL_SelectClock(CAN_Type *base, flexcan_clk_source_t clk)
Selects the clock source for FlexCAN.
flexcan_msgbuff_id_type_t
FlexCAN Message Buffer ID type Implements : flexcan_msgbuff_id_type_t_Class.
void INT_SYS_EnableIRQ(IRQn_Type irqNumber)
Enables an interrupt for a given IRQ number.
static status_t FLEXCAN_DRV_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)
#define CAN_CS_CODE_SHIFT
flexcan_msgbuff_t * mb_message
void FLEXCAN_HAL_SetPayloadSize(CAN_Type *base, flexcan_fd_payload_size_t payloadSize)
Sets the payload size of the MBs.
static void FLEXCAN_HAL_ClearMsgBuffIntStatusFlag(CAN_Type *base, uint32_t flag)
Clears the interrupt flag of the message buffers.
void FLEXCAN_HAL_SetStuffBitCount(CAN_Type *base, bool enable)
Enables/Disables the Stuff Bit Count for CAN FD frames.
void FLEXCAN_DRV_SetRxMbGlobalMask(uint8_t instance, flexcan_msgbuff_id_type_t id_type, uint32_t mask)
Sets the FlexCAN RX MB global standard or extended mask.
void FLEXCAN_DRV_IRQHandler(uint8_t instance)
Interrupt handler for a FlexCAN instance.
FlexCAN data info from user Implements : flexcan_data_info_t_Class.
flexcan_rx_mask_type_t
FlexCAN RX mask type. Implements : flexcan_rx_mask_type_t_Class.
status_t EDMA_DRV_ConfigSingleBlockTransfer(uint8_t channel, edma_transfer_type_t type, uint32_t srcAddr, uint32_t destAddr, edma_transfer_size_t transferSize, uint32_t dataBufferSize)
Configures a simple single block data transfer with DMA.
void FLEXCAN_HAL_SetRxFifoGlobalExtMask(CAN_Type *base, uint32_t extMask)
Sets the FlexCAN Rx FIFO global extended mask.
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.
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 standard or extended mask.
volatile flexcan_mb_handle_t mbs[FEATURE_CAN_MAX_MB_NUM]
FlexCAN Message Buffer code and status for transmit and receive Implements : flexcan_msgbuff_code_sta...
status_t EDMA_DRV_InstallCallback(uint8_t channel, edma_callback_t callback, void *parameter)
Registers the callback function and the parameter for eDMA channel.
void FLEXCAN_DRV_SetBitrate(uint8_t instance, const flexcan_time_segment_t *bitrate)
Sets the FlexCAN bit rate.
#define FEATURE_CAN_RXFIFO_OVERFLOW
status_t FLEXCAN_HAL_SetRxIndividualExtMask(CAN_Type *base, uint32_t msgBuffIdx, uint32_t extMask)
Sets the FlexCAN Rx individual extended mask for ID filtering in the Rx Message Buffers and the Rx FI...
void FLEXCAN_DRV_GetBitrate(uint8_t instance, flexcan_time_segment_t *bitrate)
Gets the FlexCAN bit rate.
void FLEXCAN_HAL_SetFDEnabled(CAN_Type *base, bool enable)
Enables/Disables Flexible Data rate (if supported).