stm32f030 IO Port External Interrupt Application

Source: Internet
Author: User

= = File exit.h============================================================ #ifndef __exit_h#define__exit_h#include "Stm32f0xx.h" extern void Exit_hall_init (void); #endif/* __exit_h *///== file exit.c==================================== ======================== #include "global.h" #include "exit.h"//======== Hall external interrupt initialization ===========================void Exit_hall_init (void) {gpio_inittypedef gpio_initstruct;//gpio definition exti_inittypedef exti_initstruct;//external interrupt definition NVIC_ Inittypedef nvic_initstruct; Nested interrupt Definitions/* Config the extiline (PB3 PB4 PB5) clock and AFIO clock */Rcc_apb2periphclockcmd (rcc_apb2periph_syscfg, ENA  BLE);      Rcc_ahbperiphclockcmd (Rcc_ahbperiph_gpiob, ENABLE); /* Configyre p[a| b| c| d| E]3 NIVC */nvic_initstruct.nvic_irqchannel = exti2_3_irqn; nvic_initstruct.nvic_irqchannelpriority = 0x00; Nvic_initstruct.nvic_irqchannelcmd = ENABLE;    Nvic_init (&nvic_initstruct); /* Configyre p[a| b| c| d| E]4 5 NIVC */nvic_initstruct.nvic_irqchannel = EXTI4_15_IRQN; Nvic_initstruct.nvic_irqchannelpriority = 0x00; Nvic_initstruct.nvic_irqchannelcmd = ENABLE;  Nvic_init (&nvic_initstruct); /* Exti Line gpio config (PB3 PB4 PB5) */gpio_initstruct.gpio_pin = gpio_pin_3| gpio_pin_4|   Gpio_pin_5; Gpio_initstruct.gpio_mode = gpio_mode_in;    Gpio_initstruct.gpio_speed = gpio_speed_level_2; GPIO_INITSTRUCT.GPIO_PUPD = gpio_pupd_nopull;//gpio_pupd_up; Pull-up input gpio_init (GPIOB, &gpio_initstruct);/* Exti line (PB3 PB4 PB5) mode config */exti_clearitpendingbit (exti_line3 ); Exti_clearitpendingbit (exti_line4); Exti_clearitpendingbit (Exti_line5); Syscfg_extilineconfig (Exti_portsourcegpiob, Exti_pinsource3); Syscfg_extilineconfig (Exti_portsourcegpiob, Exti_pinsource4); Syscfg_extilineconfig (Exti_portsourcegpiob, Exti_pinsource5); Exti_initstruct.exti_line = exti_line3| exti_line4| Exti_line5; Exti_initstruct.exti_mode = Exti_mode_interrupt; Exti_initstruct.exti_trigger = exti_trigger_rising_falling;//exti_trigger_falling;//on falling edge interrupt Exti_initstruct.exti_ Linecmd = ENABLE; Exti_init (&exti_initstruct); }

Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

stm32f030 IO Port External Interrupt Application

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.