[求助] 本人初学STM32遇到一些问题,希望有人给予帮助

zzg2012OTM   2012-5-9 17:36 楼主

本人初学STM32,先用keil4编写程序,把库和代码都加入工程里了,主函数也有了,可一运行出现下列错误,我看不懂怎么改啊!!求哪位大侠给看下吧。

 

 

  1. compiling main.c...
    D:\Keil\ARM\INC\ST\STM32F10x\stm32f10x_type.h(25): error: #256: invalid redeclaration of type name "s32" (declared at line 312 of "D:\Keil\ARM\INC\ST\STM32F10x\stm32f10x.h")
    D:\Keil\ARM\INC\ST\STM32F10x\stm32f10x_type.h: typedef signed long s32;
    D:\Keil\ARM\INC\ST\STM32F10x\stm32f10x_type.h: ^
    D:\Keil\ARM\INC\ST\STM32F10x\stm32f10x_type.h(29): error: #256: invalid redeclaration of type name "sc32" (declared at line 316 of "D:\Keil\ARM\INC\ST\STM32F10x\stm32f10x.h")
    D:\Keil\ARM\INC\ST\STM32F10x\stm32f10x_type.h: typedef signed long const sc32; /* Read Only */
    D:\Keil\ARM\INC\ST\STM32F10x\stm32f10x_type.h: ^
    D:\Keil\ARM\INC\ST\STM32F10x\stm32f10x_type.h(33): error: #256: invalid redeclaration of type name "vs32" (declared at line 320 of "D:\Keil\ARM\INC\ST\STM32F10x\stm32f10x.h")
    D:\Keil\ARM\INC\ST\STM32F10x\stm32f10x_type.h: typedef volatile signed long vs32;
    D:\Keil\ARM\INC\ST\STM32F10x\stm32f10x_type.h: ^
    D:\Keil\ARM\INC\ST\STM32F10x\stm32f10x_type.h(37): error: #256: invalid redeclaration of type name "vsc32" (declared at line 324 of "D:\Keil\ARM\INC\ST\STM32F10x\stm32f10x.h")
    D:\Keil\ARM\INC\ST\STM32F10x\stm32f10x_type.h: typedef volatile signed long const vsc32; /* Read Only */
    D:\Keil\ARM\INC\ST\STM32F10x\stm32f10x_type.h: ^
    D:\Keil\ARM\INC\ST\STM32F10x\stm32f10x_type.h(41): error: #256: invalid redeclaration of type name "u32" (declared at line 328 of "D:\Keil\ARM\INC\ST\STM32F10x\stm32f10x.h")
    D:\Keil\ARM\INC\ST\STM32F10x\stm32f10x_type.h: typedef unsigned long u32;
    D:\Keil\ARM\INC\ST\STM32F10x\stm32f10x_type.h: ^
    D:\Keil\ARM\INC\ST\STM32F10x\stm32f10x_type.h(45): error: #256: invalid redeclaration of type name "uc32" (declared at line 332 of "D:\Keil\ARM\INC\ST\STM32F10x\stm32f10x.h")
    D:\Keil\ARM\INC\ST\STM32F10x\stm32f10x_type.h: typedef unsigned long const uc32; /* Read Only */
    D:\Keil\ARM\INC\ST\STM32F10x\stm32f10x_type.h: ^
    D:\Keil\ARM\INC\ST\STM32F10x\stm32f10x_type.h(49): error: #256: invalid redeclaration of type name "vu32" (declared at line 336 of "D:\Keil\ARM\INC\ST\STM32F10x\stm32f10x.h")
    D:\Keil\ARM\INC\ST\STM32F10x\stm32f10x_type.h: typedef volatile unsigned long vu32;
    D:\Keil\ARM\INC\ST\STM32F10x\stm32f10x_type.h: ^
    D:\Keil\ARM\INC\ST\STM32F10x\stm32f10x_type.h(53): error: #256: invalid redeclaration of type name "vuc32" (declared at line 340 of "D:\Keil\ARM\INC\ST\STM32F10x\stm32f10x.h")
    D:\Keil\ARM\INC\ST\STM32F10x\stm32f10x_type.h: typedef volatile unsigned long const vuc32; /* Read Only */
    D:\Keil\ARM\INC\ST\STM32F10x\stm32f10x_type.h: ^
    D:\Keil\ARM\INC\ST\STM32F10x\stm32f10x_type.h(57): error: #101: "FALSE" has already been declared in the current scope
    D:\Keil\ARM\INC\ST\STM32F10x\stm32f10x_type.h: typedef enum {FALSE = 0, TRUE = !FALSE} bool;
    D:\Keil\ARM\INC\ST\STM32F10x\stm32f10x_type.h: ^
    D:\Keil\ARM\INC\ST\STM32F10x\stm32f10x_type.h(57): error: #101: "TRUE" has already been declared in the current scope
    D:\Keil\ARM\INC\ST\STM32F10x\stm32f10x_type.h: typedef enum {FALSE = 0, TRUE = !FALSE} bool;
    D:\Keil\ARM\INC\ST\STM32F10x\stm32f10x_type.h: ^
    D:\Keil\ARM\INC\ST\STM32F10x\stm32f10x_type.h(57): error: #256: invalid redeclaration of type name "bool" (declared at line 345 of "D:\Keil\ARM\INC\ST\STM32F10x\stm32f10x.h")
    D:\Keil\ARM\INC\ST\STM32F10x\stm32f10x_type.h: typedef enum {FALSE = 0, TRUE = !FALSE} bool;
    D:\Keil\ARM\INC\ST\STM32F10x\stm32f10x_type.h: ^
    D:\Keil\ARM\INC\ST\STM32F10x\stm32f10x_type.h(59): error: #101: "RESET" has already been declared in the current scope
    D:\Keil\ARM\INC\ST\STM32F10x\stm32f10x_type.h: typedef enum {RESET = 0, SET = !RESET} FlagStatus, ITStatus;
    D:\Keil\ARM\INC\ST\STM32F10x\stm32f10x_type.h: ^
    D:\Keil\ARM\INC\ST\STM32F10x\stm32f10x_type.h(59): error: #101: "SET" has already been declared in the current scope
    D:\Keil\ARM\INC\ST\STM32F10x\stm32f10x_type.h: typedef enum {RESET = 0, SET = !RESET} FlagStatus, ITStatus;
    D:\Keil\ARM\INC\ST\STM32F10x\stm32f10x_type.h: ^
    D:\Keil\ARM\INC\ST\STM32F10x\stm32f10x_type.h(59): error: #256: invalid redeclaration of type name "FlagStatus" (declared at line 348 of "D:\Keil\ARM\INC\ST\STM32F10x\stm32f10x.h")
    D:\Keil\ARM\INC\ST\STM32F10x\stm32f10x_type.h: typedef enum {RESET = 0, SET = !RESET} FlagStatus, ITStatus;
    D:\Keil\ARM\INC\ST\STM32F10x\stm32f10x_type.h: ^
    D:\Keil\ARM\INC\ST\STM32F10x\stm32f10x_type.h(59): error: #256: invalid redeclaration of type name "ITStatus" (declared at line 348 of "D:\Keil\ARM\INC\ST\STM32F10x\stm32f10x.h")
    D:\Keil\ARM\INC\ST\STM32F10x\stm32f10x_type.h: typedef enum {RESET = 0, SET = !RESET} FlagStatus, ITStatus;
    D:\Keil\ARM\INC\ST\STM32F10x\stm32f10x_type.h: ^
    D:\Keil\ARM\INC\ST\STM32F10x\stm32f10x_type.h(61): error: #101: "DISABLE" has already been declared in the current scope
    D:\Keil\ARM\INC\ST\STM32F10x\stm32f10x_type.h: typedef enum {DISABLE = 0, ENABLE = !DISABLE} FunctionalState;
    D:\Keil\ARM\INC\ST\STM32F10x\stm32f10x_type.h: ^
    D:\Keil\ARM\INC\ST\STM32F10x\stm32f10x_type.h(61): error: #101: "ENABLE" has already been declared in the current scope
    D:\Keil\ARM\INC\ST\STM32F10x\stm32f10x_type.h: typedef enum {DISABLE = 0, ENABLE = !DISABLE} FunctionalState;
    D:\Keil\ARM\INC\ST\STM32F10x\stm32f10x_type.h: ^
    D:\Keil\ARM\INC\ST\STM32F10x\stm32f10x_type.h(61): error: #256: invalid redeclaration of type name "FunctionalState" (declared at line 350 of "D:\Keil\ARM\INC\ST\STM32F10x\stm32f10x.h")
    D:\Keil\ARM\INC\ST\STM32F10x\stm32f10x_type.h: typedef enum {DISABLE = 0, ENABLE = !DISABLE} FunctionalState;
    D:\Keil\ARM\INC\ST\STM32F10x\stm32f10x_type.h: ^
    D:\Keil\ARM\INC\ST\STM32F10x\stm32f10x_type.h(64): error: #101: "ERROR" has already been declared in the current scope
    D:\Keil\ARM\INC\ST\STM32F10x\stm32f10x_type.h: typedef enum {ERROR = 0, SUCCESS = !ERROR} ErrorStatus;
    D:\Keil\ARM\INC\ST\STM32F10x\stm32f10x_type.h: ^
    D:\Keil\ARM\INC\ST\STM32F10x\stm32f10x_type.h(64): error: #101: "SUCCESS" has already been declared in the current scope
    D:\Keil\ARM\INC\ST\STM32F10x\stm32f10x_type.h: typedef enum {ERROR = 0, SUCCESS = !ERROR} ErrorStatus;
    D:\Keil\ARM\INC\ST\STM32F10x\stm32f10x_type.h: ^
    D:\Keil\ARM\INC\ST\STM32F10x\stm32f10x_type.h(64): error: #256: invalid redeclaration of type name "ErrorStatus" (declared at line 353 of "D:\Keil\ARM\INC\ST\STM32F10x\stm32f10x.h")
    D:\Keil\ARM\INC\ST\STM32F10x\stm32f10x_type.h: typedef enum {ERROR = 0, SUCCESS = !ERROR} ErrorStatus;
    D:\Keil\ARM\INC\ST\STM32F10x\stm32f10x_type.h: ^
    D:\Keil\ARM\INC\ST\STM32F10x\stm32f10x_conf.h(147): warning: #47-D: incompatible redefinition of macro "HSE_Value" (declared at line 83 of "D:\Keil\ARM\INC\ST\STM32F10x\stm32f10x.h")
    D:\Keil\ARM\INC\ST\STM32F10x\stm32f10x_conf.h: #define HSE_Value ((u32)8000000) /* Value of the External oscillator in Hz*/
    D:\Keil\ARM\INC\ST\STM32F10x\stm32f10x_conf.h: ^
    main.c(15): error: #20: identifier "GPIO_InitTypeDef" is undefined
    main.c: GPIO_InitTypeDef GPIO_InitStructure;
    main.c: ^
    main.c(18): warning: #223-D: function "RCC_APB2PeriphClockCmd" declared implicitly
    main.c: RCC_APB2PeriphClockCmd(RCC_GPIO_LED | RCC_APB2Periph_AFIO , ENABLE); //RCC_APB2Periph_AFIO
    main.c: ^
    main.c(18): error: #20: identifier "RCC_APB2Periph_GPIOD" is undefined
    main.c: RCC_APB2PeriphClockCmd(RCC_GPIO_LED | RCC_APB2Periph_AFIO , ENABLE); //RCC_APB2Periph_AFIO
    main.c: ^
    main.c(18): error: #20: identifier "RCC_APB2Periph_AFIO" is undefined
    main.c: RCC_APB2PeriphClockCmd(RCC_GPIO_LED | RCC_APB2Periph_AFIO , ENABLE); //RCC_APB2Periph_AFIO
    main.c: ^
    main.c(21): error: #20: identifier "GPIO_Pin_2" is undefined
    main.c: GPIO_InitStructure.GPIO_Pin = GPIO_LED_ALL;
    main.c: ^
    main.c(21): error: #20: identifier "GPIO_Pin_3" is undefined
    main.c: GPIO_InitStructure.GPIO_Pin = GPIO_LED_ALL;
    main.c: ^
    main.c(21): error: #20: identifier "GPIO_Pin_4" is undefined
    main.c: GPIO_InitStructure.GPIO_Pin = GPIO_LED_ALL;
    main.c: ^
    main.c(21): error: #20: identifier "GPIO_Pin_7" is undefined
    main.c: GPIO_InitStructure.GPIO_Pin = GPIO_LED_ALL;
    main.c: ^
    main.c(22): error: #20: identifier "GPIO_Speed_50MHz" is undefined
    main.c: GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
    main.c: ^
    main.c(23): error: #20: identifier "GPIO_Mode_Out_PP" is undefined
    main.c: GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
    main.c: ^
    main.c: main.c: 2 warnings, 30 errors
    main.c - 30 Error(s), 2 Warning(s).

所建工程文件截图在附件里。

  • 错误3.jpg

回复评论 (2)

11

这都是很基本的错误,楼主你多百度百度,这些问题解决不了,以后没法深入。
点赞  2012-5-24 11:26
 在keil的option中的c/c++的Define中加入  USE_STDPERIPH_DRIVER, STM32F10X_MD  ,这样就可以了,试试
  • 小Q截图-20120524150650.png
点赞  2012-5-24 15:09
电子工程世界版权所有 京B2-20211791 京ICP备10001474号-1 京公网安备 11010802033920号
    写回复