Introduction
STM32Cube is an STMicroelectronics original initiative to significantly improve developer productivity by reducing development
ef
fort, time and cost. STM32Cube covers the STM32 portfolio.
STM32Cube includes:
STM32CubeMX, a graphical software configuration tool that allows the generation of C initialization code using graphical
wizards.
A comprehensive embedded software platform, delivered per Series (such as STM32CubeG0 for STM32G0 Series)
The STM32Cube HAL, STM32 abstraction layer embedded software ensuring maximized portability across the
STM32 portfolio. HAL APIs are available for all peripherals.
Low-layer APIs (LL) offering a fast light-weight expert-oriented layer which is closer to the hardware than the HAL. LL
APIs are available only for a set of peripherals.
A consistent set of middleware components such as FAT file system, RTOS, USB and USB PD.
All embedded software utilities, delivered with a full set of examples.
The HAL driver layer provides a simple, generic multi-instance set of APIs (application programming interfaces) to interact with
the upper layer (application, libraries and stacks). The HAL driver APIs are split into two categories: generic APIs, which provide
common and generic functions for all the STM32 series and extension APIs, which include specific and customized functions for
a given line or part number. The HAL drivers include a complete set of ready-to-use APIs that simplify the user application
implementation. For example, the communication peripherals contain APIs to initialize and configure the peripheral, manage
data transfers in polling mode, handle interrupts or DMA, and manage communication errors. The HAL drivers are feature-
oriented instead of IP-oriented. For example, the timer APIs are split into several categories following the IP functions, such as
basic timer, capture and pulse width modulation (PWM). The HAL driver layer implements run-time failure detection by checking
the input values of all functions. Such dynamic checking enhances the firmware robustness. Run-time detection is also suitable
for user application development and debugging.
The LL drivers offer hardware services based on the available features of the STM32 peripherals. These services reflect exactly
the hardware capabilities, and provide atomic operations that must be called by following the programming model described in
the product line reference manual. As a result, the LL services are not based on standalone processes and do not require any
additional memory resources to save their states, counter or data pointers. All operations are performed by changing the
content of the associated peripheral registers. Unlike the HAL, LL APIs are not provided for peripherals for which optimized
access is not a key feature, or for those requiring heavy software configuration and/or a complex upper-level stack (such as
USB).
The HAL and LL are complementary and cover a wide range of application requirements:
The HAL offers high-level and feature-oriented APIs with a high-portability level. These hide the MCU and peripheral
complexity from the end-user.
The LL offers low-level APIs at register level, with better optimization but less portability. These require deep knowledge of
the MCU and peripheral specifications.
The HAL- and LL-driver source code is developed in Strict ANSI-C, which makes it independent of the development tools. It is
checked with the CodeSonar
®
static analysis tool. It is fully documented.
The next release will be compliant with MISRA C
®
:2012 standard.
Description of STM32G0 HAL and low-layer drivers
UM2319
User manual
UM2319 - Rev 2 - October 2020
For further information contact your local STMicroelectronics sales of
fice.
www.st.com
This user manual is structured as follows:
Overview of HAL drivers
Overview of low-layer drivers
Cohabiting of HAL and LL drivers
Detailed description of each peripheral driver: configuration structures, functions, and how to use the given API to build
your application
UM2319
UM2319 - Rev 2
page 2/2202