HAL and LL inclusion model

Inclusion model

The stm32_hal.h file serves as the entry point header for any application using the HAL. It includes the following files in the specified order:

  • stm32tnxx_hal.h

  • stm32_hal_os.h (under the conditional flag USE_HAL_MUTEX)

  • Various HAL PPP modules (stm32tnxx_hal_ppp.h) under the conditional flag USE_HAL_PPP_MODULE

    Note

    HAL system modules such as RCC, GPIO, PWR, GTZC, and DMA should be included first.

  • stm32_assert.h (under the conditional flags USE_ASSERT_DBG_PARAM or USE_ASSERT_DBG_STATE)

Note

The stm32_assert.h file is provided as a template and, in case STM32CubeMX2 code generation is not used, it should be copied into the application and customized by the user if needed.

Each stm32tnxx_hal_ppp.h file includes the following:

  • stm32tnxx_hal_def.h

  • The required LL (Low-Layer) header file(s)

  • The required core driver(s)

The stm32tnxx_hal_ppp.c includes only stm32_hal.h.

The stm32tnxx_hal_def.h includes:

  • HAL Configuration Defines: By including the stm32tnxx_hal_conf.h.

  • Essential Types and Defines Related to STM32TN Devices: By including the specific Device Family Pack (DFP) header file, such as stm32tnxx.h.

  • Other Essential Types: By including standard headers like stddef.h and math.h.

This ensures that the stm32tnxx_hal_def.h file provides all necessary types and definitions required for the given HAL drivers. Additionally, the user configuration is retrieved from the lowest HAL header file in the inclusion model ( stm32tnxx_hal_def.h) as it includes the stm32tnxx_hal_conf.h. Thus, the HAL user configuration is propagated to all HAL driver modules.

The core drivers reside below the HAL and are not dependent on any HAL driver or file. The only allowed dependency for a stm32tnxx_ppp_core.h core driver header file is on the device header file stm32tnxx.h. This ensures that the core driver remains independent and can function without relying on higher-level HAL components. The stm32tnxx_ppp_core.c includes the stm32tnxx_ppp_core.h.