我一个端口上挂了4个按键,编码器3个接线(A B Z)
我这样写中断,有问题吗?(外部按键,编码器,都是下降沿有效。设置cpu的中断为上下都产生中断)
INTERRUPT_HANDLER(EXTI_PORTB_IRQHandler, 4)
{
pb_cu_data=GPIO_ReadInputData(GPIOB);
//异或判读数据跳变
exit_data=pb_la_data^pb_cu_data;
if(exit_data)
{
//如果是高电平,非0,那就跳过判断
if(pb_cu_data&exit_data)
goto bb1;
switch(exit_data)
{
case 0x10:
uart_putchar ('0');
en_count=0;
break;
case 0x20:
// uart_putchar ('1');
uart_putchar((u8)(en_count));
break;
case 0x40:
uart_putchar ('2');
break;
case 0x80:
uart_putchar ('3');
break;
case 0x2:
uart_putchar ('b');
en_count++;
break;
case 0x4:
uart_putchar ('z');
break;
case 0x6:
uart_putchar ('Z');
break;
}
}
bb1:
pb_la_data=pb_cu_data;
} |