void MiniBalance_EXTI_Init(void) { GPIO_InitTypeDef GPIO_InitStructure; EXTI_InitTypeDef EXTI_InitStructure; NVIC_InitTypeDef NVIC_InitStructure; RCC_APB2PeriphClockCmd(RCC_APB2Periph_AFIO,ENABLE);//ҿאìѨҪʹŜAFIOʱד RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA, ENABLE); //ʹŜGPIOࠚʱד GPIO_InitStructure.GPIO_Pin = GPIO_Pin_12; //ࠚƤ׃ GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IPU; //ʏ-ˤɫ GPIO_Init(GPIOA, &GPIO_InitStructure); //ٹߝʨ֨ӎ˽ԵʼۯGPIO GPIO_EXTILineConfig(GPIO_PortSourceGPIOA,GPIO_PinSource12); EXTI_InitStructure.EXTI_Line=EXTI_Line12; EXTI_InitStructure.EXTI_Mode = EXTI_Mode_Interrupt; EXTI_InitStructure.EXTI_Trigger = EXTI_Trigger_Falling;//ЂݵҘԥע EXTI_InitStructure.EXTI_LineCmd = ENABLE; EXTI_Init(&EXTI_InitStructure); //ٹߝEXTI_InitStructאָ֨քӎ˽ԵʼۯʨEXTI݄զǷ NVIC_InitStructure.NVIC_IRQChannel = EXTI15_10_IRQn; //ʹŜдݼ̹՚քҿאͨր NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0x02; //ȀռԅЈܶ2ì NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0x01; //ؓԅЈܶ1 NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; //ʹŜҿאͨր NVIC_Init(&NVIC_InitStructure); }
时间: 2024-04-27 18:20:16 浏览: 135
STM32-EXTI.rar_stm32 exti
这是一个用于初始化外部中断的函数,其中包括对GPIO和EXTI的初始化,以及对NVIC中断的配置。其中,GPIOA的Pin12被配置为输入上拉模式,EXTI线路12被配置为下降沿触发中断模式。NVIC中断通道被配置为EXTI15_10,优先级为0x02和0x01,使能EXTI15_10_IRQn通道中断。
阅读全文