Small knowledge, big challenge! This article is participating in the creation activity of “Essential Tips for Programmers”.
STM32 series of STMICROELECTRONICS support library function programming, library function is more easy to transplant than the conventional register programming, especially projects need to transplant on several series of chips, using library function programming, the underlying configuration need not change. The business logic itself is generic, so migration costs are low. But because the library function function call nesting level is more, the execution efficiency is not high register, register code is not so concise. It is recommended for beginners to use registers, which are more general for cpus of different manufacturers and can be more clearly understood at the bottom of registers.
STM32 currently supports normal library functions (latest version 3.5), HAL two kinds of library functions (later out, is also the mainstream later), the following tutorial uses 3.5 earlier library functions to create a project.
Obtain the standard peripheral firmware library
ST official website: www.st.com
Download the STM32F1 series standard peripheral firmware library: my.st.com/content/my_…
STM32F1 series final standard peripheral firmware library version is 3.5.0, you can directly search the software code: STSW-STM32054 for download.
If you do not know the version code, you can also find the download link in the software tools section on the official website.
Second, the use of standard peripheral firmware library construction project
The template of the new project is used, the template of the register is the same, but it needs to add some standard peripheral library files.
Copy the standard driver folder from the downloaded standard peripheral library into the current project. It contains the inc and SRC folders, which correspond to the library header and the library source files.
In the project SYSLIB directory, on the basis of the previous increase in 3 files, one is the configuration file, the other two are interrupt handling files, can be found in the standard library routines.