void KEY_Init(void)
{
GPIO_InitTypeDef GPIO_InitStruct;
NVIC_InitTypeDef NVIC_InitStructure;
EXTI_InitTypeDef EXTI_InitStructure;
RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOB, ENABLE);
RCC_APB2PeriphClockCmd(RCC_APB2Periph_SYSCFG,ENABLE);
GPIO_InitStruct.GPIO_Pin = GPIO_Pin_1 ;
GPIO_InitStruct.GPIO_Mode = GPIO_Mode_IN;
GPIO_InitStruct.GPIO_PuPd = GPIO_PuPd_UP ;
GPIO_InitStruct.GPIO_Speed = GPIO_Speed_Level_3;
GPIO_Init(GPIOB, &GPIO_InitStruct);
NVIC_InitStructure.NVIC_IRQChannel = EXTI0_1_IRQn;
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
NVIC_InitStructure.NVIC_IRQChannelPriority = 0;
NVIC_Init(&NVIC_InitStructure);
SYSCFG_EXTILineConfig(EXTI_PortSourceGPIOB,EXTI_PinSource1);
EXTI_InitStructure.EXTI_Line = EXTI_Line1 ;
EXTI_InitStructure.EXTI_Mode = EXTI_Mode_Interrupt;
EXTI_InitStructure.EXTI_Trigger = EXTI_Trigger_Falling;
EXTI_InitStructure.EXTI_LineCmd = ENABLE;
EXTI_Init(&EXTI_InitStructure);
}
void EXTI_Line1_IRQHandler(void)
{
if(EXTI_GetITStatus(EXTI_Line1) == SET)
{
// Converter_channelbankFlag=~Converter_channelbankFlag;
//if(Converter_channelbankFlag==0)
// LED_Open( );
// else
LED_Close( );
EXTI_ClearITPendingBit(EXTI_Line1);
}
}
void main(void)
{
LED_Init( );
KEY_Init( );
LED_Open( );
//UART_Init( );
//TIM3_Init_OC1( );
while(1)
{
}
}
|