STM32F4xx firmware library analysis

STM32F4xx firmware library

The standard software library provided by ST company contains the control operation of all registers of the STM32 chip. We can learn how to use the ST standard library directly, which greatly facilitates rapid development.

  • Firmware library file structure

    The file structure of the firmware library clearly expresses the relationship between the firmware library files, and it is worth taking a closer look:
    Firmware library file structure
  • The relationship between CMSIS standards and libraries

Before analyzing the firmware library, we must understand what CMSIS is and what it has to do with the firmware library.

The cores used in Cortex series chips are all the same, and the difference is mainly the difference of on-chip peripherals outside the core. These differences make it difficult to transplant software on chips with the same core and different peripherals. In order to solve the compatibility problem of Cortex microcontroller software produced by different chip manufacturers, ARM and chip manufacturers established the CMSIS standard (Cortex MicroController Software Interface Standard)-Cortex MicroController Software Interface Standard

It can be seen from the description that CMSIS is a software abstraction layer that shields the differences between the same core and different peripheral chips to solve the problem of program portability and compatibility. As follows:
CMSIS architecture
CMSIS is related to the core. Any chip based on these cores needs the support of the core to write programs; the firmware library must also be developed based on CMSIS.

Note: Note: Note: Note Italy: The functions of the core are provided by ARM, mainly the names and address definitions of some core registers; the peripheral functions outside the core are provided by the chip manufacturer, including the addresses of the external peripherals and interrupt definitions.

The CMSIS layer is located between the hardware layer and the operating system or user layer. It provides a hardware abstraction layer that has nothing to do with the chip manufacturer. It can provide a simple processor software interface for interface peripherals and real-time operating systems, shielding hardware differences. Software migration is of great benefit

  • STM32F4xx_DSP_StdPeriph_Lib_V1.4.0 actual file analysis

    This time the firmware library version V1.4.0 is used. As follows:
    Firmware library directory
    As can be seen from the above figure, the important folders in the firmware library are Libraries and Project, and only these two folders are analyzed below.
    • Libraries

There are two files in the Libraries folder: CMSIS and STM32F4xx_StdPeriph_Driver, first look at the CMSIS:
Firmware library CMSIS
   Device folder: the file under this folder is directly related to the specific chip, including startup files, chip peripheral register definitions, and system clock initialization functions. File, which is provided by ST company.
CMSIS_Device

stm 32 f 4 xx .h and system stm 32 f 4 xx .c files stm32f4xx.h and system_stm32f4xx.c files s t m 3 2 f 4 x x . h and s y s t e msT m . 3 2 F . 4 X X . C paper member
  stm32f4xx.h this document is very important, is the bottom of a chip STM32 relevant documents; STM32 contains all of the peripheral register address and the structure type definitions, using the standard STM32 The library must include this header file.
  The system_stm32f4xx.c file contains functions for initializing the system clock and expanding external memory after the STM32 chip is powered on

   Include folder: Contains the Cortex-M core common header files located in the device function layer of the CMSIS standard core. Their function is to provide a chip peripheral designed by chip vendors that use Cortex-M core design SOC The interface to the kernel defines some kernel-related registers
CMSIS_Include

 core_cm4.h is a very important file for the M4 core, all CM4 chip libraries have this file; like the startup file, it is a low-level file, which is provided by ARM and complies with the CMSIS standard.

Look at the STM32F4xx_StdPeriph_Driver folder again:
STM32F4xx_StdPeriph_Driver
STM32F4xx_StdPeriph_Driver is a library function file written by ST for each STM32 peripheral. Each peripheral corresponds to a file with a .c and .h suffix.

  • Project

Firmware Library Project

stm 32 f 4 xxit.c and stm 32 f 4 xxconf.h files stm32f4xx_it.c and stm32f4xx_conf.h files stm32f4xxit . c and s t m 3 2 f 4 x xcO the n- f . H file pieces
  stm32f4xx_it.c: This document is designed to write interrupt service function before we modify this file already defines some system exceptions (special interrupt) interface, the other by our common interrupt service function Add it yourself. But how do we know how to write the interface of these interrupt service functions? Can it be customized? The answer is of course no, these can be found in the assembly startup file
  stm32f4xx_conf.h: this file is included in the stm32f4xx.h file. ST standard library supports all STM32F4 models of chips, but some models have more peripheral functions, so use this configuration file to increase or decrease ST library peripheral files according to the chip model

The above is the basic analysis of the STM32F4xx firmware library.

Guess you like

Origin blog.csdn.net/weixin_41629848/article/details/99692561