Write your own library-build library function prototype

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.