同时配置了四个外部中断用于唤醒,其中一个中断唤醒后,就把其他中断也给唤醒了,比如说用EXTI_Line4唤醒,却同时触发唤醒EXTI_Line0 EXTI_Line1 void RCC_Config(void) { RCC_APB2PeriphClockCmd(RCC_APB2Periph_SYSCFG, ENABLE); SYSCFG_EXTILineConfig(EXTI_PortSourceGPIOB , EXTI_PinSource4); SYSCFG_EXTILineConfig(EXTI_PortSourceGPIOB ,EXTI_PinSource3); SYSCFG_EXTILineConfig(EXTI_PortSourceGPIOB ,EXTI_PinSource1); SYSCFG_EXTILineConfig(EXTI_PortSourceGPIOB ,EXTI_PinSource0); } void EXTI_Config(void) { NVIC_InitTypeDef NVIC_InitStructure; EXTI_InitTypeDef EXTI_InitStructure; //KEY 4 NVIC_InitStructure.NVIC_IRQChannel = EXTI4_IRQn; NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 3; NVIC_InitStructure.NVIC_IRQChannelSubPriority = 3; NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; NVIC_Init(&NVIC_InitStructure); EXTI_InitStructure.EXTI_Line = EXTI_Line4; EXTI_InitStructure.EXTI_Mode = EXTI_Mode_Interrupt; EXTI_InitStructure.EXTI_Trigger = EXTI_Trigger_Falling; EXTI_InitStructure.EXTI_LineCmd = ENABLE; EXTI_Init(&EXTI_InitStructure); //KEY 3 NVIC_InitStructure.NVIC_IRQChannel = EXTI3_IRQn; NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 3; NVIC_InitStructure.NVIC_IRQChannelSubPriority = 3; NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; NVIC_Init(&NVIC_InitStructure); EXTI_InitStructure.EXTI_Line = EXTI_Line3; EXTI_InitStructure.EXTI_Mode = EXTI_Mode_Interrupt; EXTI_InitStructure.EXTI_Trigger = EXTI_Trigger_Falling; EXTI_InitStructure.EXTI_LineCmd = ENABLE; EXTI_Init(&EXTI_InitStructure); //KEY 2 NVIC_InitStructure.NVIC_IRQChannel = EXTI1_IRQn; NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 3; NVIC_InitStructure.NVIC_IRQChannelSubPriority = 3; NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; NVIC_Init(&NVIC_InitStructure); EXTI_InitStructure.EXTI_Line = EXTI_Line1; EXTI_InitStructure.EXTI_Mode = EXTI_Mode_Interrupt; EXTI_InitStructure.EXTI_Trigger = EXTI_Trigger_Falling; EXTI_InitStructure.EXTI_LineCmd = ENABLE; EXTI_Init(&EXTI_InitStructure); //KEY 1 NVIC_InitStructure.NVIC_IRQChannel = EXTI0_IRQn; NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 3; NVIC_InitStructure.NVIC_IRQChannelSubPriority = 3; NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; NVIC_Init(&NVIC_InitStructure); EXTI_InitStructure.EXTI_Line = EXTI_Line0; EXTI_InitStructure.EXTI_Mode = EXTI_Mode_Interrupt; EXTI_InitStructure.EXTI_Trigger = EXTI_Trigger_Falling; EXTI_InitStructure.EXTI_LineCmd = ENABLE; EXTI_Init(&EXTI_InitStructure); } void Cma_exti_config(void) { printf("\r\nCma_exti_config\r\n"); GpioInit(&cam_key1,PTC_KEY1,PIN_INPUT,PIN_PUSH_PULL,PIN_PULL_UP,0); GpioInit(&cam_key2,PTC_KEY2,PIN_INPUT,PIN_PUSH_PULL,PIN_PULL_UP,0); GpioInit(&cam_key3,PTC_KEY3,PIN_INPUT,PIN_PUSH_PULL,PIN_PULL_UP,0); GpioInit(&cam_key4,PTC_KEY4,PIN_INPUT,PIN_PUSH_PULL,PIN_PULL_UP,0); RCC_Config(); EXTI_Config(); } |
void EXTI4_IRQHandler( void )
{
if( EXTI_GetITStatus( EXTI_Line4 ) != RESET )
{
EXTI_ClearITPendingBit( EXTI_Line4 );
SystemInit();
printf("\r\nEXTI4_IRQHandler\r\n");
printf("\r\nEXTI_GetFlagStatus(EXTI_Line0)=%d\r\n",EXTI_GetFlagStatus(EXTI_Line0));
key_flag = true;
}
}
评分
查看全部评分