#include "ExtiConfig.h" unsigned char key1down = 0;unsigned char Key2down = 0;/***************************************** /void exti_config (void) {Exti_inittypedef extistruct; Nvic_inittypedef nvicstruct; Gpio_inittypedef gpioinit;//nvic_setvectortable (Nvic_vecttab_flash, 0x00); Nvic_prioritygroupconfig (nvic_prioritygroup_2);//First 4 from 4 rcc_apb2periphclockcmd (RCC_APB2PERIPH_GPIOC | Rcc_apb2periph_gpiod | Rcc_apb2periph_afio, ENABLE);//gpioa configuration Gpioinit.gpio_mode = gpio_mode_ipu;//pa0 pull-up input gpioinit.gpio_pin = GPIO_Pin_3;// Lfgpioinit.gpio_speed = Gpio_speed_50mhz; Gpio_init (Gpiod, &gpioinit); Gpioinit.gpio_mode = GPIO_MODE_IPU;//PB5 Pull-up input gpioinit.gpio_pin = gpio_pin_13; Gpioinit.gpio_speed = Gpio_speed_50mhz; Gpio_init (GPIOC, &gpioinit); Gpio_extilineconfig (Gpio_portsourcegpiod, Gpio_pinsource3); Gpio_extilineconfig (GPIO_PORTSOURCEGPIOC, gpio_pinsource13); extistruct.exti_line = EXTI_Line3 | Exti_line13;eXtistruct.exti_mode = Exti_mode_interrupt;extistruct.exti_trigger = Exti_trigger_falling;extistruct.exti_linecmd = ENABLE; Exti_init (&extistruct); Exti_clearitpendingbit (EXTI_LINE3); Exti_clearitpendingbit (EXTI_LINE13); External interrupt line 0, interrupt multiplexing pa0nvicstruct.nvic_irqchannel = exti3_irqn;nvicstruct.nvic_irqchannelpreemptionpriority = 1; nvicstruct.nvic_irqchannelsubpriority = 1;nvicstruct.nvic_irqchannelcmd = ENABLE; Nvic_init (&nvicstruct); Nvicstruct.nvic_irqchannel = Exti15_10_irqn;nvicstruct.nvic_irqchannelpreemptionpriority = 1;nvicStruct.NVIC_ irqchannelsubpriority = 0;nvicstruct.nvic_irqchannelcmd = ENABLE; Nvic_init (&nvicstruct); }/**************************************************************** external interrupt function, with 13******************************* in break /void Exti_line13irq (void) {if (Exti_getitstatus (EXTI_LINE13)!=reset) {if (k ey1down==0) {key1down = 1; } exti_clearitpendingbit (EXTI_LINE13); Clear the interrupt flag on line}}/**************************************************************** external interrupt function, with 13******************************* in break /void Exti_line3irq (void) {if (Exti_getitstatus (exti_line3)!=reset) {if (key 2down==0) {key2down = 1; } exti_clearitpendingbit (Exti_line3); Clear the interrupt flag bit on line}}
Some global interrupt flags Key1down and Key2down are designed to provide some logic for the program in other parts of the project.
STM32 External Interrupt Programming