标签:rip enable def lcm sub mod handler io复用 span
1.外部中断开启步骤
a.初始化IO口为输入
GPIO_Init();
b.使能IO复用功能时钟
RCC_APB2PeriphClockCmd(RCC_APB2Periph_AFIO,ENABLE);
c.设置与中断线的映射关系
void GPIO_EXTILineConfig();
d.初始化线上外部中断,设置出发条件
EXTI_Init();
e.配置中断函数,并使能中断
NVIC_Init();
f.编写中断服务函数
EXTIx_IRQHandler();
g.清除中断标志位
EXTI_ClearITPendingBit();
void EXTI_INIT() { EXTI_InitTypeDef EXTI_Initstructe; GPIO_InitTypeDef GPIO_Initstructe; NVIC_InitTypeDef NVIC_Initstructe; RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOC, ENABLE); RCC_APB2PeriphClockCmd(RCC_APB2Periph_AFIO, ENABLE); GPIO_Initstructe.GPIO_Pin=GPIO_Pin_5; GPIO_Initstructe.GPIO_Mode=GPIO_Mode_IPU; GPIO_Initstructe.GPIO_Speed=GPIO_Speed_50MHz; GPIO_Init(GPIOC,&GPIO_Initstructe); GPIO_EXTILineConfig(GPIO_PortSourceGPIOC,GPIO_PinSource5); EXTI_Initstructe.EXTI_Line=EXTI_Line5; EXTI_Initstructe.EXTI_LineCmd=ENABLE; EXTI_Initstructe.EXTI_Mode=EXTI_Mode_Interrupt; EXTI_Initstructe.EXTI_Trigger=EXTI_Trigger_Falling; EXTI_Init(&EXTI_Initstructe); NVIC_Initstructe.NVIC_IRQChannel=EXTI9_5_IRQn; NVIC_Initstructe.NVIC_IRQChannelCmd=ENABLE; NVIC_Initstructe.NVIC_IRQChannelPreemptionPriority=2; NVIC_Initstructe.NVIC_IRQChannelSubPriority=2; NVIC_Init(&NVIC_Initstructe); }
标签:rip enable def lcm sub mod handler io复用 span
原文地址:https://www.cnblogs.com/cgy601785959/p/10139677.html