金牌会员
 
- 积分
- 1214
- 金钱
- 1214
- 注册时间
- 2016-5-19
- 在线时间
- 297 小时
|
1金钱
想问下为什么我把第一行和第二行换了个位置就会出现很多报错?
int main(void)
{GPIO_InitTypeDef GPIO_InitStructure; 第一行
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOC|RCC_APB2Periph_GPIOA,ENABLE); 第二行
GPIO_InitStructure.GPIO_Pin=GPIO_Pin_13;
GPIO_InitStructure.GPIO_Mode=GPIO_Mode_IPU;
GPIO_InitStructure.GPIO_Speed=GPIO_Speed_10MHz;
GPIO_Init(GPIOC,&GPIO_InitStructure);
GPIO_InitStructure.GPIO_Pin=GPIO_Pin_7;
GPIO_InitStructure.GPIO_Mode=GPIO_Mode_Out_PP;
GPIO_InitStructure.GPIO_Speed=GPIO_Speed_10MHz;
GPIO_Init(GPIOA,&GPIO_InitStructure);
while(1)
{if (GPIO_ReadInputDataBit(GPIOC,GPIO_Pin_13)==0) GPIO_WriteBit(GPIOA,GPIO_Pin_7, (BitAction)( (1-GPIO_ReadOutputDataBit(GPIOA,GPIO_Pin_7)) ) ) ; }
}
|
最佳答案
查看完整内容[请看2#楼]
第一行是定义一个GPIO_InitTypeDef类型的结构体,结构体名为GPIO_InitStructure。意思就是变量定义必须放在语句之前。
|