HAL FDCAN Functions

Initialization and de-initialization functions

group FDCAN_Exported_Functions_Group1

A set of functions allowing to initialize and deinitialize the FDCAN peripheral:

Functions

hal_status_t HAL_FDCAN_Init ( hal_fdcan_handle_t * hfdcan , hal_fdcan_t instance )

Initializes the FDCAN peripheral according to the associated handle.

Parameters :
Return values :
  • HAL_OK – Operation completed successfully.

  • HAL_INVALID_PARAM – hfdcan is NULL.

  • HAL_ERROR – HAL FDCAN semaphore creation has failed (USE_HAL_MUTEX is set to 1).

void HAL_FDCAN_DeInit ( hal_fdcan_handle_t * hfdcan )

Deinitialize the FDCAN driver for the given handle and disable the peripheral.

Parameters :

hfdcan – Pointer to a hal_fdcan_handle_t handle.

Enter and Exit Power Down mode

group FDCAN_Exported_Functions_Group2

A set of functions allowing to enter and exit sleep mode for the FDCAN peripheral:

Functions

hal_status_t HAL_FDCAN_EnterPowerDownMode ( hal_fdcan_handle_t * hfdcan )

Set the FDCAN peripheral in power down mode (sleep mode).

Note

Called from HAL_FDCAN_STATE_ACTIVE state and sets the fdcan in HAL_FDCAN_STATE_POWER_DOWN state.

Parameters :

hfdcan – Pointer to a hal_fdcan_handle_t handle.

Return values :
  • HAL_OK – Operation completed successfully.

  • HAL_ERROR – FDCAN cannot be set in power down mode.

hal_status_t HAL_FDCAN_ExitPowerDownMode ( hal_fdcan_handle_t * hfdcan )

Exit the FDCAN peripheral power down mode (sleep mode).

Note

Called from HAL_FDCAN_STATE_POWER_DOWN state and sets the fdcan in HAL_FDCAN_STATE_ACTIVE state.

Parameters :

hfdcan – Pointer to a hal_fdcan_handle_t handle.

Return values :
  • HAL_OK – Operation completed successfully.

  • HAL_ERROR – FDCAN cannot leave the power down mode.

Configuration functions

group FDCAN_Exported_Functions_Group3

There are two categories of HAL configuration set of functions for the peripheral configuration:

  • Global configuration set of functions:

  • Unitary configuration set of functions

    • Apply/Get one single configuration item

These sets of functions are intended to dynamically modify/retrieve a unitary item meaning that a global configuration has been already applied. Unitary configuration set of functions must check first if the FDCAN module is in IDLE state (meaning a global configuration was applied) in order to modify or retrieve a single item. Integrity check must be ensured when setting an item.

Items that can alter other config parameters must not be handled within unitary set of functions.

Functions

hal_status_t HAL_FDCAN_SetConfig ( hal_fdcan_handle_t * hfdcan , const hal_fdcan_config_t * p_config )

Configures the FDCAN according to the user parameters.

Parameters :
  • hfdcan – Pointer to a hal_fdcan_handle_t handle.

  • p_config – Pointer to the configuration structure.

Return values :
  • HAL_OK – Operation completed successfully.

  • HAL_INVALID_PARAM – p_config is NULL.

  • HAL_ERROR – FDCAN cannot leave the power down mode..

void HAL_FDCAN_GetConfig ( const hal_fdcan_handle_t * hfdcan , hal_fdcan_config_t * p_config )

Get the FDCAN global configuration.

Parameters :
hal_status_t HAL_FDCAN_SetTxMode ( const hal_fdcan_handle_t * hfdcan , hal_fdcan_tx_mode_t tx_mode )

Set the transmission FIFO/Queue mode.

Parameters :
Return values :

HAL_OK – Operation completed successfully.

hal_fdcan_tx_mode_t HAL_FDCAN_GetTxMode ( const hal_fdcan_handle_t * hfdcan )

Get the transmission FIFO/Queue mode configuration.

Parameters :

hfdcan – Pointer to a hal_fdcan_handle_t handle.

Returns :

hal_fdcan_tx_mode_t Current transmission mode.

hal_status_t HAL_FDCAN_SetNominalBitTiming ( const hal_fdcan_handle_t * hfdcan , const hal_fdcan_nominal_bit_timing_t * p_nominal_bit_timing )

Set the FDCAN nominal bit timing configuration.

Parameters :
Return values :
  • HAL_OK – Operation completed successfully.

  • HAL_INVALID_PARAM – p_nominal_bit_timing is NULL.

void HAL_FDCAN_GetNominalBitTiming ( const hal_fdcan_handle_t * hfdcan , hal_fdcan_nominal_bit_timing_t * nominal_bit_timing )

Get the FDCAN nominal bit timing configuration.

Parameters :
hal_status_t HAL_FDCAN_SetDataBitTiming ( const hal_fdcan_handle_t * hfdcan , const hal_fdcan_data_bit_timing_t * p_data_bit_timing )

Set the FDCAN data bit timing configuration.

Parameters :
Return values :
  • HAL_OK – Operation completed successfully.

  • HAL_INVALID_PARAM – p_data_bit_timing is NULL.

void HAL_FDCAN_GetDataBitTiming ( const hal_fdcan_handle_t * hfdcan , hal_fdcan_data_bit_timing_t * data_bit_timing )

Get the FDCAN data bit timing configuration.

Parameters :
hal_status_t HAL_FDCAN_SetFilter ( const hal_fdcan_handle_t * hfdcan , const hal_fdcan_filter_t * p_filter_config )

Configure the FDCAN reception filter according to the user parameters.

Parameters :
Return values :
  • HAL_OK – Operation completed successfully.

  • HAL_INVALID_PARAM – p_filter_config is NULL.

void HAL_FDCAN_GetFilter ( const hal_fdcan_handle_t * hfdcan , hal_fdcan_filter_t * p_filter_config , uint32_t filter_index , uint32_t id_type )

Configure the FDCAN reception filter according to the specified parameters in the hal_fdcan_filter_t structure.

Parameters :
  • hfdcan – Pointer to a hal_fdcan_handle_t handle.

  • p_filter_config – Pointer to a structure based on hal_fdcan_filter_t to be filled with current configuration.

  • filter_index – Index of the filter to be set.

  • id_type – Specifies the type of filter based on FDCAN ID type .

hal_status_t HAL_FDCAN_SetGlobalFilter ( const hal_fdcan_handle_t * hfdcan , const hal_fdcan_global_filter_config_t * p_global_filter_config )

Configure the FDCAN global filter.

Parameters :
Return values :
  • HAL_OK – Operation completed successfully.

  • HAL_INVALID_PARAM – p_global_filter_config is NULL.

void HAL_FDCAN_GetGlobalFilter ( const hal_fdcan_handle_t * hfdcan , hal_fdcan_global_filter_config_t * p_global_filter_config )

Get the FDCAN global filter.

Parameters :
hal_status_t HAL_FDCAN_SetExtendedIdMask ( const hal_fdcan_handle_t * hfdcan , uint32_t mask )

Set the extended ID mask value.

Parameters :
  • hfdcan – Pointer to a hal_fdcan_handle_t handle.

  • mask – Value of the Extended ID Mask, this parameter must be a number between 0 and 0x1FFFFFFF.

Return values :

HAL_OK – Operation completed successfully.

uint32_t HAL_FDCAN_GetExtendedIdMask ( const hal_fdcan_handle_t * hfdcan )

Get the extended ID mask value.

Parameters :

hfdcan – Pointer to a hal_fdcan_handle_t handle.

Returns :

Current extended ID mask.

hal_status_t HAL_FDCAN_SetClockDivider ( const hal_fdcan_handle_t * hfdcan , hal_fdcan_clock_divider_t clock_divider )

Set the FDCAN clock divider value.

Parameters :
Return values :

HAL_OK – Operation completed successfully.

hal_fdcan_clock_divider_t HAL_FDCAN_GetClockDivider ( const hal_fdcan_handle_t * hfdcan )

Get the clock divider for FDCAN.

Parameters :

hfdcan – Pointer to a hal_fdcan_handle_t handle.

Returns :

hal_fdcan_clock_divider_t Current clock divider.

hal_status_t HAL_FDCAN_SetRxFifoOverwrite ( const hal_fdcan_handle_t * hfdcan , hal_fdcan_rx_location_t rx_fifo_idx , hal_fdcan_rx_fifo_operative_mode_t operation_mode )

Configure the Rx FIFO operation mode.

Parameters :
Return values :

HAL_OK – Operation completed successfully.

void HAL_FDCAN_GetRxFifoOverwrite ( const hal_fdcan_handle_t * hfdcan , hal_fdcan_rx_location_t rx_fifo_sel , hal_fdcan_rx_fifo_operative_mode_t * p_rx_operation )

Get the Rx FIFO operation mode.

Parameters :
hal_status_t HAL_FDCAN_SetRamWatchdog ( const hal_fdcan_handle_t * hfdcan , uint32_t counter_start_value )

Configure the RAM watchdog.

Warning

With the reset value of 0x00 the counter is disabled.

Parameters :
  • hfdcan – Pointer to a hal_fdcan_handle_t handle.

  • counter_start_value – Start value of the message RAM watchdog counter, this parameter must be a number between 0x00 and 0xFF.

Return values :

HAL_OK – Operation completed successfully.

uint32_t HAL_FDCAN_GetRamWatchdog ( const hal_fdcan_handle_t * hfdcan )

Get the current RAM watchdog counter - not the configured value.

Parameters :

hfdcan – Pointer to a hal_fdcan_handle_t handle.

Returns :

Current message RAM watchdog counter value.

hal_status_t HAL_FDCAN_SetConfigTimestampCounter ( const hal_fdcan_handle_t * hfdcan , const hal_fdcan_timestamp_config_t * p_timestamp_config )

Configure the timestamp counter.

Parameters :
Return values :
  • HAL_OK – Operation completed successfully.

  • HAL_INVALID_PARAM – p_timestamp_config is NULL.

void HAL_FDCAN_GetConfigTimestampCounter ( const hal_fdcan_handle_t * hfdcan , hal_fdcan_timestamp_config_t * p_timestamp_config )

Get the timestamp counter configuration.

Parameters :
uint16_t HAL_FDCAN_GetTimestampCounter ( const hal_fdcan_handle_t * hfdcan )

Get the timestamp counter value.

Parameters :

hfdcan – Pointer to a hal_fdcan_handle_t handle.

Returns :

Current timestamp counter value.

hal_status_t HAL_FDCAN_ResetTimestampCounter ( const hal_fdcan_handle_t * hfdcan )

Reset the timestamp counter to zero.

Parameters :

hfdcan – Pointer to a hal_fdcan_handle_t handle.

Return values :
  • HAL_OK – Operation completed successfully.

  • HAL_ERROR – Timestamp counter source is not internal.

hal_status_t HAL_FDCAN_SetConfigTimeoutCounter ( const hal_fdcan_handle_t * hfdcan , const hal_fdcan_timeout_config_t * p_timeout_param )

Configure the timeout counter.

Parameters :
Return values :
  • HAL_OK – Operation completed successfully.

  • HAL_INVALID_PARAM – p_timeout_param is NULL.

void HAL_FDCAN_GetConfigTimeoutCounter ( const hal_fdcan_handle_t * hfdcan , hal_fdcan_timeout_config_t * p_timeout_param )

Get the timeout counter configuration.

Parameters :
uint32_t HAL_FDCAN_GetTimeoutCounter ( const hal_fdcan_handle_t * hfdcan )

Get the timeout counter value.

Parameters :

hfdcan – Pointer to a hal_fdcan_handle_t handle.

Returns :

Current timeout counter value.

hal_status_t HAL_FDCAN_EnableTimeoutCounter ( const hal_fdcan_handle_t * hfdcan )

Enable the timeout counter.

Parameters :

hfdcan – Pointer to a hal_fdcan_handle_t handle.

Return values :

HAL_OK – Operation completed successfully.

hal_status_t HAL_FDCAN_DisableTimeoutCounter ( const hal_fdcan_handle_t * hfdcan )

Disable the timeout counter.

Parameters :

hfdcan – Pointer to a hal_fdcan_handle_t handle.

Return values :

HAL_OK – Operation completed successfully.

hal_fdcan_timeout_counter_status_t HAL_FDCAN_IsEnabledTimeoutCounter ( const hal_fdcan_handle_t * hfdcan )

Check timeout Counter status.

Parameters :

hfdcan – Pointer to a hal_fdcan_handle_t handle.

Returns :

hal_fdcan_timeout_counter_status_t Current timeout counter status.

hal_status_t HAL_FDCAN_ResetTimeoutCounter ( const hal_fdcan_handle_t * hfdcan )

Reset the timeout counter to its start value.

Parameters :

hfdcan – Pointer to a hal_fdcan_handle_t handle.

Return values :
  • HAL_OK – Operation completed successfully.

  • HAL_ERROR – Timeout counter source is not continuous.

hal_status_t HAL_FDCAN_SetConfigTxDelayCompensation ( const hal_fdcan_handle_t * hfdcan , const hal_fdcan_tx_delay_compensation_config_t * p_tx_delay_param )

Configure the transmitter delay compensation.

Parameters :
Return values :
  • HAL_OK – Operation completed successfully.

  • HAL_INVALID_PARAM – p_tx_delay_param is NULL.

void HAL_FDCAN_GetConfigTxDelayCompensation ( const hal_fdcan_handle_t * hfdcan , hal_fdcan_tx_delay_compensation_config_t * p_tx_delay_param )

Get the transmitter delay compensation offset.

Parameters :
hal_status_t HAL_FDCAN_EnableTxDelayCompensation ( const hal_fdcan_handle_t * hfdcan )

Enable the transmitter delay compensation.

Parameters :

hfdcan – Pointer to a hal_fdcan_handle_t handle.

Return values :

HAL_OK – Operation completed successfully.

hal_status_t HAL_FDCAN_DisableTxDelayCompensation ( const hal_fdcan_handle_t * hfdcan )

Disable the transmitter delay compensation.

Parameters :

hfdcan – Pointer to a hal_fdcan_handle_t handle.

Return values :

HAL_OK – Operation completed successfully.

hal_fdcan_transmitter_delay_comp_status_t HAL_FDCAN_IsEnabledTxDelayCompensation ( const hal_fdcan_handle_t * hfdcan )

Check Transmitter Delay Compensation status.

Parameters :

hfdcan – Pointer to a hal_fdcan_handle_t handle.

Returns :

hal_fdcan_transmitter_delay_comp_status_t Current transmitter delay compensation status.

hal_status_t HAL_FDCAN_EnableISOMode ( const hal_fdcan_handle_t * hfdcan )

Enable ISO 11898-1 protocol mode.

Parameters :

hfdcan – Pointer to a hal_fdcan_handle_t handle.

Return values :

HAL_OK – Operation completed successfully.

hal_status_t HAL_FDCAN_DisableISOMode ( const hal_fdcan_handle_t * hfdcan )

Disable ISO 11898-1 protocol mode.

Parameters :

hfdcan – Pointer to a hal_fdcan_handle_t handle.

Return values :

HAL_OK – Operation completed successfully.

hal_fdcan_iso_mode_status_t HAL_FDCAN_IsEnabledISOMode ( const hal_fdcan_handle_t * hfdcan )

Check ISO 11898-1 protocol mode status.

Parameters :

hfdcan – Pointer to a hal_fdcan_handle_t handle.

Returns :

hal_fdcan_iso_mode_status_t Current protocol mode status.

hal_status_t HAL_FDCAN_EnableEdgeFiltering ( const hal_fdcan_handle_t * hfdcan )

Enable edge filtering during bus integration.

Note

Two consecutive dominant tq’s are required to detect an edge for hard synchronization.

Parameters :

hfdcan – Pointer to a hal_fdcan_handle_t handle.

Return values :

HAL_OK – Operation completed successfully.

hal_status_t HAL_FDCAN_DisableEdgeFiltering ( const hal_fdcan_handle_t * hfdcan )

Disable edge filtering during bus integration.

Note

One dominant tq is required to detect an edge for hard synchronization.

Parameters :

hfdcan – Pointer to a hal_fdcan_handle_t handle.

Return values :

HAL_OK – Operation completed successfully.

hal_fdcan_edge_filtering_status_t HAL_FDCAN_IsEnabledEdgeFiltering ( const hal_fdcan_handle_t * hfdcan )

Check edge filtering during bus integration status.

Note

One dominant tq is required to detect an edge for hard synchronization.

Parameters :

hfdcan – Pointer to a hal_fdcan_handle_t handle.

Returns :

hal_fdcan_edge_filtering_status_t Current edge filtering status.

hal_status_t HAL_FDCAN_SetMode ( const hal_fdcan_handle_t * hfdcan , hal_fdcan_mode_t mode )

Set the FDCAN mode.

Warning

This function can only be called from HAL_FDCAN_STATE_IDLE state.

Parameters :
Return values :

HAL_OK – Operation completed successfully.

hal_fdcan_mode_t HAL_FDCAN_GetMode ( const hal_fdcan_handle_t * hfdcan )

Get the FDCAN mode.

Parameters :

hfdcan – Pointer to a hal_fdcan_handle_t handle.

Returns :

hal_fdcan_mode_t Current FDCAN mode configuration.

hal_status_t HAL_FDCAN_SetFrameFormat ( const hal_fdcan_handle_t * hfdcan , hal_fdcan_frame_format_t frame_format )

Set the frame format.

Parameters :
Return values :

HAL_OK – Operation completed successfully.

hal_fdcan_frame_format_t HAL_FDCAN_GetFrameFormat ( const hal_fdcan_handle_t * hfdcan )

Get the frame format.

Parameters :

hfdcan – Pointer to a hal_fdcan_handle_t handle.

Returns :

hal_fdcan_frame_format_t Current FDCAN frame format.

hal_status_t HAL_FDCAN_SetAutoRetransmission ( const hal_fdcan_handle_t * hfdcan , hal_fdcan_auto_retransmission_status_t auto_retransmit )

Set auto retransmission.

Parameters :
  • hfdcan – Pointer to a hal_fdcan_handle_t handle.

  • auto_retransmit – Value to enable or disable the automatic retransmission of messages.

Return values :

HAL_OK – Operation completed successfully.

hal_fdcan_auto_retransmission_status_t HAL_FDCAN_GetAutoRetransmission ( const hal_fdcan_handle_t * hfdcan )

Get auto retransmission status.

Parameters :

hfdcan – Pointer to a hal_fdcan_handle_t handle.

Returns :

hal_fdcan_auto_retransmission_status_t Current auto retransmission status.

hal_status_t HAL_FDCAN_SetTransmitPause ( const hal_fdcan_handle_t * hfdcan , hal_fdcan_transmit_pause_status_t transmit_pause )

Set transmit pause.

Parameters :
  • hfdcan – Pointer to a hal_fdcan_handle_t handle.

  • transmit_pause – Value to enable/disable the FDCAN pauses for two CAN bit times before starting the next transmission.

Return values :

HAL_OK – Operation completed successfully.

hal_fdcan_transmit_pause_status_t HAL_FDCAN_GetTransmitPause ( const hal_fdcan_handle_t * hfdcan )

Get the transmit pause status.

Parameters :

hfdcan – Pointer to a hal_fdcan_handle_t handle.

Returns :

hal_fdcan_transmit_pause_status_t Current transmit pause status.

hal_status_t HAL_FDCAN_SetProtocolException ( const hal_fdcan_handle_t * hfdcan , hal_fdcan_protocol_exception_status_t protocol_exception )

Set protocol exception.

Parameters :
  • hfdcan – Pointer to a hal_fdcan_handle_t handle.

  • protocol_exception – Value to enable or disable the protocol exception.

Return values :

HAL_OK – Operation completed successfully.

hal_fdcan_protocol_exception_status_t HAL_FDCAN_GetProtocolException ( const hal_fdcan_handle_t * hfdcan )

Get the protocol exception status.

Parameters :

hfdcan – Pointer to a hal_fdcan_handle_t handle.

Returns :

hal_fdcan_protocol_exception_status_t Current protocol exception status.

uint32_t HAL_FDCAN_GetClockFreq ( const hal_fdcan_handle_t * hfdcan )

Return the peripheral clock frequency for FDCAN.

Parameters :

hfdcan – Pointer to a hal_fdcan_handle_t handle. structure

Returns :

Current clock frequency(hz) or 0 if FDCAN is not configured or not ready.

hal_status_t HAL_FDCAN_RegisterTxEventFifoCallback ( hal_fdcan_handle_t * hfdcan , hal_fdcan_fifo_cb_t p_callback )

Register Tx event FIFO callback to be used instead of the weak HAL_FDCAN_TxEventFifoCallback() predefined callback.

Parameters :
  • hfdcan – Pointer to a hal_fdcan_handle_t handle.

  • p_callback – Pointer to the Tx Event FIFO Callback function.

Return values :
  • HAL_OK – Operation completed successfully.

  • HAL_INVALID_PARAM – p_callback is NULL.

hal_status_t HAL_FDCAN_RegisterRxFifo0Callback ( hal_fdcan_handle_t * hfdcan , hal_fdcan_fifo_cb_t p_callback )

Register Rx FIFO 0 callback to be used instead of the weak HAL_FDCAN_RxFifo0Callback() predefined callback.

Parameters :
  • hfdcan – Pointer to a hal_fdcan_handle_t handle.

  • p_callback – Pointer to the Rx FIFO 0 Callback function.

Return values :
  • HAL_OK – Operation completed successfully.

  • HAL_INVALID_PARAM – p_callback is NULL.

hal_status_t HAL_FDCAN_RegisterRxFifo1Callback ( hal_fdcan_handle_t * hfdcan , hal_fdcan_fifo_cb_t p_callback )

Register Rx FIFO 1 callback to be used instead of the weak HAL_FDCAN_RxFifo1Callback() predefined callback.

Parameters :
  • hfdcan – Pointer to a hal_fdcan_handle_t handle.

  • p_callback – Pointer to the Rx FIFO 1 Callback function.

Return values :
  • HAL_OK – Operation completed successfully.

  • HAL_INVALID_PARAM – p_callback is NULL.

hal_status_t HAL_FDCAN_RegisterTxBufferCompleteCallback ( hal_fdcan_handle_t * hfdcan , hal_fdcan_tx_buffer_cb_t p_callback )

Register Tx Buffer Complete callback to be used instead of the weak HAL_FDCAN_TxBufferCompleteCallback() predefined callback.

Parameters :
  • hfdcan – Pointer to a hal_fdcan_handle_t handle.

  • p_callback – Pointer to the Tx Buffer Complete Callback function.

Return values :
  • HAL_OK – Operation completed successfully.

  • HAL_INVALID_PARAM – p_callback is NULL.

hal_status_t HAL_FDCAN_RegisterTxBufferAbortCallback ( hal_fdcan_handle_t * hfdcan , hal_fdcan_tx_buffer_cb_t p_callback )

Register Tx buffer abort callback to be used instead of the weak HAL_FDCAN_TxBufferAbortCallback() predefined callback.

Parameters :
  • hfdcan – Pointer to a hal_fdcan_handle_t handle.

  • p_callback – Pointer to the Tx buffer abort callback function.

Return values :
  • HAL_OK – Operation completed successfully.

  • HAL_INVALID_PARAM – p_callback is NULL.

hal_status_t HAL_FDCAN_RegisterHighPriorityMessageCallback ( hal_fdcan_handle_t * hfdcan , hal_fdcan_cb_t p_callback )

Register high priority message callback to be used instead of the weak HAL_FDCAN_HighPriorityMessageCallback() predefined callback.

Parameters :
  • hfdcan – Pointer to a hal_fdcan_handle_t handle.

  • p_callback – Pointer to the high priority message callback function.

Return values :
  • HAL_OK – Operation completed successfully.

  • HAL_INVALID_PARAM – p_callback is NULL.

hal_status_t HAL_FDCAN_RegisterTxFifoEmptyCallback ( hal_fdcan_handle_t * hfdcan , hal_fdcan_cb_t p_callback )

Register Tx FIFO empty callback to be used instead of the weak HAL_FDCAN_TxFifoEmptyCallback() predefined callback.

Parameters :
  • hfdcan – Pointer to a hal_fdcan_handle_t handle.

  • p_callback – Pointer to the Tx FIFO empty callback function.

Return values :
  • HAL_OK – Operation completed successfully.

  • HAL_INVALID_PARAM – p_callback is NULL.

hal_status_t HAL_FDCAN_RegisterTimestampWraparoundCallback ( hal_fdcan_handle_t * hfdcan , hal_fdcan_cb_t p_callback )

Register timestamp wrapAround callback to be used instead of the weak HAL_FDCAN_TimestampWraparoundCallback() predefined callback.

Parameters :
  • hfdcan – Pointer to a hal_fdcan_handle_t handle.

  • p_callback – Pointer to the timestamp wrapAround callback function.

Return values :
  • HAL_OK – Operation completed successfully.

  • HAL_INVALID_PARAM – p_callback is NULL.

hal_status_t HAL_FDCAN_RegisterErrorCallback ( hal_fdcan_handle_t * hfdcan , hal_fdcan_cb_t p_callback )

Register error callback to be used instead of the weak HAL_FDCAN_ErrorCallback() predefined callback.

Parameters :
  • hfdcan – Pointer to a hal_fdcan_handle_t handle.

  • p_callback – Pointer to the FDCAN error callback function.

Return values :
  • HAL_OK – Operation completed successfully.

  • HAL_INVALID_PARAM – p_callback is NULL.

Control Functions

group FDCAN_Exported_Functions_Group4

A set of functions allowing to control the peripheral and initiate an operation on the bus:

Functions

hal_status_t HAL_FDCAN_Start ( hal_fdcan_handle_t * hfdcan )

Start the FDCAN module.

Parameters :

hfdcan – Pointer to a hal_fdcan_handle_t handle.

Return values :
  • HAL_OK – Operation completed successfully.

  • HAL_INVALID_PARAM – hfdcan is NULL.

hal_status_t HAL_FDCAN_Stop ( hal_fdcan_handle_t * hfdcan )

Stop the FDCAN module and enable access to configuration registers.

Parameters :

hfdcan – Pointer to a hal_fdcan_handle_t handle.

Return values :
  • HAL_OK – Operation completed successfully.

  • HAL_ERROR – FDCAN cannot leave the power down mode.

  • HAL_INVALID_PARAM – hfdcan is NULL.

hal_status_t HAL_FDCAN_ReqTransmitMsgFromFIFOQ ( hal_fdcan_handle_t * hfdcan , const hal_fdcan_tx_header_t * p_tx_element_header , const uint8_t * p_tx_data )

Add a message to the Tx FIFO/Queue and activate the corresponding transmission request.

Parameters :
  • hfdcan – Pointer to a hal_fdcan_handle_t handle.

  • p_tx_element_header – Pointer to a structure based on hal_fdcan_tx_header_t containing the header of the element to transmit.

  • p_tx_data – Pointer to a buffer containing the payload of the Tx frame.

Return values :
  • HAL_OK – Operation completed successfully.

  • HAL_INVALID_PARAM – p_tx_element_header or p_tx_data are NULL.

hal_fdcan_fifo_status_t HAL_FDCAN_GetTxFifoStatus ( const hal_fdcan_handle_t * hfdcan )

Get the Tx FIFO status.

Parameters :

hfdcan – Pointer to a hal_fdcan_handle_t handle.

Returns :

hal_fdcan_fifo_status_t Current Tx FIFO status.

uint32_t HAL_FDCAN_GetLatestTxFifoQRequestBuffer ( const hal_fdcan_handle_t * hfdcan )

Get the Tx buffer index of latest Tx FIFO/Queue request.

Parameters :

hfdcan – Pointer to a hal_fdcan_handle_t handle.

Returns :

Current index of last Tx FIFO/Queue request or 0 if no Tx submitted request.

hal_fdcan_tx_fifo_free_level_t HAL_FDCAN_GetTxFifoFreeLevel ( const hal_fdcan_handle_t * hfdcan )

Return the Tx FIFO free level - number of consecutive free Tx FIFO elements starting from Tx FIFO get_index.

Parameters :

hfdcan – Pointer to a hal_fdcan_handle_t handle.

Returns :

hal_fdcan_tx_fifo_free_level_t Current Tx FIFO free level.

hal_status_t HAL_FDCAN_ReqAbortOfTxBuffer ( const hal_fdcan_handle_t * hfdcan , uint32_t buffer_index )

Abort transmission request.

Parameters :
Return values :

HAL_OK – Operation completed successfully.

hal_status_t HAL_FDCAN_GetTxEvent ( const hal_fdcan_handle_t * hfdcan , hal_fdcan_tx_evt_fifo_header_t * p_tx_event )

Get a FDCAN Tx event from the Tx Event FIFO zone into the message RAM.

Parameters :
  • hfdcan – Pointer to a hal_fdcan_handle_t handle.

  • p_tx_event – Pointer to a hal_fdcan_tx_event_fifo_t structure.

Return values :
  • HAL_OK – Operation completed successfully.

  • HAL_INVALID_PARAM – p_tx_event is NULL.

  • HAL_ERROR – FIFO is empty or no RAM was allocated for it.

hal_fdcan_buffer_status_t HAL_FDCAN_GetTxBufferMessageStatus ( const hal_fdcan_handle_t * hfdcan , uint32_t tx_buffer_index )

Check if a transmission request is pending on the selected Tx buffer.

Parameters :
Returns :

hal_fdcan_buffer_status_t Current transmission pending status.

hal_status_t HAL_FDCAN_GetReceivedMessage ( const hal_fdcan_handle_t * hfdcan , hal_fdcan_rx_location_t rx_location , hal_fdcan_rx_header_t * p_rx_header , uint8_t * p_rx_data )

Get a FDCAN frame from the Rx FIFO zone into the message RAM.

Parameters :
  • hfdcan – Pointer to a hal_fdcan_handle_t handle.

  • rx_location – Location of the received message to be read.

  • p_rx_header – Pointer to the Rx header element to fill.

  • p_rx_data – Pointer to a buffer where the payload of the Rx message will be stored.

Return values :
  • HAL_OK – Operation completed successfully.

  • HAL_INVALID_PARAM – p_rx_header or p_rx_data are NULL.

  • HAL_ERROR – Rx FIFO empty.

void HAL_FDCAN_GetRxFifoFillLevel ( const hal_fdcan_handle_t * hfdcan , hal_fdcan_rx_location_t rx_fifo_sel , uint32_t * p_fill_level )

Get the Rx FIFO fill level.

Parameters :
  • hfdcan – Pointer to a hal_fdcan_handle_t handle.

  • rx_fifo_sel – value to select the right available Rx FIFO 0/1.

  • p_fill_level – Pointer to the Rx FIFO fill level.

hal_status_t HAL_FDCAN_GetHighPriorityMessageStatus ( const hal_fdcan_handle_t * hfdcan , hal_fdcan_high_prio_msg_status_t * p_hp_msg_status )

Get the high priority message status.

Parameters :
Return values :
  • HAL_OK – Operation completed successfully.

  • HAL_INVALID_PARAM – p_hp_msg_status is NULL.

hal_status_t HAL_FDCAN_GetProtocolStatus ( const hal_fdcan_handle_t * hfdcan , hal_fdcan_protocol_status_t * p_protocol_status )

Get the protocol status.

Parameters :
Return values :
  • HAL_OK – Operation completed successfully.

  • HAL_INVALID_PARAM – p_protocol_status is NULL.

hal_status_t HAL_FDCAN_GetErrorCounters ( const hal_fdcan_handle_t * hfdcan , hal_fdcan_error_counters_t * p_error_counters )

Get the error counter values.

Parameters :
Return values :
  • HAL_OK – Operation completed successfully.

  • HAL_INVALID_PARAM – p_error_counters is NULL.

hal_status_t HAL_FDCAN_EnableRestrictedOperationMode ( const hal_fdcan_handle_t * hfdcan )

Enable the restricted operation mode.

Parameters :

hfdcan – Pointer to a hal_fdcan_handle_t handle.

Return values :

HAL_OK – Operation completed successfully.

hal_status_t HAL_FDCAN_DisableRestrictedOperationMode ( const hal_fdcan_handle_t * hfdcan )

Disable the restricted operation mode.

Parameters :

hfdcan – Pointer to a hal_fdcan_handle_t handle.

Return values :

HAL_OK – Operation completed successfully.

hal_fdcan_restricted_op_mode_status_t HAL_FDCAN_IsEnabledRestrictedOperationMode ( const hal_fdcan_handle_t * hfdcan )

Check the FDCAN restricted operation mode status.

Parameters :

hfdcan – Pointer to a hal_fdcan_handle_t handle.

Returns :

hal_fdcan_restricted_op_mode_status_t Current restricted operation mode status.

Interrupts Management Functions

group FDCAN_Exported_Functions_Group5

A set of functions allowing to deal with interruptions of the peripheral:

Functions

void HAL_FDCAN_IRQHandler ( hal_fdcan_handle_t * hfdcan )

Processes the FDCAN interrupt requests.

Parameters :

hfdcan – Pointer to a hal_fdcan_handle_t handle.

hal_status_t HAL_FDCAN_SetInterruptGroupsToLine ( const hal_fdcan_handle_t * hfdcan , uint32_t interrupt_groups , uint32_t it_line )

Assign the interrupt group(s) to an interrupt line.

Parameters :
  • hfdcan – Pointer to a hal_fdcan_handle_t handle.

  • interrupt_groups – Interrupt group(s) to connect to the given interrupt line. This parameter can be any combination of FDCAN Interrupt Groups .

  • it_line – Indicates which interrupt line must be assigned to the interrupt groups. This parameter must be one unique item of FDCAN Interrupt Lines .

Return values :

HAL_OK – Operation completed successfully.

uint32_t HAL_FDCAN_GetLineFromInterruptGroup ( const hal_fdcan_handle_t * hfdcan , uint32_t interrupt_group )

Get the interrupt line assigned to an interrupt group - applies to a single interrupt group.

Parameters :
Return values :
  • HAL_FDCAN_IT_LINE_0 – Interrupt group is assigned to line 0.

  • HAL_FDCAN_IT_LINE_1 – Interrupt group is assigned to line 1.

hal_status_t HAL_FDCAN_EnableInterruptLines ( const hal_fdcan_handle_t * hfdcan , uint32_t it_lines )

Enable the interrupt line.

Parameters :
Return values :

HAL_OK – Operation completed successfully.

hal_status_t HAL_FDCAN_DisableInterruptLines ( const hal_fdcan_handle_t * hfdcan , uint32_t it_lines )

Disable the interrupt lines.

Parameters :
Return values :

HAL_OK – Operation completed successfully.

hal_fdcan_it_lines_status_t HAL_FDCAN_IsEnabledInterruptLine ( const hal_fdcan_handle_t * hfdcan , uint32_t it_line )

Check the interrupt line status.

Parameters :
Returns :

hal_fdcan_it_lines_status_t Current interrupt line status.

hal_status_t HAL_FDCAN_EnableInterrupts ( const hal_fdcan_handle_t * hfdcan , uint32_t interrupts )

Enable the interrupts.

Parameters :
Return values :

HAL_OK – Operation completed successfully.

hal_status_t HAL_FDCAN_DisableInterrupts ( const hal_fdcan_handle_t * hfdcan , uint32_t interrupts )

Disable the interrupts.

Parameters :
  • hfdcan – Pointer to a hal_fdcan_handle_t handle.

  • interrupts – Interrupt signal(s) to disable - Can be OR-ed with other interrupt signals. This parameter can be any combination of

    • FDCAN_Interrupt_Sources.

Return values :

HAL_OK – Operation completed successfully.

hal_fdcan_it_status_t HAL_FDCAN_IsEnabledInterrupt ( const hal_fdcan_handle_t * hfdcan , uint32_t interrupt )

Check the interrupt status. Apply to one single interrupt signal.

Parameters :
  • hfdcan – Pointer to a hal_fdcan_handle_t handle.

  • interrupt – Interrupt signal to check. Only one single interrupt signal can be checked at a time. This parameter must be one unique sample of

    • FDCAN_Interrupt_Sources.

Returns :

hal_fdcan_it_status_t Current interrupt status.

hal_status_t HAL_FDCAN_EnableTxBufferCompleteInterrupts ( const hal_fdcan_handle_t * hfdcan , uint32_t buffer_idx )

Enable the transmission buffer complete interrupt.

Parameters :
Return values :

HAL_OK – Operation completed successfully.

hal_status_t HAL_FDCAN_DisableTxBufferCompleteInterrupts ( const hal_fdcan_handle_t * hfdcan , uint32_t buffer_idx )

Disable the transmission buffer complete interrupt.

Parameters :
Return values :

HAL_OK – Operation completed successfully.

hal_fdcan_it_txbuffer_complete_status_t HAL_FDCAN_IsEnabledTxBufferCompleteInterrupt ( const hal_fdcan_handle_t * hfdcan , uint32_t buffer_idx )

Check the status of the buffer connected to transmission complete interrupt.

Parameters :
Returns :

hal_fdcan_it_txbuffer_complete_status_t Current Tx complete interrupt buffer status.

hal_status_t HAL_FDCAN_EnableTxBufferCancellationInterrupts ( const hal_fdcan_handle_t * hfdcan , uint32_t buffer_idx )

Enable the transmission cancellation finished interrupt.

Parameters :
Return values :

HAL_OK – Operation completed successfully.

hal_status_t HAL_FDCAN_DisableTxBufferCancellationInterrupts ( const hal_fdcan_handle_t * hfdcan , uint32_t buffer_idx )

Disable the transmission cancellation finished interrupt.

Parameters :
Return values :

HAL_OK – Operation completed successfully.

hal_fdcan_it_txbuffer_abort_status_t HAL_FDCAN_IsEnabledTxBufferCancellationInterrupt ( const hal_fdcan_handle_t * hfdcan , uint32_t buffer_idx )

Check the status of the buffer connected to transmission cancellation finished interrupt.

Parameters :
Returns :

hal_fdcan_it_txbuffer_abort_status_t Current Tx cancellation finished interrupt buffer status.

uint32_t HAL_FDCAN_GetFlag ( const hal_fdcan_handle_t * hfdcan , uint32_t flag )

Check whether the specified FDCAN flag is set or not.

Parameters :
  • hfdcan – Pointer to a hal_fdcan_handle_t .

  • flag – FDCAN flag. This parameter can be one of

    • FDCAN_Interrupt_Sources

Return values :

uint32_t – FlagStatus

Weak Callback Functions

group FDCAN_Exported_Functions_Group6

A set of Weak functions if USE_HAL_FDCAN_REGISTER_CALLBACKS is set to 0 (or custom Callbacks functions if USE_HAL_FDCAN_REGISTER_CALLBACKS is set to 1) which are used to asynchronously informed the application in non-blocking modes:

Functions

void HAL_FDCAN_TxEventFifoCallback ( hal_fdcan_handle_t * hfdcan , uint32_t tx_event_fifo_interrupts )

Tx event callback.

Warning

This weak function must not be modified. When the callback is needed, it must be implemented in the user file.

Parameters :
  • hfdcan – Pointer to a hal_fdcan_handle_t handle.

  • tx_event_fifo_interrupts – Indicates which Tx event FIFO interrupts are raised. This parameter can be any combination of

    • FDCAN_Tx_Event_Fifo_Interrupts

void HAL_FDCAN_RxFifo0Callback ( hal_fdcan_handle_t * hfdcan , uint32_t rx_fifo0_interrupts )

Rx FIFO 0 callback.

Warning

This weak function must not be modified. When the callback is needed, it must be implemented in the user file.

Parameters :
  • hfdcan – Pointer to a hal_fdcan_handle_t handle.

  • rx_fifo0_interrupts – indicates which Rx FIFO 0 interrupts are raised. This parameter can be any combination of

    • FDCAN_Rx_Fifo0_Interrupts.

void HAL_FDCAN_RxFifo1Callback ( hal_fdcan_handle_t * hfdcan , uint32_t rx_fifo1_interrupts )

Rx FIFO 1 callback.

Warning

This weak function must not be modified. When the callback is needed, it must be implemented in the user file.

Parameters :
  • hfdcan – Pointer to a hal_fdcan_handle_t handle.

  • rx_fifo1_interrupts – indicates which Rx FIFO 1 interrupts are raised. This parameter can be any combination of

    • FDCAN_Rx_Fifo1_Interrupts.

void HAL_FDCAN_TxFifoEmptyCallback ( hal_fdcan_handle_t * hfdcan )

Tx FIFO Empty callback.

Warning

This weak function must not be modified. When the callback is needed, it must be implemented in the user file.

Parameters :

hfdcan – Pointer to a hal_fdcan_handle_t handle.

void HAL_FDCAN_TxBufferCompleteCallback ( hal_fdcan_handle_t * hfdcan , uint32_t buffer_indexes )

Transmission complete callback.

Warning

This weak function must not be modified. When the callback is needed, it must be implemented in the user file.

Parameters :
  • hfdcan – Pointer to a hal_fdcan_handle_t handle.

  • buffer_indexes – Indexes of the transmitted buffers. This parameter can be any combination of

    • FDCAN_IT_Tx_Complete_Buffers_select.

void HAL_FDCAN_TxBufferAbortCallback ( hal_fdcan_handle_t * hfdcan , uint32_t buffer_indexes )

Transmission cancellation callback.

Warning

This weak function must not be modified. When the callback is needed, it must be implemented in the user file.

Parameters :
  • hfdcan – Pointer to a hal_fdcan_handle_t handle.

  • buffer_indexes – Indexes of the aborted buffers. This parameter can be any combination of

    • FDCAN_IT_Tx_Abort_Buffers_select.

void HAL_FDCAN_HighPriorityMessageCallback ( hal_fdcan_handle_t * hfdcan )

High priority message callback.

Warning

This weak function must not be modified. When the callback is needed, it must be implemented in the user file.

Parameters :

hfdcan – Pointer to a hal_fdcan_handle_t handle.

void HAL_FDCAN_TimestampWraparoundCallback ( hal_fdcan_handle_t * hfdcan )

Timestamp wraparound callback.

Warning

This weak function must not be modified. When the callback is needed, it must be implemented in the user file.

Parameters :

hfdcan – Pointer to a hal_fdcan_handle_t handle.

void HAL_FDCAN_ErrorCallback ( hal_fdcan_handle_t * hfdcan )

Error callback.

Warning

The hfdcan handle’s last_error_codes parameter is updated by the FDCAN processes, and the user can use HAL_FDCAN_GetLastErrorCodes() to verify the most recent error that occurred.

Warning

This weak function must not be modified. When the callback is needed, it must be implemented in the user file.

Parameters :

hfdcan – Pointer to a hal_fdcan_handle_t handle.

Error and State functions

group FDCAN_Exported_Functions_Group7

A set of functions allowing to process with the state and last process errors.

Functions

hal_fdcan_state_t HAL_FDCAN_GetState ( const hal_fdcan_handle_t * hfdcan )

Return the FDCAN state.

Parameters :

hfdcan – Pointer to a hal_fdcan_handle_t handle.

Returns :

hal_fdcan_state_t Current FDCAN state.

uint32_t HAL_FDCAN_GetLastErrorCodes ( const hal_fdcan_handle_t * hfdcan )

Return the FDCAN error code.

Parameters :

hfdcan – Pointer to a hal_fdcan_handle_t handle.

Returns :

Last error code, this code must be a value of FDCAN Error Codes .

Peripheral Acquire/Release/Free the bus

group FDCAN_Exported_Functions_Group8

A set of functions allowing to Acquire/Release the bus based on the HAL OS abstraction layer (stm32_hal_os.c/.h osal):

Functions

hal_status_t HAL_FDCAN_AcquireBus ( hal_fdcan_handle_t * hfdcan , uint32_t timeout_ms )

Acquire the FDCAN bus through the HAL OS abstraction layer (stm32_hal_os.c/.h osal).

Note

HAL_FDCAN_AcquireBus() must be called from thread mode only (not from handler mode i.e from ISR).

Parameters :
  • hfdcan – Pointer to a hal_fdcan_handle_t handle.

  • timeout_ms – Timeout duration in millisecond.

Return values :
  • HAL_OK – Operation completed successfully.

  • HAL_ERROR – Semaphore cannot be taken.

hal_status_t HAL_FDCAN_ReleaseBus ( hal_fdcan_handle_t * hfdcan )

Release the FDCAN bus through the HAL OS abstraction layer (stm32_hal_os.c/.h osal).

Note

HAL_FDCAN_ReleaseBus() can be called from thread mode or from handler mode i.e from ISR.

Parameters :

hfdcan – Pointer to a hal_fdcan_handle_t handle.

Return values :
  • HAL_OK – Operation completed successfully.

  • HAL_ERROR – Semaphore cannot be released.

User data Set/Get

group FDCAN_Exported_Functions_Group9

A set of functions allowing to manage a user data Pointer stored to the FDCAN handle:

Functions

void HAL_FDCAN_SetUserData ( hal_fdcan_handle_t * hfdcan , const void * p_user_data )

Set the user data pointer into the handle.

Parameters :
const void * HAL_FDCAN_GetUserData ( const hal_fdcan_handle_t * hfdcan )

Get the user data pointer from the handle.

Parameters :

hfdcan – Pointer to a hal_fdcan_handle_t .

Returns :

Current pointer to the user data.