首页 | 新闻 | 新品 | 文库 | 方案 | 视频 | 下载 | 商城 | 开发板 | 数据中心 | 座谈新版 | 培训 | 工具 | 博客 | 论坛 | 百科 | GEC | 活动 | 主题月 | 电子展
返回列表 回复 发帖

STM32F 使用最新的V3.3.0 固件库小弯路记录

STM32F 使用最新的V3.3.0 固件库小弯路记录

STM32F 使用最新的V3.3.0 固件库小弯路记录

一个小范例,之前使用V3.1.0都是编译正常,后来换了V3.3.0 编译提示错误:
..\src\main.c(7): error:  #20: identifier "GPIO_InitTypeDef" is undefined
..\src\main.c(10): error:  #20: identifier "GPIO_Pin_8" is undefined
..\src\main.c(10): error:  #20: identifier "GPIO_Pin_9" is undefined
......
-------开始分析查找错误的原因
一、先确认:Target Options --- C/C++ 里的Include Paths 要把新的固件库的包含路径都设置添加好,不然编
译器会跑去包含编译器路径下的旧固件库。这些没问题。
二、开始对比新旧固件库StdPeriph_Template下的stm32f10x_it.c是否有不同的地方,看了半天,找到如下问题:
新的固件库:
#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
上面的这段代码注释意思是:如果不使用外设驱动库,请把下面的这行注释掉。我们在这里肯定是用固件库了,所
以要把  /*#define USE_STDPERIPH_DRIVER  */ 的注释去掉。
#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
返回列表