标签:
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);
}
标签:
原文地址:http://www.cnblogs.com/Montauk/p/5760165.html