UM1940
4
Cohabiting of HAL and LL
The Low Layer is designed to be used in standalone mode or combined with the HAL. It
cannot be automatically used with the HAL for the same peripheral instance. If you use the
LL APIs for a specific instance, you can still use the HAL APIs for other instances. Be
careful that the Low Layer might overwrite some registers which content is mirrored in the
HAL handles.
4.1
Low Layer driver used in standalone mode
The Low Layer APIs can be used without calling the HAL driver services. This is done by
simply including stm32f2xx_ll_ppp.h in the application files. The LL APIs for a given
peripheral are called by executing the same sequence as the one recommended by the
programming model in the corresponding product line reference manual. In this case the
HAL drivers associated to the used peripheral can be removed from the workspace.
However the STM32CubeF2 framework should be used in the same way as in the HAL
drivers case which means that System file, startup file and CMSIS should always be used.
4.2
Mixed use of Low Layer APIs and HAL drivers
In this case the Low Layer APIs are used in conjunction with the HAL drivers to achieve
direct and register level based operations.
Mixed use is allowed, however some consideration should be taken into account:
It is recommended to avoid using simultaneously the HAL APIs and the combination of
Low Layer APIs for a given peripheral instance. If this is the case, one or more private
fields in the HAL PPP handle structure should be updated accordingly.
For operations and processes that do not alter the handle fields including the
initialization structure, the HAL driver APIs and the Low Layer services can be used
together for the same peripheral instance.
The Low Layer drivers can be used without any restriction with all the HAL drivers that
are not based on handle objects (RCC, common HAL, flash and GPIO).
Several examples showing how to use HAL and LL in the same application are provided
within stm32f2 firmware package (refer to Examples_MIX projects).
When the BSP drivers are included, the used HAL drivers associated with the
BSP functions drivers should be included in the workspace, even if they are not
used by the application layer.
1.
When the HAL Init/DeInit APIs are not used and are replaced by the Low
Layer macros, the InitMsp() functions are not called and the MSP
initialization should be done in the user application.
2.
When process APIs are not used and the corresponding function is
performed through the Low Layer APIs, the callbacks are not called and post
processing or error management should be done by the user application.
3.
When the LL APIs is used for process operations, the IRQ handler HAL APIs
cannot be called and the IRQ should be implemented by the user application.
Each LL driver implements the macros needed to read and clear the
associated interrupt flags.
DocID028236 Rev 2
Cohabiting of HAL and LL
69/1371
Need help?
Do you have a question about the STM32F2 and is the answer not in the manual?
Questions and answers