#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
/* Tip: To avoid modifying this file each time you need to switch between these
devices, you can define the device in your toolchain compiler preprocessor.
- Low-density devices are STM32F101xx, STM32F102xx and STM32F103xx microcontrollers
where the Flash memory density ranges between 16 and 32 Kbytes.
- Low-density value line devices are STM32F100xx microcontrollers where the Flash
memory density ranges between 16 and 32 Kbytes.
- Medium-density devices are STM32F101xx, STM32F102xx and STM32F103xx microcontrollers
where the Flash memory density ranges between 64 and 128 Kbytes.
- Medium-density value line devices are STM32F100xx microcontrollers where the
Flash memory density ranges between 64 and 128 Kbytes.
- High-density devices are STM32F101xx and STM32F103xx microcontrollers where
the Flash memory density ranges between 256 and 512 Kbytes.
- High-density value line devices are STM32F100xx microcontrollers where the
Flash memory density ranges between 256 and 512 Kbytes.
- XL-density devices are STM32F101xx and STM32F103xx microcontrollers where
the Flash memory density ranges between 512 and 1024 Kbytes.
- Connectivity line devices are STM32F105xx and STM32F107xx microcontrollers.
*/
“stm32f10x.h”是整個標(biāo)準(zhǔn)外設(shè)庫的入口文件,這個文件包含了STM32F10x全系列所有外設(shè)寄存器的定義(寄存器的基地址和布局)、位定義、中斷向量表、存儲空間的地址映射等。為了是這個文件適用于不同系列的產(chǎn)品,程序中是通過宏定義來實現(xiàn)不同產(chǎn)品的匹配的,上面這段程序的注釋中已經(jīng)詳細(xì)給出了每個啟動文件所對應(yīng)的產(chǎn)品系列,與之對應(yīng),也要相應(yīng)的修改這個入口文件,需要根據(jù)所使用的產(chǎn)品系列正確的注釋/去掉相應(yīng)的注釋define。在這段程序的下方同樣有這樣的一個注釋程序/*#define USE_STDPERIPH_DRIVER*/ 用于選擇是否使用標(biāo)準(zhǔn)外設(shè)庫,如果保留這個注釋,則用戶開發(fā)程序可以基于直接訪問“stm32f10x.h”中定義的外設(shè)寄存器,所有的操作均基于寄存器完成,目前不使用固件庫的單片機(jī)開發(fā),如51、AVR、MSP430等其實都是采用此種方式,通過在對應(yīng)型號的頭文件中進(jìn)行外設(shè)寄存器等方面的定義,從而在程序中對相應(yīng)的寄存器操作完成相應(yīng)的功能設(shè)計。
如果去掉/*#define USE_STDPERIPH_DRIVER*/的注釋,則是使用標(biāo)準(zhǔn)外設(shè)庫進(jìn)行開發(fā),用戶需要使用在文件“stm32f10x_conf.h”中,選擇要用的外設(shè),外設(shè)同樣是通過注釋/去掉注釋的方式來選擇。示例程序如下:
/* Uncomment the line below to enable peripheral header file inclusion */
#include "stm32f10x_adc.h"
/* #include "stm32f10x_bkp.h" */
/* #include "stm32f10x_can.h" */
/* #include "stm32f10x_cec.h" */
/* #include "stm32f10x_crc.h" */
/* #include "stm32f10x_dac.h" */
/* #include "stm32f10x_dbgmcu.h" */
#include "stm32f10x_dma.h"
/* #include "stm32f10x_exti.h" */
/* #include "stm32f10x_flash.h" */
/* #include "stm32f10x_fsmc.h" */
#include "stm32f10x_gpio.h"
/* #include "stm32f10x_i2c.h" */
/* #include "stm32f10x_iwdg.h" */
/* #include "stm32f10x_pwr.h" */
#include "stm32f10x_rcc.h"
/* #include "stm32f10x_rtc.h" */
/* #include "stm32f10x_sdio.h" */
/* #include "stm32f10x_spi.h" */
/* #include "stm32f10x_tim.h" */
/* #include "stm32f10x_usart.h" */
/* #include "stm32f10x_wwdg.h" */
#include "misc.h" /* High level functions for NVIC and SysTick (add-on to CMSIS functions) */
電子發(fā)燒友App















評論