zoukankan      html  css  js  c++  java
  • STM32外部中断.

    void EXTIX_Init(void)
    {
        EXTI_InitTypeDef EXTI_InitStructure;
        NVIC_InitTypeDef NVIC_InitStructure;
        RCC_APB2PeriphClockCmd(RCC_APB2Periph_AFIO,ENABLE);

        GPIO_EXTILineConfig(GPIO_PortSourceGPIOA,GPIO_PinSource1);   //A1
        EXTI_InitStructure.EXTI_Line=EXTI_Line1;   //这个Line跟GPIO引脚有关, 如果是引脚1, 就用Line1
        EXTI_InitStructure.EXTI_Trigger = EXTI_Trigger_Falling;     //下降沿触发, 因为红外的模块就是走的下降
        EXTI_Init(&EXTI_InitStructure);        
        
        NVIC_InitStructure.NVIC_IRQChannel = EXTI1_IRQn;            
        NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0x02;    
        NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0x03;                    
        NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;                                
        NVIC_Init(&NVIC_InitStructure);
    }

    void EXTI1_IRQHandler(void)
    {

        LED_ONOFF(ON);    
        delay_s(2);
        LED_ONOFF(OFF);
        EXTI_ClearITPendingBit(EXTI_Line1);
    }

    void GPIOA1_Init(void){

        GPIO_InitTypeDef GPIO_InitStructure;
        RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA,ENABLE);
        GPIO_InitStructure.GPIO_Pin  = GPIO_Pin_1;
        GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IPD;   //下拉输入
        GPIO_Init(GPIOA, &GPIO_InitStructure);
    }

  • 相关阅读:
    codeforces 269B Greenhouse Effect
    codeforces 5C Longest Regular Bracket Sequence
    codeforces 225C Barcode
    codeforces 279C Ladder
    CodeForces 479E Riding in a Lift
    CodeForces 351A Jeff and Rounding
    POJ-1579-201308122106.txt
    表达式求值-201308081712.txt
    Encoding-201308072147.txt
    A + B Problem II201308072001.txt
  • 原文地址:https://www.cnblogs.com/Montauk/p/5760165.html
Copyright © 2011-2022 走看看