STM32F103V GPIO中断
端口配置:
void GPIO_Configuration(void)
{
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOC , ENABLE);
GPIO_InitStructure.GPIO_Pin = IR_int_IN|IR_int_OUT; //IR_int 作为输入
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING ; //输入
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_10MHz;
GPIO_Init(GPIOC, &GPIO_InitStructure);
}
//时钟配置
void RCC_Configuration(void)
{
SystemInit();
RCC_AHBPeriphClockCmd(RCC_AHBPeriph_DMA1, ENABLE);
RCC_APB2PeriphClockCmd( | RCC_APB2Periph_GPIOC | RCC_APB2Periph_AFIO, ENABLE);
}
//中断配置
void NVIC_Configuration(void)
{
NVIC_InitTypeDef NVIC_InitStructure;
/* Configure the NVIC Preemption Priority Bits */
NVIC_PriorityGroupConfig(NVIC_PriorityGroup_1);
NVIC_PriorityGroupConfig(NVIC_PriorityGroup_0); // 抢占式优先级别
NVIC_InitStructure.NVIC_IRQChannel = EXTI9_5_IRQn; //指定中断源
NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0; // 指定响应优先级别1
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
NVIC_Init(&NVIC_InitStructure);
}
/////////////////GPIO中断处理函数/////////////
void EXTI9_5_IRQHandler(void)
{
IWDG_ReloadCounter();//喂狗
if (EXTI_GetITStatus(EXTI_Line6) != RESET)
{
//添加中断处理程序
speakertest();
EXTI_ClearFlag(EXTI_Line6);
}
if (EXTI_GetITStatus(EXTI_Line7) != RESET)
{
//添加中断处理程序
speakertest();
EXTI_ClearFlag(EXTI_Line7);
}
}
STM32F103VGPIO中 相关文章:
- Windows CE 进程、线程和内存管理(11-09)
- RedHatLinux新手入门教程(5)(11-12)
- uClinux介绍(11-09)
- openwebmailV1.60安装教学(11-12)
- Linux嵌入式系统开发平台选型探讨(11-09)
- Windows CE 进程、线程和内存管理(二)(11-09)