1, what is the STM32 function library
The above mentioned software library refers to "STM32 standard function library", it is provided by St Company for STM32 function interface, namely API (application program Interface), developers can call these function interfaces to configure the STM32 register, Enables developers to disengage from the lowest register operation;
In fact, the library is the code that is erected between the register and the user-driven layer, processing the configuration directly related to the Register, and providing the user with an interface for the configuration register.
The difference between the library development mode and the direct configuration register method is shown in Figure 8-1!!!!!!!
2, why use the library to develop and learn?
、、、、、、、
Now the STM32F1 series and STM32F4 series have their own library of functions, but most of them are compatible, and the program porting between F1 and F4 requires only minor modifications. To cultivate C language, start with the library of St. So in a later chapter, the use of the software library is our focus, and we explain the library API to efficiently learn STM32 register, and not because of library learning, will not register control STM32 chip.
3. Building the library function cone
1) Modify Register address encapsulation
2) Define the struct pointer that accesses the peripheral
At first glance, in addition to the last part, the BSRR register into the bsrrh and BSRRL two, the other part with the direct access to the absolute address just changed the name, use up with a chapter no difference. This is because we now only implement the base of the library functions, and have not defined library functions.
Defining bit manipulation functions
3) Define initialization structure body GPIO_INITTYPEDEF
4) Define the enumeration type for PIN mode
5) Defining the GPIO initialization function
6) New Look, use function to highlight LED lights
With this in order, we can define our own function to illuminate the LED lights, see listing 8-15.
Summarize
Write your own library-build library function prototype