1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768 |
- #include "exti.h"
- #include "delay.h"
- void exti_Init(void)
- {
- EXTI_InitTypeDef EXTI_InitStruct;
- NVIC_InitTypeDef NVIC_InitStruct;
- GPIO_InitTypeDef GPIO_InitStructure;
- RCC_APB2PeriphClockCmd(RCC_APB2Periph_AFIO,ENABLE);
- RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOB,ENABLE);
- GPIO_InitStructure.GPIO_Pin = GPIO_Pin_7|GPIO_Pin_9;
-
- GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING;
- GPIO_Init(GPIOB, &GPIO_InitStructure);
-
- GPIO_EXTILineConfig(GPIO_PortSourceGPIOB,GPIO_PinSource7);
- EXTI_InitStruct.EXTI_Line=EXTI_Line7;
- EXTI_InitStruct.EXTI_LineCmd=ENABLE;
- EXTI_InitStruct.EXTI_Mode=EXTI_Mode_Interrupt;
- EXTI_InitStruct.EXTI_Trigger=EXTI_Trigger_Falling;
- EXTI_Init(&EXTI_InitStruct);
-
-
- GPIO_EXTILineConfig(GPIO_PortSourceGPIOB,GPIO_PinSource9);
- EXTI_InitStruct.EXTI_Line=EXTI_Line9;
- EXTI_InitStruct.EXTI_LineCmd=ENABLE;
- EXTI_InitStruct.EXTI_Mode=EXTI_Mode_Interrupt;
- EXTI_InitStruct.EXTI_Trigger=EXTI_Trigger_Falling;
- EXTI_Init(&EXTI_InitStruct);
-
-
- NVIC_InitStruct.NVIC_IRQChannel=EXTI9_5_IRQn;
- NVIC_InitStruct.NVIC_IRQChannelCmd=ENABLE;
- NVIC_InitStruct.NVIC_IRQChannelPreemptionPriority=1;
- NVIC_InitStruct.NVIC_IRQChannelSubPriority=0;
- NVIC_Init(&NVIC_InitStruct);
- }
- void EXTI9_5_IRQHandler(void)
- {
- if(EXTI_GetITStatus(EXTI_Line7)!=RESET)
- {
-
- EXTI_ClearITPendingBit(EXTI_Line7);
- }else if(EXTI_GetITStatus(EXTI_Line9)!=RESET)
- {
- }
- EXTI_ClearITPendingBit(EXTI_Line9);
- }
|