CN / EN
Doc Feedback
Thanks for your interest, welcome to contact us.
Thanks for your feedback
No matches were found 114page(s) matching the search query
Documentation > GR5xx APP Driver User Manual/ Overview/ Driver Architecture Copy URL

Driver Architecture

GR5xx driver architecture is divided into the application layer (APP), the hardware abstraction layer (HAL), and the low layer (LL), corresponding to APP drivers, HAL drivers, and LL drivers respectively, as shown below.

Figure 2 Driver architecture

APP, HAL, and LL drivers are correlated in the software architecture. APP drivers are encapsulated based on HAL drivers and called by the application layer, to implement frequently used functionalities of peripherals. HAL drivers access hardware by calling the related LL APIs.

In most cases, it is recommended to use APP drivers.

APP Drivers

The APP drivers are designed to provide a rich set of APIs encapsulated based on HAL drivers. Each driver consists of a set of functionalities, covering the most common peripheral features. The APIs not only inherit all features of HAL drivers, but also highlight stability, security, and being easy-to-use. Developers can call the APIs directly in application programming with no need to care about register configurations.

APP drivers feature:

  • Uniformly defined basic parameters of peripherals. Developers can initialize a peripheral by configuring the basic parameters only, with no need to care about implementation details.
  • Flexibility with APIs for polling/interrupt/DMA transmission provided
  • Automatic sleep management, without requiring re-initialing peripherals after MCU wake-up
  • State self-management, which can quickly identify the current state of a peripheral based on the API return value
  • Supporting calling user interrupt callback functions in initialization/deintialization APIs of peripherals. When an interrupt event is triggered, the corresponding user callback function will be called.

APP driver files are available in SDK_Folder\drivers in the SDK. Header files (such as app_xxx.h) are in the inc folder, which declare the structures and APIs of peripherals; sources files (such as app_xxx.c) are in the src folder, which implement driver APIs.

Note:

SDK_Folder is the root directory of an SDK.

The sequence to call APP driver files is shown in the figure below.

Figure 3 Sequence to call APP driver files

HAL Drivers

HAL drivers encapsulate the functionalities of various peripherals into a series of simple APIs, facilitating interactions between lower-level peripheral hardware and upper-level applications.

HAL drivers feature:

  • APIs compatible with System-on-Chips (SoCs) of the same series. Some special functionalities of SoCs can be implemented with extended APIs.
  • Supporting more than one instance: Users can call an API in more than one instance (such as I2C1 and I2C2) of the same peripheral.
  • Supporting calling user callback functions in initialization/deintialization APIs of peripherals, to initialize/deinitialize clock/GPIO/interrupt/DMA module
  • Supporting calling callback functions in a peripheral interrupt event/error, to inform users of triggering the corresponding event
  • Timeout mechanism to deal with driver polling events, to avoid infinite loop in a program

LL Drivers

LL drivers encapsulate the atomic operations of all peripheral registers by using inline functions. LL drivers are closer to the hardware than HAL drivers, offering APIs covering all peripheral functionalities. Developers can use LL drivers to configure peripheral functionalities that are not covered by HAL drivers. For performance-demanding scenarios, developers can directly use LL drivers.

LL drivers feature:

  • Implementation with inline functions, not requiring function calling
  • Encapsulation of register operations, with a high-level portability and reusability
  • Full coverage of peripheral functionalities

Scan to follow

Open WeChat, use "Scan" to follow.