Before giving the full program, it is for the convenience of beginners. After putting all the functions used by the main function into the main function, add the function declaration before the main function. This will make the main.c file have no hierarchy. All functions dilute the function code in main.c.
The file organization in a general project is like this: the main.c file only contains code that reflects the functionality.
The main.c header file contains only two
#include "stm32f0xx.h"#include "hw_config.h"
The following are user-defined macros. These macros are also closely related to the function. To put it bluntly, it is used by the main function. If it is not directly related to the function, it can be defined in hw_config.h, such as the definition of GPIO pins.
#define OE GPIO_Pin_5
The following is the definition of the global variable, which is also defined here in the main function.
The following is the main function, its structure is
void main(void){ //defining the local variables used by the main function //Initialize global variables and local variables //initialization hardware, such as RCC, NVIC, GPIO, TIM, USART, Systick, IWWDG, etc. //The following is the implementation of the function code, usually while (1) structure. while (1) { }}
The main.c file contains these codes. The functions called by the main function, such as RCC_Configuration, NVIC_Configuration, GPIO_Configuration, SysTick_Configuration, USART1_Configuration, etc., are declared in hw_config.h, in hw_config Defined in .c.
Note: Because all functions called by the main function are defined in hw_config.c, some variables are bound to be defined in hw_config.c, and these variables are also used in the main.c file. These variables need to be extern declared in hw_config.h. So even if stm32f0xx_it.c uses these variables defined in hw_config.c, you only need to include the hw_config.h header file.
Take a count variable usart1_invalidframe_time as an example, defined in hw_config.c, declared with extern in hw_config.h, cleared in main.c (usart1 receives data to clear the variable), in stm32f0xx_it The .s SysTick_Handler function is added every 1 ms.
Under the Linux partition is more troublesome, the more convenient tool is called fdiskWe can use t
In terms of file system, Linux® can be regarded as the Swiss Army Knife in the operating syste
According to foreign media reports, many users, like the author, have been intere
The original use of Tomcat in Linux does not use the newly created user created by the non-ROOT perm
How to set IP and MAC binding on Linux routing
Software-only dual-system hot standby solution in-depth analysis
UDP and socket functions (binding ports)
How to view Linux distribution
LVM configuration under SUSE server
Linux sed command learning experience
Common shortcuts under the Linux command line
Linux File System Knowledge Daquan
How to do disk space shortage, linux disk cleaning method
Nginx replace text module Substitution
CentOS 6.2 source code compilation and installation Nginx+MySQL+PHP+WordPress installation Word
How can I know the version number of Windows 95/98
Windows 7 method of creating a virtual disk partition
Modify the registry - easily remove the Vista/7 right briefcase menu
Create a desktop shortcut that always loses automatically deleted
What should I do if the notebook keyboard fails after installing Win10?
Win7 can not install the sound card driver prompt No Appropriate Driver to be how to solve?