HAL FDCAN Overview

Introducing FDCAN

group FDCAN_Introduction

The FDCAN hardware abstraction layer provides a comprehensive software interface to support the communication protocol on STM32 microcontrollers. FDCAN (Flexible Data-rate Controller Area Network) is an advanced communication protocol that extends the classical CAN protocol to support higher data rates and improved error handling capabilities. It is designed to meet the requirements of modern automotive and industrial applications.

This peripheral conforms to CAN protocol version 2.0 part A, part B, and ISO 11898-1. This HAL driver abstracts low-level hardware details, enabling configuration, data transfer, and interrupt handling, thereby accelerating development and ensuring robust and scalable embedded applications leveraging the full capabilities of the CAN-FD bus.

Module and files

The following diagram illustrates the FDCAN module and its associated files.

Module and files diagram

Component diagram

The following diagram illustrates the software components involved in the FDCAN module. It shows the interactions between the user application, HAL drivers, low-level drivers, and the hardware components.


@startuml
<style>
componentDiagram {
   arrow {
      FontSize 8
   }
}
</style>

title FDCAN Software Component Diagram

package "HAL" {
    [HAL_SERVICE]
    [HAL_FDCAN]
}

package "Low Layer" {
    [CMSIS]
    [FDCAN ISR]
}

package "HW" {
    [STM32_HW]
}

[Appli] --> [HAL_FDCAN] : HAL FDCAN API
[Appli] <-- [HAL_FDCAN] : FDCAN callback
[HAL_FDCAN] -l-> [HAL_SERVICE] : HAL_GetTick
[HAL_FDCAN] <-- [FDCAN ISR]
[HAL_FDCAN] --> [CMSIS]:FDCAN register def
[STM32_HW] -u--> [FDCAN ISR]: FDCANx_ITy Irq
[STM32_HW] <--u--- [HAL_FDCAN] : FDCAN registers R/W
@enduml

Configuration table

The following table lists the configuration defines for the HAL FDCAN module, specifying their locations, default values, and descriptions:

group FDCAN_Configuration_Table

  1. Configuration inside the FDCAN driver

Software configuration defined in stm32c5xx_hal_conf.h:

Preprocessor flags

Default value

Comment

USE_HAL_FDCAN_MODULE

1

Enable HAL FDCAN driver module

USE_HAL_FDCAN_REGISTER_CALLBACKS

0

Allow the user to define their own callback

USE_HAL_CHECK_PARAM

0

Enable runtime parameter check

USE_HAL_FDCAN_CLK_ENABLE_MODEL

HAL_CLK_ENABLE_NO

Enable the gating of the peripheral clock

USE_HAL_CHECK_PROCESS_STATE

0

Enable atomicity of process state check

USE_HAL_MUTEX

0

Enable semaphore creation for OS

USE_HAL_FDCAN_USER_DATA

0

Add a user data inside HAL FDCAN handle

USE_HAL_FDCAN_GET_LAST_ERRORS

0

Enable retrieval of the last process error codes

Software configuration defined in preprocessor environment:

Preprocessor flags

Default value

Comment

USE_ASSERT_DBG_PARAM

Not defined

Enable check param for HAL

USE_ASSERT_DBG_STATE

Not defined

Enable check state for HAL