There are a couple of new terms and concepts I’m learning while working with STM32. I will add more as they appear.

Hardware Abstraction Layer (HAL)

Not really new, but STM32 makes it explicit. On other platforms, the abstraction is provided by the libraries for a specific chip we import into the code. In STM32, the functions and parameters are masked with generic names, are organized in a HAL library, and their names start with HAL_. HAL provides the highest level of abstraction and is uniform across STM32 MCUs, enabling portability and simplifying peripheral configuration and access. In addition, the HAL library is available for all peripherals.

The downside is increased memory usage and overhead. That can be a problem when you need precise runtime control or efficient memory use.

The document Description of STM32F2 HAL and low-layer drivers (UM1940) gives a complete description of the library.

Low-Layer (LL) APIs

LL offers functions that are one step closer to the hardware than HAL. It masks the hardware, but allows access to registers and detailed peripheral configuration. This level of control allows better optimization but requires deeper technical knowledge of the MCU and compromises portability. Moreover, ST provides LL APIs for only a restricted number of peripherals.

The specification of the LL APIs is in the same document that describes HAL.

Board Support Packages (BSP)

While HAL and LL operate at the MCU level, BSP does it at the board level. On an evaluation board, many peripherals, pins, inputs, outputs, voltages, etc., are fixed by the board design, so its configuration is clearly defined, and the peripheral functions are linked with a high-level action. The BSP driver reflects that design, simplifying the programming. For example, a board might have a green LED connected to Pin 19 (PA5), which is configured as a digital output. Well, the BSP driver will mask pin 19 as GREEN_LED, and provide a function that correctly configures the peripheral for you. BSP raises the abstraction level an additional step.

ST provides BSP drivers for its development boards, but you can also write a library for your architecture.

More details about BSP are in the document STM32Cube BSP drivers development guidelines (UM2298).

STM32 APIs scheme Figure 1. Scheme of the different layers in the STM32 APIs. BSP uses HAL, LL, and the board architecture to provide high-level access to hardware.1