本人新手 想自己写一下led.c 和 头文件 并在给定的工程中替换原子赠送的代码 但是提示..\HARDWARE\LED\led.c(9): error: #268: declaration may not appear after executable statement in block 这是led.c的代码
#include "led.h"
void LED_Init()
{
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOB|RCC_APB2Periph_GPIOE,ENABLE);
GPIO_InitTypeDef GPIO_InitStr;
GPIO_Init(GPIOB,&GPIO_InitStr);
GPIO_InitStr.GPIO_Speed=GPIO_Speed_50MHz;
GPIO_InitStr.GPIO_Mode=GPIO_Mode_Out_PP;
GPIO_InitStr.GPIO_Pin=GPIO_Pin_5;
GPIO_SetBits(GPIOB,GPIO_Pin_5);
GPIO_Init(GPIOE,&GPIO_InitStr);
GPIO_InitStr.GPIO_Pin=GPIO_Pin_5;
GPIO_SetBits(GPIOE,GPIO_Pin_5);
}
头文件比较简单 是没问题的
#ifndef _LED_H_
#define _LED_H_
#include "sys.h"
#define LED0 PBout(5)
#define LED1 PEout(5)
void LED_Init(void)
#endif
还有我本想自己建一个工程的 但是看了好几遍视频就是不行 总是提示main.c: Error: command-line: #992: invalid macro definition: STM32F10X_HD.USE_STDPERIPH_DRIVER 结果我重装了一边4.7 但是还是提示 所以我用了原子的工程 双击之后删除了HARDWARE 自己写了led.c和led.h 重新修改了路径但是会提示上边的在执行的部分未出现声明的变量 求解释~ 在线等!!!!!
|