Design Concepts of Hardware Abstraction Layer (HAL & BSP) Part Two

1 BSP Design Example (Taking STM32 Hardware Platform as an Example)

Design Concepts of Hardware Abstraction Layer (HAL & BSP) Part Two

Design Concepts of Hardware Abstraction Layer (HAL & BSP) Part Two

Design Concepts of Hardware Abstraction Layer (HAL & BSP) Part Two

2 Summary of Hardware Abstraction Layer Design

2.1 Key Points in Module Header File Design

1. Only include definitions of data types and descriptions of interface functions provided for external calls.

2. Generally, do not define variables or describe hardware-related resources, nor include any other header files, to ensure the universality of the header file.

3. The application layer only calls the interface functions provided by the header file, so there is no need to modify the application layer code.

2.2 Key Points in Module Source File Design

1. Implement the interface functions (note the design of RTOS interface reentrant or exclusive resource functions).

2. Include relevant header files.

3. Define variables within the module and all definitions related to hardware.

4. Call the interface functions provided by the HAL library (here, HAL refers to the STM32 HAL library, not the abbreviation for Hardware Abstraction Layer), perform secondary encapsulation, and provide a module interface function with better readability and portability.

————————————————

Copyright Statement: The source of this article is from CSDN’s Ning Jing Zhi Yuan 2021. This account maintains neutrality regarding all original and reprinted articles’ statements and viewpoints; the articles are sent for readers’ learning and communication only. The copyright of articles, images, etc. belongs to the original authors. If there is any infringement, please contact for deletion.

Original link: https://blog.csdn.net/m0_46577050/article/details/121050337

Leave a Comment