#include "exti.h"
#include "led.h"
#include "key.h"
#include "delay.h"
#include "usart.h"
#include "stm32f10x.h"
//////////////////////////////////////////////////////////////////////////////////
//±¾3ìDòÖ»1©Ñ§Ï°ê1óã¬Î′¾-×÷ÕßDí¿é£¬2»μÃóÃóúÆäËüèÎoÎóÃí¾
//ALIENTEK¾«ó¢STM32¿a·¢°å
//ía2¿ÖD¶Ï Çy¶ˉ′úÂë
//ÕyμãÔ-×ó@ALIENTEK
//¼¼êõÂÛì3:
www.openedv.com
//DT¸ÄèÕÆú:2012/9/3
//°æ±¾£oV1.0
//°æè¨ËùóD£¬μá°æ±Ø¾¿¡£
//Copyright(C) 1ãÖYêDDÇòíμç×ó¿Æ¼¼óDÏT1«Ë¾ 2009-2019
//All rights reserved
//////////////////////////////////////////////////////////////////////////////////
//ía2¿ÖD¶Ï0·tÎñ3ìDò
//ÖD¶Ï3õê¼»ˉ
void EXTIX_Init(void)
{
EXTI_InitTypeDef EXTI_InitStature;
NVIC_InitTypeDef NVIC_InitStature;
//3õê¼»ˉIO¿úÎaêäèë
key_Init();
//¿aÆôIO¿ú¸′óÃê±Öó
RCC_APB2PeriphClockCmd(RCC_APB2Periph_AFIO,ENABLE);
//éèÖÃIO¿úóëÖD¶ÏÏßμÄó3éä1ØÏμ
GPIO_EXTILineConfig(GPIO_PortSourceGPIOA,GPIO_PinSource9);
GPIO_EXTILineConfig(GPIO_PortSourceGPIOA,GPIO_PinSource4);
//3õê¼»ˉÏßéÏÖD¶Ï
EXTI_InitStature.EXTI_Line = EXTI_Line9 | EXTI_Line4;
EXTI_InitStature.EXTI_LineCmd = ENABLE;
EXTI_InitStature.EXTI_Mode = EXTI_Mode_Interrupt;
EXTI_InitStature.EXTI_Trigger = EXTI_Trigger_Falling;
EXTI_Init(&EXTI_InitStature);
//ÅäÖÃÖD¶Ï·Ö×é,2¢ê1Äü
NVIC_InitStature.NVIC_IRQChannel = EXTI9_5_IRQn | EXTI4_IRQn;
NVIC_InitStature.NVIC_IRQChannelCmd = ENABLE;
NVIC_InitStature.NVIC_IRQChannelPreemptionPriority = 0;
NVIC_InitStature.NVIC_IRQChannelSubPriority = 2;
NVIC_Init(&NVIC_InitStature);
}
//ÖD¶Ï·tÎñoˉêy
void EXTI4_IRQHandler(void)
{
delay_ms(10);
if(EXTI_GetITStatus(EXTI_Line4) == SET)
{
LED1_OFF;
LED2_ON;
delay_ms(100);
}
//Çå3yÖD¶Ï±ê־λ
EXTI_ClearITPendingBit(EXTI_Line4);
}
void EXTI9_5_IRQHandler(void)
{
delay_ms(10);
if(EXTI_GetITStatus(EXTI_Line9) != SET)
{
LED1_OFF;
LED2_ON;
delay_ms(100);
// LED2_OFF;
}
//Çå3yÖD¶Ï±ê־λ
EXTI_ClearITPendingBit(EXTI_Line9);
}
一周热门 更多>