初中生
最后登录1970-1-1
在线时间 小时
注册时间2016-10-22
|
void EXTI_KEY1_NVIC_Config(void)
{
NVIC_InitTypeDef NVIC_InitStruct;
NVIC_PriorityGroupConfig(NVIC_PriorityGroup_1);
NVIC_InitStruct.NVIC_IRQChannel= EXTI0_IRQn;
NVIC_InitStruct.NVIC_IRQChannelPreemptionPriority=1;
NVIC_InitStruct.NVIC_IRQChannelSubPriority=1;
NVIC_InitStruct.NVIC_IRQChannelCmd=ENABLE;
NVIC_Init(&NVIC_InitStruct);
}
void EXTI_KEY1_Config()
{
GPIO_InitTypeDef GPIO_InitStruct;
EXTI_InitTypeDef EXTI_InitStruct;
RCC_APB2PeriphClockCmd(RCC_APB2Periph_AFIO|RCC_APB2Periph_GPIOA,ENABLE);
EXTI_KEY1_NVIC_Config( ) ;
GPIO_InitStruct.GPIO_Pin=GPIO_Pin_0;
GPIO_InitStruct.GPIO_Mode= GPIO_Mode_IN_FLOATING ;
GPIO_Init( GPIOA,& GPIO_InitStruct);
GPIO_EXTILineConfig(GPIO_PortSourceGPIOA , GPIO_PinSource0);
EXTI_InitStruct.EXTI_Line= EXTI_Line0 ;
EXTI_InitStruct.EXTI_LineCmd=ENABLE;
EXTI_InitStruct.EXTI_Mode= EXTI_Mode_Interrupt;
EXTI_InitStruct.EXTI_Trigger= EXTI_Trigger_Rising;
EXTI_Init(& EXTI_InitStruct);
}
void EXTI_KEY2_NVIC_Config(void)
{
NVIC_InitTypeDef NVIC_InitStruct1;
NVIC_PriorityGroupConfig(NVIC_PriorityGroup_1);
NVIC_InitStruct1.NVIC_IRQChannel= EXTI0_IRQn;;
NVIC_InitStruct1.NVIC_IRQChannelPreemptionPriority=1;
NVIC_InitStruct1.NVIC_IRQChannelSubPriority=1;
NVIC_InitStruct1.NVIC_IRQChannelCmd=ENABLE;
NVIC_Init(&NVIC_InitStruct1);
}
void EXTI_KEY2_Config()
{
GPIO_InitTypeDef GPIO_InitStruct;
EXTI_InitTypeDef EXTI_InitStruct;
RCC_APB2PeriphClockCmd(RCC_APB2Periph_AFIO|RCC_APB2Periph_GPIOC,ENABLE);
EXTI_KEY2_NVIC_Config( ) ;
GPIO_InitStruct.GPIO_Pin=GPIO_Pin_0;
GPIO_InitStruct.GPIO_Mode= GPIO_Mode_IN_FLOATING ;
GPIO_Init( GPIOC,& GPIO_InitStruct);
GPIO_EXTILineConfig(GPIO_PortSourceGPIOC , GPIO_PinSource0);
EXTI_InitStruct.EXTI_Line= EXTI_Line0 ;
EXTI_InitStruct.EXTI_LineCmd=ENABLE;
EXTI_InitStruct.EXTI_Mode= EXTI_Mode_Interrupt;
EXTI_InitStruct.EXTI_Trigger=EXTI_Trigger_Rising;
EXTI_Init(& EXTI_InitStruct);
}
//中断函数
void EXTI0_IRQHandler ( )
{
if(EXTI_GetITStatus( EXTI_Line0)!=RESET)
{
if(GPIOA->IDR && 0x01==0x01)
{
LED3(ON);
DelayTime();
LED3(OFF);
DelayTime();
}
if(GPIOC->IDR && 0x01==0x01)
{
LED1(ON);
DelayTime();
LED1(OFF);
DelayTime();
}
EXTI_ClearFlag(EXTI_Line0);
}
}
这段代码到底哪里出错了,为什么就是不能正常运行啊
|
|