#include"exit.h"
static void 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 Exit_init(void)
{
EXTI_InitTypeDef EXTI_InitStructe;
GPIO_InitTypeDef GPIO_InitStruct;
NVIC_Config();
RCC_APB2PeriphClockCmd(PRESS_CLK,ENABLE);
GPIO_InitStruct.GPIO_Mode = GPIO_Mode_IPU; //配置成上拉模式
GPIO_InitStruct.GPIO_Pin = PRESS_PIN;
GPIO_Init(GPIOA,&GPIO_InitStruct);
EXTI_InitStructe.EXTI_Line = EXTI_Line0 ; //选择外部中断线´
EXTI_InitStructe.EXTI_Mode = EXTI_Mode_Interrupt; //选择模式 中断或触发
EXTI_InitStructe.EXTI_Trigger = EXTI_Trigger_Rising; //上升沿
EXTI_InitStructe.EXTI_LineCmd = ENABLE; //开启¯
EXTI_Init(&EXTI_InitStructe);
}
STM32按键中断
最新推荐文章于 2023-03-26 20:03:00 发布