GPIO_InitType GPIO_InitStructure;
NVIC_InitType NVIC_InitStructure;
RCC_EnableAPB2PeriphClk( RCC_APB2_PERIPH_GPIOA | RCC_APB2_PERIPH_GPIOB |RCC_APB2_PERIPH_GPIOC | RCC_APB2_PERIPH_GPIOD | RCC_APB2_PERIPH_GPIOE | RCC_APB2_PERIPH_AFIO, ENABLE);
//INT0、INT1
GPIO_InitStructure.Pin = INT0_PIN | INT1_PIN;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING;
GPIO_InitPeripheral(INT0_GPIO, &GPIO_InitStructure);
GPIO_ConfigEXTILine(GPIOD_PORT_SOURCE, GPIO_PIN_SOURCE13 | GPIO_PIN_SOURCE12 | GPIO_PIN_SOURCE11);//AFIO寄存器的 AFIO_EXTICRx 值,设为PD13/PD12/PD11
EXTI_InitType EXTI_InitStructure;
EXTI_InitStructure.EXTI_Line = EXTI_LINE13 | EXTI_LINE12;
EXTI_InitStructure.EXTI_Mode = EXTI_Mode_Interrupt;
EXTI_InitStructure.EXTI_Trigger = EXTI_Trigger_Rising;
EXTI_InitStructure.EXTI_LineCmd = ENABLE;
EXTI_InitPeripheral( &EXTI_InitStructure);
NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2);
NVIC_InitStructure.NVIC_IRQChannel = EXTI15_10_IRQn;
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 1;
NVIC_InitStructure.NVIC_IRQChannelSubPriority = 1;
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
NVIC_Init(&NVIC_InitStructure);
EXTI的配置
最新推荐文章于 2024-09-01 11:36:15 发布