STM32L1标准固件库使用

如何使用STM32L1XX 标准固件库

1. 创建工程并设置所选型号的启动文件

选择相对应MCU型号的启动文件:
* startup_stm32l1xx_md.s: 适用于STM32L Ultra Low Power Medium density devices
* startup_stm32l1xx_mdp.s:适用于STM32L Ultra Low Power Medium density Plus devices
* startup_stm32l1xx_hd.s: 适用于STM32L Ultra Low Power High density devices
* startup_stm32l1xx_xl.s: 适用于STM32L Ultra Low Power XL density devices
上面四种类型所对应的MCU型号分别是:
* Ultra Low Power Medium-density devices: - STM32L151x6xx, STM32L151x8xx, STM32L151xBxx, STM32L152x6xx, STM32L152x8xx, STM32L152xBxx, STM32L151x6xxA, STM32L151x8xxA, STM32L151xBxxA, STM32L152x6xxA, STM32L152x8xxA and STM32L152xBxxA, STM32L100x6xx, STM32L100x8xx and STM32L100xBxx
* Ultra Low Power Medium-density Plus devices: - STM32L151xCxx, STM32L152xCxx and STM32L162xCxx, STM32L100xCxx
* Ultra Low Power High-density devices: STM32L151xDxx, STM32L152xDxx and STM32L162xDxx
* Ultra Low Power XL-density devices: STM32L151xExx, STM32L152xExx and STM32L162xExx

2. 根据所选的MCU型号配置固件库

在 stm32l1xx.h (under Libraries\CMSIS\Device\ST\STM32L1xx\Include)中配置所选的MCU类型,以及使用的外设头文件。

#if !defined (STM32L1XX_MD) && !defined (STM32L1XX_MDP) && !defined (STM32L1XX_HD) && !defined (STM32L1XX_XL)
    /* #define STM32L1XX_MD  */   /*!< - Ultra Low Power Medium-densitydevices: STM32L151x6xx, STM32L151x8xx,                                                      STM32L151xBxx, STM32L152x6xx, STM32L152x8xx and STM32L152xBxx.                                                  - Ultra Low Power Medium-density Value Line devices: STM32L100x6xx,STM32L100x8xx and STM32L100xBxx.*/
    /* #define STM32L1XX_MDP */   /*!< - Ultra Low Power Medium-density Plus devices: STM32L151xCxx, STM32L152xCxx and STM32L162xCxx
    - Ultra Low Power Medium-density Plus Value Line devices: STM32L100xCxx  */
/* #define STM32L1XX_HD */   /*!< Ultra Low Power High-density devices: STM32L151xDxx, STM32L152xDxx and STM32L162xDxx */
/* #define STM32L1XX_XL */     /*!< Ultra Low Power XL-density devices: STM32L151xExx, STM32L152xExx and STM32L162xExx */
#endif

到这里,对固件库的配置就算完成了,剩下的就是将这些文件包含进编译器中,并对编译器进行相应的配置。

你可能感兴趣的:(STM32/STM32L1)