Introduction to STM32Cube
STM32Cube is an initiative by STMicroelectronics designed to significantly enhance developer productivity by reducing development effort, time, and cost across the STM32 portfolio. This comprehensive ecosystem includes:
- STM32CubeMX: A graphical software configuration tool for generating C initialization code via visual wizards.
- Embedded Software Platform: Delivered per series (e.g., STM32CubeG4 for STM32G4), providing a complete embedded software package.
- HAL (Hardware Abstraction Layer): An abstraction layer ensuring maximized portability across the STM32 portfolio, with APIs available for all peripherals.
- Low-Layer (LL) APIs: A fast, lightweight, expert-oriented layer closer to the hardware, available for a select set of peripherals.
- Middleware Components: Including RTOS and USB.
- Embedded Software Utilities: Delivered with a full set of examples.
HAL Driver Features
The HAL driver layer offers a simple, generic set of APIs for interacting with application upper layers. Key features include:
- Cross-family portable APIs covering common and specific peripheral features.
- Support for three programming models: polling, interrupt, and DMA.
- RTOS compliance with fully reentrant APIs and systematic use of timeouts.
- Multi-instance support for concurrent API calls for multiple peripheral instances.
- User-callback functions for peripheral initialization, de-initialization, interrupt events, and error events.
- An object locking mechanism for safe access to shared resources.
- Timeouts for all blocking processes.
Low-Layer (LL) Driver Features
LL drivers provide hardware services directly mapped to peripheral capabilities. They offer:
- An expert-oriented layer with optimized performance but less portability.
- Direct register manipulation, requiring a deep understanding of MCU and peripheral specifications.
- APIs are not provided for peripherals where optimized access is not critical or requires complex software configuration.
Complementary Nature of HAL and LL
The HAL and LL drivers are designed to be complementary, covering a wide range of application requirements. HAL offers high-level, portable APIs, while LL provides optimized, low-level access.
Development Standards
The HAL and LL driver source code is developed in Strict ANSI-C, ensuring tool independence. It is checked with the CodeSonar® static analysis tool and is fully documented, adhering to the MISRA C®:2012 standard.
Further Information
For detailed information on specific peripherals, driver structures, functions, and usage examples, please refer to the full documentation available on the STMicroelectronics website.