stm32f10x_conf.h,用户需要配置的文件,其中包括inc主要的头文件,我们在编程中,根据需要把相关的头文件包含进来,如果不去掉,编译的时间会很长,即把所有的源代码都编译了一次。
通常我们在main.c中只要包括stm32f10x.h这就可以了,因为在其中有如下的语句:
#include "system_stm32f10x.h"
#include <stdint.h>
#ifdef USE_STDPERIPH_DRIVER
#include "stm32f10x_conf.h"
#endif
从上面这句可以看出,只有在#ifdef USE_STDPERIPH_DRIVER,其被定义的时候才会把stm32f10x_conf.h文件包含进来,因此我们在keil编译器中通常会在C/C++这个配置选项中定义,如下:
#include "stm32f10x_it.h"(与中断有关的处理)在句语句在stm32f10x.c文件中,而stm32f10x_it.h中又包括:
#include "stm32f10x.h"
#include "core_cm3.h"中有如下定义
#define __I volatile const /*!< defines 'read only' permissions */
#define __O volatile /*!< defines 'write only' permissions */
#define __IO volatile /*!< defines 'read / write' permissions */
相关的源代码:
stm32f10x_rcc.c用于配置系统时钟,是每个外设都需要用到的库文件,而stm32f10x_gpio.c用于操作I/O
在STM32中每个外设都有自己独立的时钟,要想外设工作除了要使能系统时钟(SystemInit(),这个函数在system_stm32f10x.c中)之外,还要使能响应的IO时钟,假如用到了I/O的第二功能的话还要使能第二功能的时钟(stm32f10x_rcc.c来配置);STM32所有的IO口都是高速的I/O口。
typedef struct
{
uint16_t GPIO_Pin;
GPIOSpeed_TypeDef GPIO_Speed;
GPIOMode_TypeDef GPIO_Mode;
}GPIO_InitTypeDef;