GPIO_InitStructure.GPIO_Mode=GPIO_Mode_IPU; //ÉÏÀÊäÈë
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_15;
GPIO_InitStructure.GPIO_Speed=GPIO_Speed_50MHz;
GPIO_Init(GPIOA, &GPIO_InitStructure);
GPIO_EX
tiLineConfig(GPIO_PortSourceGPIOA, GPIO_PinSource15);//Ñ¡ÔñGPIO¹Ü½ÅÓÃ×÷ÍⲿÖжÏÏß·
EXTI_InitStructure.EXTI_Line=EXTI_Line15;
EXTI_InitStructure.EXTI_Mode=EXTI_Mode_Interrupt;
EXTI_InitStructure.EXTI_Trigger=EXTI_Trigger_Falling;
EXTI_InitStructure.EXTI_LineCmd = ENABLE;
EXTI_Init(&EXTI_InitStructure);
/* ÉèÖÃNVIC²ÎÊý */
NVIC_PriorityGroupConfig(NVIC_PriorityGroup_1);
NVIC_InitStructure.NVIC_IRQChannel = EXTI15_10_IRQn; //´ò¿ªEXTI2µÄÈ«¾ÖÖжÏ
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0; //ÇÀÕ¼ÓÅÏȼ¶Îª0
NVIC_InitStructure.NVIC_IRQChannelSubPriority = 2; //ÏìÓ¦ÓÅÏȼ¶Îª0
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; //ʹÄÜ
NVIC_Init(&NVIC_InitStructure);
void EXTI15_10_IRQnHandler() //ÍⲿÖжÏ2ÖжϺ¯Êý
{
if(EXTI_GetITStatus(EXTI_Line15)==SET)
{
EXTI_ClearITPendingBit(EXTI_Line15);//Çå³ýEXTIÏß·¹ÒÆðλ
delay_ms(50);//Ïû¶¶´¦Àí
if(GPIO_ReadInputDataBit(GPIOA,GPIO_Pin_15)==Bit_RESET) //k_left°´¼ü°´ÏÂ
{
delay_ms(50);//Ïû¶¶´¦Àí
LED1_ON;
LED2_ON;
LED3_ON;
LED4_ON;
LED5_ON;
}
while(GPIO_ReadInputDataBit(GPIOA,GPIO_Pin_15)==0);
}
}
一周热门 更多>