STM32 Single chip microcomputer IO interrupt implementation steps

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.