大学生
最后登录1970-1-1
在线时间 小时
注册时间2018-4-2
|
- #include "bsp_exti.h"
- static void EXTI_NVIC_Config(void)
- {
- NVIC_InitTypeDef NVIC_InitStuct;
- NVIC_PriorityGroupConfig(NVIC_PriorityGroup_1);
- NVIC_InitStuct.NVIC_IRQChannel = EXTI0_IRQn;
- NVIC_InitStuct.NVIC_IRQChannelPreemptionPriority = 1;
- NVIC_InitStuct.NVIC_IRQChannelSubPriority = 1;
- NVIC_InitStuct.NVIC_IRQChannelCmd = ENABLE;
- NVIC_Init(&NVIC_InitStuct);
-
- NVIC_InitStuct.NVIC_IRQChannel = EXTI15_10_IRQn;
- NVIC_Init(&NVIC_InitStuct);
- }
- void EXTI_Key_Config(void)
- {
- GPIO_InitTypeDef GPIO_InitStuct;
- EXTI_InitTypeDef EXTI_InitStuct;
-
- RCC_APB2PeriphClockCmd(KEY1_INT_GPIO_CLK, ENABLE);
- //配置中断优先级
- EXTI_NVIC_Config();
- //初始化GPIO
- GPIO_InitStuct.GPIO_Pin = KEY1_INT_GPIO_PIN;
- GPIO_InitStuct.GPIO_Mode = GPIO_Mode_IN_FLOATING;
- GPIO_Init(KEY1_INT_GPIO_PORT, &GPIO_InitStuct);
-
- GPIO_EXTILineConfig(GPIO_PortSourceGPIOA, GPIO_PinSource0);
-
- EXTI_InitStuct.EXTI_Line = EXTI_Line0;
- EXTI_InitStuct.EXTI_Mode = EXTI_Mode_Interrupt;
- EXTI_InitStuct.EXTI_Trigger = EXTI_Trigger_Rising;
- EXTI_InitStuct.EXTI_LineCmd = ENABLE;
- EXTI_Init(&EXTI_InitStuct);
- /*KEY2配置*/
- GPIO_InitStuct.GPIO_Pin = KEY2_INT_GPIO_PIN;
- GPIO_InitStuct.GPIO_Mode = GPIO_Mode_IN_FLOATING;
- GPIO_Init(KEY2_INT_GPIO_PORT, &GPIO_InitStuct);
-
- GPIO_EXTILineConfig(GPIO_PortSourceGPIOC, GPIO_PinSource13);
-
- EXTI_InitStuct.EXTI_Line = EXTI_Line13;
- EXTI_InitStuct.EXTI_Mode = EXTI_Mode_Interrupt;
- EXTI_InitStuct.EXTI_Trigger = EXTI_Trigger_Falling;
- EXTI_InitStuct.EXTI_LineCmd = ENABLE;
- EXTI_Init(&EXTI_InitStuct);
- }
复制代码
|
|