打印

外部中断选择重复问题

[复制链接]
190|0
手机看帖
扫描二维码
随时随地手机跟帖
跳转到指定楼层
楼主
石头张|  楼主 | 2019-11-20 18:44 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
我现在做一个东西有用到10个按键,前期在画图时没有考虑到,导致现在按键对应GPIO口在中断时有重复,key1-PB12、key2-PB13、key3-PB14、key4-PD9、key5-PD10、key6-PD11、key7-PD12、key8-PD15、key9-PC6、key10-PA8、key1和key7下面配置中断还对?

void EXTI_KEY1_Config(void)
{
        GPIO_InitTypeDef GPIO_InitStructure;
        EXTI_InitTypeDef EXTI_InitStructure;

        /* config the extiline(PC13) clock and AFIO clock */
        //RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOC | RCC_APB2Periph_AFIO,ENABLE);
                                                                                                
        /* config the NVIC(PB12) */
        NVIC_Configuration();

        /* EXTI line gpio config(PB12) */        
        GPIO_InitStructure.GPIO_Pin = PIN_KEY10 ;                       /********KEY1********/
      GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING;
      GPIO_Init(PORT_KEY10, &GPIO_InitStructure);

        /* EXTI line(PB12) mode config */
  GPIO_EXTILineConfig(GPIO_PortSourceGPIOB, GPIO_PinSource12);
  EXTI_InitStructure.EXTI_Line = EXTI_Line12;
  EXTI_InitStructure.EXTI_Mode = EXTI_Mode_Interrupt;
  EXTI_InitStructure.EXTI_Trigger = EXTI_Trigger_Falling;
  EXTI_InitStructure.EXTI_LineCmd = ENABLE;
  EXTI_Init(&EXTI_InitStructure);
}

void EXTI_KEY7_Config(void)
{
        GPIO_InitTypeDef GPIO_InitStructure;
        EXTI_InitTypeDef EXTI_InitStructure;
                NVIC_Configuration();
                        /* EXTI line gpio config(PD12) */        
        GPIO_InitStructure.GPIO_Pin = PIN_KEY4 ;      
  GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING;
  GPIO_Init(PORT_KEY4, &GPIO_InitStructure);

        /* EXTI line(PD12) mode config */
  GPIO_EXTILineConfig(GPIO_PortSourceGPIOD, GPIO_PinSource12);
  EXTI_InitStructure.EXTI_Line = EXTI_Line12;
  EXTI_InitStructure.EXTI_Mode = EXTI_Mode_Interrupt;
  EXTI_InitStructure.EXTI_Trigger = EXTI_Trigger_Falling; //
  EXTI_InitStructure.EXTI_LineCmd = ENABLE;
  EXTI_Init(&EXTI_InitStructure);
}

在终端服务子程序中怎么判断?这时怎么判断是哪个按键在作用?
void EXTI15_10_IRQHandler(void)
{
        if(EXTI_GetITStatus(EXTI_Line12) != RESET) //
        {               
                LED1_TOGGLE;
                EXTI_ClearITPendingBit(EXTI_Line12);     //
        }

}

使用特权

评论回复

相关帖子

发新帖 我要提问
您需要登录后才可以回帖 登录 | 注册

本版积分规则

446

主题

446

帖子

0

粉丝