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

2019-03-23 19:52发布

本人初学STM32,先用keil4编写程序,把库和代码都加入工程里了,主函数也有了,可一运行出现下列错误,我看不懂怎么改啊!!求哪位大侠给看下吧。    
  1. compiling main.c...
    D:KeilARMINCSTSTM32F10xstm32f10x_type.h(25): error: #256: invalid redeclaration of type name "s32" (declared at line 312 of "D:KeilARMINCSTSTM32F10xstm32f10x.h")
    D:KeilARMINCSTSTM32F10xstm32f10x_type.h: typedef signed long s32;
    D:KeilARMINCSTSTM32F10xstm32f10x_type.h: ^
    D:KeilARMINCSTSTM32F10xstm32f10x_type.h(29): error: #256: invalid redeclaration of type name "sc32" (declared at line 316 of "D:KeilARMINCSTSTM32F10xstm32f10x.h")
    D:KeilARMINCSTSTM32F10xstm32f10x_type.h: typedef signed long const sc32; /* Read Only */
    D:KeilARMINCSTSTM32F10xstm32f10x_type.h: ^
    D:KeilARMINCSTSTM32F10xstm32f10x_type.h(33): error: #256: invalid redeclaration of type name "vs32" (declared at line 320 of "D:KeilARMINCSTSTM32F10xstm32f10x.h")
    D:KeilARMINCSTSTM32F10xstm32f10x_type.h: typedef volatile signed long vs32;
    D:KeilARMINCSTSTM32F10xstm32f10x_type.h: ^
    D:KeilARMINCSTSTM32F10xstm32f10x_type.h(37): error: #256: invalid redeclaration of type name "vsc32" (declared at line 324 of "D:KeilARMINCSTSTM32F10xstm32f10x.h")
    D:KeilARMINCSTSTM32F10xstm32f10x_type.h: typedef volatile signed long const vsc32; /* Read Only */
    D:KeilARMINCSTSTM32F10xstm32f10x_type.h: ^
    D:KeilARMINCSTSTM32F10xstm32f10x_type.h(41): error: #256: invalid redeclaration of type name "u32" (declared at line 328 of "D:KeilARMINCSTSTM32F10xstm32f10x.h")
    D:KeilARMINCSTSTM32F10xstm32f10x_type.h: typedef unsigned long u32;
    D:KeilARMINCSTSTM32F10xstm32f10x_type.h: ^
    D:KeilARMINCSTSTM32F10xstm32f10x_type.h(45): error: #256: invalid redeclaration of type name "uc32" (declared at line 332 of "D:KeilARMINCSTSTM32F10xstm32f10x.h")
    D:KeilARMINCSTSTM32F10xstm32f10x_type.h: typedef unsigned long const uc32; /* Read Only */
    D:KeilARMINCSTSTM32F10xstm32f10x_type.h: ^
    D:KeilARMINCSTSTM32F10xstm32f10x_type.h(49): error: #256: invalid redeclaration of type name "vu32" (declared at line 336 of "D:KeilARMINCSTSTM32F10xstm32f10x.h")
    D:KeilARMINCSTSTM32F10xstm32f10x_type.h: typedef volatile unsigned long vu32;
    D:KeilARMINCSTSTM32F10xstm32f10x_type.h: ^
    D:KeilARMINCSTSTM32F10xstm32f10x_type.h(53): error: #256: invalid redeclaration of type name "vuc32" (declared at line 340 of "D:KeilARMINCSTSTM32F10xstm32f10x.h")
    D:KeilARMINCSTSTM32F10xstm32f10x_type.h: typedef volatile unsigned long const vuc32; /* Read Only */
    D:KeilARMINCSTSTM32F10xstm32f10x_type.h: ^
    D:KeilARMINCSTSTM32F10xstm32f10x_type.h(57): error: #101: "FALSE" has already been declared in the current scope
    D:KeilARMINCSTSTM32F10xstm32f10x_type.h: typedef enum {FALSE = 0, TRUE = !FALSE} bool;
    D:KeilARMINCSTSTM32F10xstm32f10x_type.h: ^
    D:KeilARMINCSTSTM32F10xstm32f10x_type.h(57): error: #101: "TRUE" has already been declared in the current scope
    D:KeilARMINCSTSTM32F10xstm32f10x_type.h: typedef enum {FALSE = 0, TRUE = !FALSE} bool;
    D:KeilARMINCSTSTM32F10xstm32f10x_type.h: ^
    D:KeilARMINCSTSTM32F10xstm32f10x_type.h(57): error: #256: invalid redeclaration of type name "bool" (declared at line 345 of "D:KeilARMINCSTSTM32F10xstm32f10x.h")
    D:KeilARMINCSTSTM32F10xstm32f10x_type.h: typedef enum {FALSE = 0, TRUE = !FALSE} bool;
    D:KeilARMINCSTSTM32F10xstm32f10x_type.h: ^
    D:KeilARMINCSTSTM32F10xstm32f10x_type.h(59): error: #101: "RESET" has already been declared in the current scope
    D:KeilARMINCSTSTM32F10xstm32f10x_type.h: typedef enum {RESET = 0, SET = !RESET} FlagStatus, ITStatus;
    D:KeilARMINCSTSTM32F10xstm32f10x_type.h: ^
    D:KeilARMINCSTSTM32F10xstm32f10x_type.h(59): error: #101: "SET" has already been declared in the current scope
    D:KeilARMINCSTSTM32F10xstm32f10x_type.h: typedef enum {RESET = 0, SET = !RESET} FlagStatus, ITStatus;
    D:KeilARMINCSTSTM32F10xstm32f10x_type.h: ^
    D:KeilARMINCSTSTM32F10xstm32f10x_type.h(59): error: #256: invalid redeclaration of type name "FlagStatus" (declared at line 348 of "D:KeilARMINCSTSTM32F10xstm32f10x.h")
    D:KeilARMINCSTSTM32F10xstm32f10x_type.h: typedef enum {RESET = 0, SET = !RESET} FlagStatus, ITStatus;
    D:KeilARMINCSTSTM32F10xstm32f10x_type.h: ^
    D:KeilARMINCSTSTM32F10xstm32f10x_type.h(59): error: #256: invalid redeclaration of type name "ITStatus" (declared at line 348 of "D:KeilARMINCSTSTM32F10xstm32f10x.h")
    D:KeilARMINCSTSTM32F10xstm32f10x_type.h: typedef enum {RESET = 0, SET = !RESET} FlagStatus, ITStatus;
    D:KeilARMINCSTSTM32F10xstm32f10x_type.h: ^
    D:KeilARMINCSTSTM32F10xstm32f10x_type.h(61): error: #101: "DISABLE" has already been declared in the current scope
    D:KeilARMINCSTSTM32F10xstm32f10x_type.h: typedef enum {DISABLE = 0, ENABLE = !DISABLE} FunctionalState;
    D:KeilARMINCSTSTM32F10xstm32f10x_type.h: ^
    D:KeilARMINCSTSTM32F10xstm32f10x_type.h(61): error: #101: "ENABLE" has already been declared in the current scope
    D:KeilARMINCSTSTM32F10xstm32f10x_type.h: typedef enum {DISABLE = 0, ENABLE = !DISABLE} FunctionalState;
    D:KeilARMINCSTSTM32F10xstm32f10x_type.h: ^
    D:KeilARMINCSTSTM32F10xstm32f10x_type.h(61): error: #256: invalid redeclaration of type name "FunctionalState" (declared at line 350 of "D:KeilARMINCSTSTM32F10xstm32f10x.h")
    D:KeilARMINCSTSTM32F10xstm32f10x_type.h: typedef enum {DISABLE = 0, ENABLE = !DISABLE} FunctionalState;
    D:KeilARMINCSTSTM32F10xstm32f10x_type.h: ^
    D:KeilARMINCSTSTM32F10xstm32f10x_type.h(64): error: #101: "ERROR" has already been declared in the current scope
    D:KeilARMINCSTSTM32F10xstm32f10x_type.h: typedef enum {ERROR = 0, SUCCESS = !ERROR} ErrorStatus;
    D:KeilARMINCSTSTM32F10xstm32f10x_type.h: ^
    D:KeilARMINCSTSTM32F10xstm32f10x_type.h(64): error: #101: "SUCCESS" has already been declared in the current scope
    D:KeilARMINCSTSTM32F10xstm32f10x_type.h: typedef enum {ERROR = 0, SUCCESS = !ERROR} ErrorStatus;
    D:KeilARMINCSTSTM32F10xstm32f10x_type.h: ^
    D:KeilARMINCSTSTM32F10xstm32f10x_type.h(64): error: #256: invalid redeclaration of type name "ErrorStatus" (declared at line 353 of "D:KeilARMINCSTSTM32F10xstm32f10x.h")
    D:KeilARMINCSTSTM32F10xstm32f10x_type.h: typedef enum {ERROR = 0, SUCCESS = !ERROR} ErrorStatus;
    D:KeilARMINCSTSTM32F10xstm32f10x_type.h: ^
    D:KeilARMINCSTSTM32F10xstm32f10x_conf.h(147): warning: #47-D: incompatible redefinition of macro "HSE_Value" (declared at line 83 of "D:KeilARMINCSTSTM32F10xstm32f10x.h")
    D:KeilARMINCSTSTM32F10xstm32f10x_conf.h: #define HSE_Value ((u32)8000000) /* Value of the External oscillator in Hz*/
    D:KeilARMINCSTSTM32F10xstm32f10x_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).
复制代码 所建工程文件截图在附件里。 此帖出自小平头技术问答
友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。
该问题目前已经被作者或者管理员关闭, 无法添加新回复
2条回答
hansmmm
1楼-- · 2019-03-24 06:01
 精彩回答 2  元偷偷看……
411353021
2楼-- · 2019-03-24 08:50
 在keil的option中的c/c++的Define中加入  USE_STDPERIPH_DRIVER, STM32F10X_MD  ,这样就可以了,试试

一周热门 更多>