General HAL and LL Design Aspects

The Portable APIs layer (HAL and Low-Layer drivers) provides a generic, multi-instance, and simple set of APIs to interact with the upper layer (application, libraries, and stacks). It is composed of an API set that is directly built around a generic architecture and allows the build-upon layers, like the middleware layer, to implement its functions without knowing in-depth the used STM32 device. This improves the library code reusability and guarantees easy portability on other devices and STM32 families.

The HAL drivers have to offer a rich set of APIs to interact easily with the application upper layers. Each driver consists of a set of functions covering the full peripheral features. The development of each driver is driven by a common API, which standardizes the driver structure, the functions, and the parameter names.

Architecture principles for resources management

The following principles are considered within the HAL/LL drivers:

  • The resource types and defines are belong to the given SW layer: The resource types and defines are prefixed by the layer prefix : ex “ HAL_ ” or “ hal_ ” then the module (Ex HAL_FLASH or hal_flash)

  • Each SW layer uses its own resources and types: data structures, enum, error management…

  • Layering resources translation: In case of vertical layering (Ex HAL on top of the LL), a translation phase is required inside the upper layer implementation to accommodate to the lower layer resources (user must not care about it)

  • In case of cohabitating 2 layers at user application (Horizontal interaction) : a translation API is provided allowing the user to move from a Layer A type to the equivalent Layer B type regarding the required objects.