固件库从3.1升级到3.5版本。
小经验:
1.老版本的库函数的寄存器定义在stm32f10x_map.h,现在版本的库函数(3.1以后)的所有寄存器的定义都在stm32f10x.h里面。 |
所以只要是引用stm32f10x_map.h的地方,都要改成stm32f10x.h。
stm32f10x_map.h阅读记录,详见博客《stm32f10x_map.h(3.0以后不再使用)阅读记录》。
stm32f10x.h阅读记录,详见博客《stm32f10x.h阅读记录》。
2.最新版的用户手册:其实就是固件库里叫做stm32f10x_stdperiph_lib_um 的CHM文件。
3.原版的固件库是3.1,要升级到3.5。但是改完后,报错,一查才知道stm32f10x_gpio.h 版本竟然是2.0.1,说明改得不彻底,头文件看来没改,结果是keil找不到对应的头文件,调用安装时的目录文件。
遇到的问题:
1.stm32固件库从2.0升级到3.5。
自己新建了一个工程,把3.5里面需要的库文件拷贝到工程目录下,编译出问题:
C:\Keil\ARM\INC\ST\STM32F10x\stm32f10x_type.h(23): error: #256: invalid redeclaration of type name "s32" (declared at line 487 of "..\CMSIS\stm32f10x.h") C:\Keil\ARM\INC\ST\STM32F10x\stm32f10x_type.h(27): error: #256: invalid redeclaration of type name "sc32" (declared at line 491 of "..\CMSIS\stm32f10x.h") ...
现象:
报错地址中出现keil安装目录下的头文件。
原因:
2.原版3.1,打算升级到3.5,GPIO报错:
现象: ..\Source\CPU\IO\io.h(198): error: #20: identifier "GPIOMode_TypeDef" is undefined
原因:io.h是用户的文件,原先只做了#include <stm32f10x.h>,但是GPIOMode_TypeDef是定义在 #include "stm32f10x_gpio.h" 中的。(按理说stm32f10x_conf.h中已经开启 #include "stm32f10x_gpio.h",就不用再单独#include "stm32f10x_gpio.h"了。但还是这样。不解啊..)
解决办法:io.h中再#include "stm32f10x_gpio.h" 就好了。
3.
报错:..\Source\CPU\cpu.h(139): error: #20: identifier "bool" is undefined //bool未定义
原因:3.5已经去掉了bool的定义,为了与c标准兼容,把定义放到了stdbool.h里面,这个文件在C:\My Program\Keil\ARM\RV31\INC路径里面。
这是stdbool.h中对bool的定义 :
/* stdbool.h: ISO/IEC 9899:1999 (C99), section 7.16 */ /* Copyright (C) ARM Ltd., 2002 * All rights reserved * RCS $Revision: 102466 $ * Checkin $Date: 2006-08-23 11:37:17 +0100 (Wed, 23 Aug 2006) $ * Revising $Author: drodgman $ */ #ifndef __bool_true_false_are_defined #define __bool_true_false_are_defined 1 #ifndef __cplusplus /* In C++, 'bool', 'true' and 'false' are keywords */ #define bool _Bool #define true 1 #define false 0 #endif #endif /* __bool_true_false_are_defined */
解决办法:把原来在stm32fxxx_type.h中对bool的定义(不是上面那个)手动加在stm32f10x.h中。
*********************************************************************************************************************************************************************
其他
*********************************************************************************************************************************************************************
网上找的升级中可能遇到的问题:
问题1:
问题2:
http://bbs.21ic.com/icview-392121-1-1.html