求助,关于stm32按键的问题
按键的话用库函数还需要消抖么,消抖之后按键没反应啊
下面是消抖程序
if(GPIO_ReadInputDataBit(GPIOA,GPIO_Pin_7)==Bit_RESET)
{
delay_ms(10);
if(GPIO_ReadInputDataBit(GPIOA,GPIO_Pin_7)==Bit_RESET)
{
while(GPIO_ReadInputDataBit(GPIOA,GPIO_Pin_7)==Bit_RESET);
GPIO_ResetBits(GPIOB,GPIO_Pin_0);//ÁÁ
//t++;
}
}
另外,按键小灯取反也没办法实现。。
void key_scan()
{
int t=0;
if(GPIO_ReadInputDataBit(GPIOA,GPIO_Pin_7)==Bit_RESET)
{
delay_ms(10);
if(GPIO_ReadInputDataBit(GPIOA,GPIO_Pin_7)==Bit_RESET)
{
while(GPIO_ReadInputDataBit(GPIOA,GPIO_Pin_7)==Bit_RESET);
t++;
}
}
if(t%2==0)
{
GPIO_ResetBits(GPIOB,GPIO_Pin_0);//ÁÁ
}
else if(t%2==1)
{
GPIO_SetBits(GPIOB,GPIO_Pin_0);//Ãð
}
}