2020-10-29 08:46:25 +08:00
|
|
|
|
#include "bsp_key_exti.h"
|
|
|
|
|
|
|
|
|
|
static void EXTI_NVIC_Config(void)
|
|
|
|
|
{
|
|
|
|
|
NVIC_InitTypeDef NVIC_IntStruct;
|
|
|
|
|
|
|
|
|
|
NVIC_PriorityGroupConfig(NVIC_PriorityGroup_1);
|
|
|
|
|
|
|
|
|
|
//<2F><><EFBFBD><EFBFBD>key1
|
|
|
|
|
NVIC_IntStruct.NVIC_IRQChannel = EXTI0_IRQn;
|
|
|
|
|
NVIC_IntStruct.NVIC_IRQChannelPreemptionPriority = 1;
|
|
|
|
|
NVIC_IntStruct.NVIC_IRQChannelSubPriority = 1;
|
|
|
|
|
NVIC_IntStruct.NVIC_IRQChannelCmd = ENABLE;
|
|
|
|
|
NVIC_Init(&NVIC_IntStruct);
|
|
|
|
|
|
|
|
|
|
//<2F><><EFBFBD><EFBFBD>key2
|
|
|
|
|
NVIC_IntStruct.NVIC_IRQChannel = EXTI15_10_IRQn;
|
|
|
|
|
NVIC_IntStruct.NVIC_IRQChannelPreemptionPriority = 1;
|
|
|
|
|
NVIC_IntStruct.NVIC_IRQChannelSubPriority = 1;
|
|
|
|
|
NVIC_Init(&NVIC_IntStruct);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void EXTI_Key_Config(void)
|
|
|
|
|
{
|
|
|
|
|
GPIO_InitTypeDef GPIO_InitStruct;
|
|
|
|
|
EXTI_InitTypeDef EXTI_InitStruct;
|
|
|
|
|
|
|
|
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD>ж<EFBFBD><D0B6><EFBFBD><EFBFBD>ȼ<EFBFBD>
|
|
|
|
|
EXTI_NVIC_Config();
|
|
|
|
|
|
|
|
|
|
//<2F><>ʼ<EFBFBD><CABC>GPIO
|
|
|
|
|
RCC_APB2PeriphClockCmd(KEY1_INT_GPIO_CLK, ENABLE); //key1ʱ<31><CAB1>
|
|
|
|
|
RCC_APB2PeriphClockCmd(KEY2_INT_GPIO_CLK, ENABLE); //key2ʱ<32><CAB1>
|
|
|
|
|
|
|
|
|
|
//<2F><>ʼ<EFBFBD><CABC>key1
|
|
|
|
|
GPIO_InitStruct.GPIO_Pin = KEY1_INT_GPIO_PIN;
|
|
|
|
|
GPIO_InitStruct.GPIO_Mode = GPIO_Mode_IN_FLOATING;
|
|
|
|
|
GPIO_Init(KEY1_INT_GPIO_PORT, &GPIO_InitStruct);
|
|
|
|
|
|
|
|
|
|
//<2F><>ʼ<EFBFBD><CABC>key2
|
|
|
|
|
GPIO_InitStruct.GPIO_Pin = KEY2_INT_GPIO_PIN;
|
|
|
|
|
GPIO_InitStruct.GPIO_Mode = GPIO_Mode_IN_FLOATING;
|
|
|
|
|
GPIO_Init(KEY2_INT_GPIO_PORT, &GPIO_InitStruct);
|
|
|
|
|
|
|
|
|
|
//<2F><>ʼ<EFBFBD><CABC>EXTI
|
|
|
|
|
RCC_APB2PeriphClockCmd(RCC_APB2Periph_AFIO, ENABLE);
|
|
|
|
|
GPIO_EXTILineConfig(GPIO_PortSourceGPIOA, GPIO_PinSource0);
|
|
|
|
|
GPIO_EXTILineConfig(GPIO_PortSourceGPIOC, GPIO_PinSource13);
|
|
|
|
|
|
|
|
|
|
EXTI_InitStruct.EXTI_Line = EXTI_Line0; //key1
|
|
|
|
|
EXTI_InitStruct.EXTI_Mode = EXTI_Mode_Interrupt;
|
|
|
|
|
EXTI_InitStruct.EXTI_Trigger = EXTI_Trigger_Rising;
|
|
|
|
|
EXTI_InitStruct.EXTI_LineCmd = ENABLE;
|
|
|
|
|
EXTI_Init(&EXTI_InitStruct);
|
|
|
|
|
|
|
|
|
|
EXTI_InitStruct.EXTI_Line = EXTI_Line13; //key2
|
|
|
|
|
EXTI_InitStruct.EXTI_Mode = EXTI_Mode_Interrupt;
|
|
|
|
|
EXTI_InitStruct.EXTI_Trigger = EXTI_Trigger_Falling;
|
|
|
|
|
EXTI_InitStruct.EXTI_LineCmd = ENABLE;
|
|
|
|
|
EXTI_Init(&EXTI_InitStruct);
|
|
|
|
|
|
|
|
|
|
}
|