在keil中需添加这两个宏
一、宏USE_STDPERIPH_DRIVER
1.这个宏控制了是否在应用中启动外设驱动。
2.在函数Stm32f10x.h中(在keil中设置后无需在此处开启)
#if !defined USE_STDPERIPH_DRIVER
/**
* @brief Comment the line below if you will not use the peripherals drivers.
In this case, these drivers will not be included and the application code will
be based on direct access to peripherals registers
*/
/*#define USE_STDPERIPH_DRIVER*/
#endif
#ifdef USE_STDPERIPH_DRIVER
#include "stm32f10x_conf.h"
#endif
==》决定了是否用stm32f10x_conf.h,此头文件中包含了各种外设的头文件,以及用于调试的assert_param函数和assert_failed函数(assert_failed 自定义--发生错误时执行的操作,用于调试,但此会影响stm32运行,调试结束后,不可在用)
二、宏STM32F10X_HD
在stm32f10x.h中
#if !defined (STM32F10X_LD) && !defined (STM32F10X_LD_VL) && !defined (STM32F10X_MD) && !defined (STM32F10X_MD_VL) && !defined (STM32F10X_HD) && !defined (STM32F10X_HD_VL) && !defined (STM32F10X_XL) && !defined (STM32F10X_CL)
/* #define STM32F10X_LD */ /*!< STM32F10X_LD: STM32 Low density devices */
/* #define STM32F10X_LD_VL */ /*!< STM32F10X_LD_VL: STM32 Low density Value Line devices */
/* #define STM32F10X_MD */ /*!< STM32F10X_MD: STM32 Medium density devices */
/* #define STM32F10X_MD_VL */ /*!< STM32F10X_MD_VL: STM32 Medium density Value Line devices */
/* #define STM32F10X_HD */ /*!< STM32F10X_HD: STM32 High density devices */
/* #define STM32F10X_HD_VL */ /*!< STM32F10X_HD_VL: STM32 High density value line devices */
/* #define STM32F10X_XL */ /*!< STM32F10X_XL: STM32 XL-density devices */
/* #define STM32F10X_CL */ /*!< STM32F10X_CL: STM32 Connectivity line devices */
#endif
这个宏根据具体的芯片来选择,与启动文件有关