About the difference between standard library functions and stm32 programming methods based on HAL library functions

Differences between stm32 programming methods based on standard library functions and HAL library functions


One, the standard library

STM32 has a lot of registers, which causes development difficulties. For this reason, a library file is written for each chip, that is, stm32F1xx... in the project file. In these .c.h files, there are macro definitions of some commonly used quantities, and some peripherals are also encapsulated through structural variables, such as GPIO port clock. So we only need to configure the variable members of the structure to modify the configuration registers of the peripherals to select different functions. It is also the way most people use it, and it is also the development way that learns STM32 the most contact.

Two, HAL library

It appears later than the standard library, but in fact, like the standard library, it is to save the time of program development, and the HAL library is especially effective. If the standard library integrates the registers that need to be configured to implement functions, then the HAL library Some functions can even integrate some specific functions. In other words, for the same function, the standard library may take a few sentences, while the HAL library only needs one sentence. And the HAL library is also a good solution to the problem of program migration. The standard library of different models of stm32 chips is different. For example, the program developed on F4 is not universal when transplanted to F3, and the HAL library is used as long as The same peripherals are used, and the program can basically be copied and pasted completely.

Guess you like

Origin blog.csdn.net/rude_dragon/article/details/111178311