新手上路
- 积分
- 34
- 金钱
- 34
- 注册时间
- 2018-6-28
- 在线时间
- 33 小时
|
1金钱
本帖最后由 xuande 于 2018-7-4 14:25 编辑
void LED_key()
{
if(!GPIO_ReadInputDataBit(GPIOA,GPIO_Pin_9)==1)
{
delay_us(1000);
{GPIO_ReadOutputDataBit(GPIOC,GPIO_Pin_13)==0?GPIO_SetBits(GPIOC,GPIO_Pin_13):GPIO_ResetBits(GPIOC,GPIO_Pin_13);}
delay_us(1000);
while(GPIO_ReadInputDataBit(GPIOA,GPIO_Pin_9));
}
if(!GPIO_ReadInputDataBit(GPIOC,GPIO_Pin_9)==1)
{
delay_us(1000);
{GPIO_ReadOutputDataBit(GPIOC,GPIO_Pin_14)==0?GPIO_SetBits(GPIOC,GPIO_Pin_14):GPIO_ResetBits(GPIOC,GPIO_Pin_14);}
delay_us(1000);
while(GPIO_ReadInputDataBit(GPIOC,GPIO_Pin_9));
}
if(!GPIO_ReadInputDataBit(GPIOC,GPIO_Pin_7)==1)
{ delay_us(1000);
{GPIO_ReadOutputDataBit(GPIOC,GPIO_Pin_15)==0?GPIO_SetBits(GPIOC,GPIO_Pin_15):GPIO_ResetBits(GPIOC,GPIO_Pin_15);}
delay_us(1000);
while(GPIO_ReadInputDataBit(GPIOC,GPIO_Pin_7));
}
}
这段函数进入函数后只会执行第一个if语句,后面的if语句不会执行,请大神帮忙看看
|
最佳答案
查看完整内容[请看2#楼]
if(!GPIO_ReadInputDataBit(GPIOA,GPIO_Pin_9)==1) 这里是低电平进入if
while(GPIO_ReadInputDataBit(GPIOA,GPIO_Pin_9)); 这里是等待高电平结束
真相只有一个,死在while循环了
|