RAL RAL ST
Register Abstraction Layer module: combines STMicroelectronics' original HAL/LL drivers with Embedbits' own hardware-independent interface layer (Port/). Consumed as a git submodule of Bsp-Ral, one branch per STM32 family/release.
Overview
Upstream project (Stm32_Drv/) | STMicroelectronics/stm32<family>xx_hal_driver (e.g. stm32g4xx_hal_driver) |
Embedbits-owned content (Port/) | Unified, family-independent function/header naming on top of the ST HAL/LL API |
| Role in Bsp-Ral | Source of both Ral_Lib (recommended, Port/-only interface) and HAL_LL_Lib (full ST HAL/LL access) |
| License | See Stm32_Drv/License.md for the ST-derived driver sources; Embedbits' Port/ layer follows the parent repository's license |
| Maintenance model | Stm32_Drv/ is mirrored from upstream ST per family and must not be modified locally; Port/ is maintained by Embedbits |
⚠️ Do not modify
Stm32_Drv/directly — updates are tracked against the original ST repository. Hardware-independent changes belong inPort/.
Branch Structure
| Branch pattern | Purpose |
|---|---|
STM32<family> (e.g. STM32G4, STM32U5, STM32H7) | Family branch, derived from master, holding the ST HAL/LL drivers and the Port/ interface for that family |
STM32<family>_<major>.x (e.g. STM32G4_1.x) | Major release branch, derived from the family branch, tracking an ST HAL major release |
STM32<family>_<major>.<minor> (e.g. STM32G4_1.2) | Minor/patch release branch, derived from the major release branch |
All family branches derive from master.
Repository Structure
RAL_ST
├── Port # Embedbits' hardware-independent interface layer
│ ├── Stm32.h # Umbrella include
│ ├── Stm32_tim.h # Unified timer interface
│ ├── Stm32_i2c.h # Unified I2C interface
│ ├── Stm32_spi.h # Unified SPI interface
│ ├── Stm32_gpio.h
│ ├── Stm32_usart.h
│ └── ... # One header per peripheral, family-independent naming
└── Stm32_Drv # Original HAL/LL drivers, unmodified from STMicroelectronics
├── Inc # HAL/LL headers (e.g. stm32g4xx_ll_tim.h)
├── Src # HAL/LL sources (e.g. stm32g4xx_ll_tim.c)
└── License.md
Port/ — unified interface
Port/ exposes one header per peripheral with function/type naming independent of the STM32 family, so application code can switch STM32 families without changing its own source:
#include "Stm32_tim.h" // Automatically selects the correct HAL headers based on the target MCU define
Usage
Both Ral_Lib and HAL_LL_Lib are defined in Bsp-Ral's top-level CMakeLists.txt and consume this module's two directories:
| CMake target | Public include path | Intended use |
|---|---|---|
Ral_Lib | RAL_ST/Port/ | Recommended. Stable, hardware-independent API for application/middleware code |
HAL_LL_Lib | RAL_ST/Stm32_Drv/Inc/ | Full ST HAL/LL access, for internal integration and testing only |
# Recommended interface
target_link_libraries(MyApp PRIVATE Ral_Lib)
# Extended low-level access (not recommended for modular projects)
target_link_libraries(MyApp PRIVATE HAL_LL_Lib)
#include "Stm32_tim.h" // Unified abstraction header, via Ral_Lib
⚠️
Ral_Libis the only officially supported interface for external projects. UseHAL_LL_Libonly when a direct ST HAL/LL API is explicitly required.
License
Stm32_Drv/ components are derived from STMicroelectronics HAL/LL drivers under their respective license — see Stm32_Drv/License.md. The Port/ interface layer is original Embedbits code, distributed under the parent Bsp-Ral repository's license.