Overview of HAL drivers
2
Overview of HAL drivers
The HAL drivers were designed to offer a rich set of APIs and to interact easily with the
application upper layers.
Each driver consists of a set of functions covering the most common peripheral features.
The development of each driver is driven by a common API which standardizes the driver
structure, the functions and the parameter names.
The HAL drivers include a set of driver modules, each module being linked to a standalone
peripheral. However, in some cases, the module is linked to a peripheral functional mode.
As an example, several modules exist for the USART peripheral: UART driver module,
USART driver module, SMARTCARD driver module and IRDA driver module.
The HAL main features are the following:
Cross-family portable set of APIs covering the common peripheral features as well as
extension APIs in case of specific peripheral features.
Three API programming models: polling, interrupt and DMA.
APIs are RTOS compliant:
Support for peripheral multi-instance allowing concurrent API calls for multiple
instances of a given peripheral (USART1, USART2...)
All HAL APIs implement user-callback functions mechanism:
Object locking mechanism: safe hardware access to prevent multiple spurious
accesses to shared resources.
Timeout used for all blocking processes: the timeout can be a simple counter or a
timebase.
2.1
HAL and user-application files
2.1.1
HAL driver files
A HAL drivers are composed of the following set of files:
stm32f2xx_hal_ppp.c
stm32f2xx_hal_ppp.h
28/1371
Fully reentrant APIs
Systematic usage of timeouts in polling mode.
Peripheral Init/DeInit HAL APIs can call user-callback functions to perform
peripheral system level Initialization/De-Initialization (clock, GPIOs, interrupt,
DMA)
Peripherals interrupt events
Error events.
File
DocID028236 Rev 2
Table 2: HAL driver files
Main peripheral/module driver file.
It includes the APIs that are common to all STM32 devices.
Example: stm32f2xx_hal_adc.c, stm32f2xx_hal_irda.c, ...
Header file of the main driver C file
It includes common data, handle and enumeration structures,
define statements and macros, as well as the exported generic
APIs.
Example: stm32f2xx_hal_adc.h, stm32f2xx_hal_irda.h, ...
Description
UM1940
Need help?
Do you have a question about the STM32F2 and is the answer not in the manual?
Questions and answers