STM32 introduced the new HAL Drive source code, this article gives the GPIO interrupt codes implementation steps:
Step 1) Similar to initializing the gpio required with gpio_initstruct struct initialization, note the mode parameter and Nvic interrupt enable:
Gpio_inittypedef gpio_initstruct;
/* Configure GPIO PINS:PB6 */
__gpiob_clk_enable ();
Gpio_initstruct.pin = gpio_pin_6;//
Gpio_initstruct.mode = gpio_mode_it_rising; Interrupt mode, rising
Gpio_initstruct.pull = Gpio_nopull;
Gpio_initstruct.speed = Gpio_speed_freq_very_high;
Hal_gpio_init (Gpiob, &gpio_initstruct);
Hal_nvic_setpriority (exti4_15_irqn,0,0);
HAL_NVIC_ENABLEIRQ (EXTI4_15_IRQN);
Step 2) Similar to the following, according to the exit line GPIO connected to implement interrupt processing function, remember to call the Hal_gpio_exti_irqhandler () function internally:
void Exti4_15_irqhandler (void)
{
Hal_gpio_exti_irqhandler (Gpio_pin_6);
}
Step 3) similar to the following implementation (replace) weak callback function Hal_gpio_exti_callback (), this function is called automatically by the STM code framework:
void Hal_gpio_exti_callback (uint16_t gpio_pin)
{
Internal implementation of their own processing logic.
}
Complete!
STM32 Single chip microcomputer IO interrupt implementation steps