HAL and LL drivers’ files

The HAL & LL drivers are composed of the following set of files:

hal/
  |-- stm32tnxx/
      |-- _htmresc/
      |-- hal/
      |   |-- stm32tnxx_hal_def.h
      |   |-- stm32tnxx_hal_ppp.c
      |   |-- stm32tnxx_hal_ppp.h
      |   |-- stm32tnxx_hal.c
      |   |-- stm32tnxx_hal.h
      |   |-- stm32tnxx_ppp_core.c
      |   `-- stm32tnxx_ppp_core.h
      |-- ll/
      |   |-- stm32tnxx_ll_ppp.h
      |-- os_port/
      |   |-- freertos/
      |   |   |-- stm32_hal_os.c
      |   |   `-- stm32_hal_os.h
      |   `-- no_os/
      |       |-- stm32_hal_os.c
      |       `-- stm32_hal_os.h
      |-- templates/
      |   |-- common/
      |   |   |-- mx_hal_def.h
      |   |   |-- stm32_assert.h
      |   |   |-- stm32_ll.h
      |   |   `-- stm32tnxx_hal_conf.h
      |   |-- os_port/
      |   |   |-- stm32_hal_os.c
      |   |   `-- stm32_hal_os.h
      |   `-- timebases/
      |       |-- mx_rtc.c
      |       |-- mx_rtc.h
      |       |-- mx_timx.c
      |       `-- mx_timx.h
      |-- timebases/
      |   |-- stm32_hal_timebase_rtc_alarm.c
      |   |-- stm32_hal_timebase_rtc_wakeup.c
      |   |-- stm32_hal_timebase_tim.c
      |-- utils/
      |   |-- i2c_timing/
      |   |   |-- stm32_utils_i2c.c
      |   |   `-- stm32_utils_i2c.h
      |   `-- i3c_timing/
      |-- license.md
      |-- README.md
      |-- Release_Notes.html
      `-- STMicroelectronics.stm32tnxx_hal.pdsc

File

Description

stm32_hal.h

HAL global include file: to be series agnostic, this file is the central file to be included by the application for the HAL.

stm32tnxx_hal.c

This file provides the following APIs: The HAL initialization deinitialization, The HAL Tick management and APIs allowing to retrieve the device unique ID and the HAL drivers version.

stm32tnxx_hal.h

stm32tnxx_hal.c header file.

stm32tnxx_hal_ppp.c

PPP peripheral/module driver file. It provides the implementation of APIs that are common to all STM32 devices, also specific functionalities linked to the series (no more stm32tnxx_hal_ppp_ex.c/h ). Example: stm32tnxx_hal_adc.c , stm32tnxx_hal_i2c.c , … etc.

stm32tnxx_hal_ppp.h

Header file of the PPP peripheral/module driver C file. It includes common data, handle, enumeration structures, define statements and macros, as well as the exported generic and specific functions. Example: stm32tnxx_hal_adc.h , stm32tnxx_hal_i2c.h , … etc.

stm32tnxx_ppp_core.c

Peripheral core driver that can be accessed from one or more HAL drivers. It offers a set of APIs and services used by the upper HAL PPP driver. Example: stm32tnxx_fmc_core.c offers a set of API used by stm32tnxx_hal_sdram.c , stm32tnxx_hal_sram.c , stm32tnxx_hal_nor.c , stm32tnxx_hal_nand.c , …

stm32tnxx_ppp_core.h

Header file of the core driver C file. It is included in the HAL PPP driver header file, thus making the core driver as intrinsic add-on of the HAL PPP driver that is not visible from the application. Example: stm32tnxx_fmc_core.h , stm32tnxx_usb_core.h , …

stm32tnxx_ll_ppp.h

Low layer drivers for peripherals covered by the low layer drivers’ program

stm32tnxx_hal_def.h

Common HAL resources such as common define statements, enumerations, structures, macros and HAL include files.

stm32tnxx_hal module

The stm32tnxx_hal module is limited to the following services:

  • HAL Init and De-Init

  • Tick/Time base management

  • An API to retrieve the device unique ID

  • An API to retrieve the HAL version

The stm32tnxx_hal module APIs and services are consistent across all STM32 series and are limited to the aforementioned services. The implementation of these APIs might vary from one series to another. Nevertheless, the API list and prototypes remain the same across all series.

Contrary to HAL1, the specific SoC services APIs (e.g., DBGCMU, SYCFG, SBS, etc.) are not provided within the stm32tnxx_hal module. Instead, they are offered by the following modules:

  • The APIs that are related to the DBGMCU are provided by the HAL module: stm32tnxx_hal_dbgmcu.h and stm32tnxx_hal_dbgmcu.c

  • The APIs that are related to the SBS are provided by the HAL module: stm32tnxx_hal_sbs.h and stm32tnxx_hal_sbs.c

  • The APIs that are related to the SYSCFG are provided by the HAL module: stm32tnxx_hal_syscfg.h and stm32tnxx_hal_syscfg.c

  • APIs related to the VREFBUF are be provided by the HAL module: stm32tnxx_hal_vrefbuf.h and stm32tnxx_hal_vrefbuf.c (the API is HAL_VREFBUF_XXX without SYSCFG)

  • ART/PREFETCH APIs are available within the HAL flash module

  • EXTI APIs (if any) are provided by the HAL EXTI driver

stm32tnxx_hal_def.h module

The stm32tnxx_hal_def.h provides essential configurations and definitions for the STM32 HAL. It includes the following:

  • HAL Configuration Definitions:

    • By including the stm32tnxx_hal_conf.h , it provides the necessary configuration settings for the HAL.

  • Essential Types and Definitions Related to STM32TN Devices:

    • By including the specific Device Family Pack (DFP) header file, such as stm32u5xx.h , it ensures the inclusion of essential types and definitions related to the given STM32TN devices.

    • Additionally, it includes other essential types by incorporating the standard headers stddef.h and math.h .

  • HAL Status Enumeration and Defines:

    • The hal_status_t enumeration type, used by the HAL APIs to return status, is defined within this file.

    • It also defines the HAL maximum delay (HAL_MAX_DELAY).

    • The file includes defines for the HAL Peripheral Clock enabling model, which are used to activate or deactivate the Peripheral Clock within various HAL_PPP_Init functions according to the user choices set in the stm32tnxx_hal_conf.h .

  • HAL_CHECK_UPDATE_STATE Macro:

  • The macro HAL_CHECK_UPDATE_STATE allows checking and updating the state with two flavours according to the USE_HAL_CHECK_PROCESS_STATE option set in the stm32tnxx_hal_conf.h .

    • An implementation with atomic check and update of the state from one original state to one destination state if USE_HAL_CHECK_PROCESS_STATE is defined to 1 .

    • An implementation with direct assignment of the state to the new desired state without any check if USE_HAL_CHECK_PROCESS_STATE is defined to 0.

By providing these configurations and definitions, the stm32tnxx_hal_def.h ensures that the HAL is properly configured and ready to be used with the given STM32TN devices.