void EXTI3_IRQHandler(void)
{
if(GPIOB->IDR & GPIO_Pin_3)
{
//高启动定时器,清标准字
PPM_star[1]=TIM_GetCounter(TIM2);
}
else
{
PPM_end[1]=TIM_GetCounter(TIM2)-PPM_star[1];
if(PPM_end[1]>900 && PPM_end[1]<2100)
{PPMINF[1]=PPM_end[1]-INF_DAT[PPM_mid1];}
}
EXTI_ClearITPendingBit(EXTI_Line3);
}
void EXTI4_IRQHandler(void)
{
if(GPIOB->IDR & GPIO_Pin_4)
{
//高启动定时器,清标准字
PPM_star[2]=TIM_GetCounter(TIM2);
}
else
{
PPM_end[2]=TIM_GetCounter(TIM2)-PPM_star[2];
if(PPM_end[2]>900 && PPM_end[2]<2100)
{PPMINF[2]=PPM_end[2]-INF_DAT[PPM_mid2];}
}
EXTI_ClearITPendingBit(EXTI_Line4);
}
void EXTI9_5_IRQHandler(void)
{
if(EXTI_GetITStatus(EXTI_Line5) != RESET)
{
//高开始计时
//低停止计时
if(GPIOB->IDR & GPIO_Pin_5)
{
//高启动定时器,清标准字
PPM_star[3]=TIM_GetCounter(TIM2);
}
else
{
PPM_end[3]=TIM_GetCounter(TIM2)-PPM_star[3];
if(PPM_end[3]>900 && PPM_end[3]<2100)
{PPMINF[3]=PPM_end[3]-INF_DAT[PPM_mid3];}
}
EXTI_ClearITPendingBit(EXTI_Line5);
}
if(EXTI_GetITStatus(EXTI_Line8) != RESET)
{
//高开始计时
//低停止计时
if(GPIOB->IDR & GPIO_Pin_8)
{
//高启动定时器,清标准字
PPM_star[4]=TIM_GetCounter(TIM2);
}
else
{
PPM_end[4]=TIM_GetCounter(TIM2)-PPM_star[4];
if(PPM_end[4]>900 && PPM_end[4]<2100)
{PPMINF[4]=PPM_end[4]-INF_DAT[PPM_mid4];}
}
EXTI_ClearITPendingBit(EXTI_Line8);
}
if(EXTI_GetITStatus(EXTI_Line9) != RESET)
{
//高开始计时
//低停止计时
if(GPIOB->IDR & GPIO_Pin_9)
{
//高启动定时器,清标准字
PPM_star[5]=TIM_GetCounter(TIM2);
}
else
{
PPM_end[5]=TIM_GetCounter(TIM2)-PPM_star[5];
if(PPM_end[5]>900 && PPM_end[5]<2100)
{PPMINF[5]=PPM_end[5]-INF_DAT[PPM_mid5];}
}
EXTI_ClearITPendingBit(EXTI_Line9);
}
}
//外部中断
void EXTI15_10_IRQHandler(void)
{
if(EXTI_GetITStatus(EXTI_Line13) != RESET)
{
//高开始计时
//低停止计时
if(GPIOC->IDR & GPIO_Pin_13)
{
//高启动定时器,清标准字
PPM_star[6]=TIM_GetCounter(TIM2);
}
else
{
PPM_end[6]=TIM_GetCounter(TIM2)-PPM_star[6];
if(PPM_end[6]>900 && PPM_end[6]<2100)
{PPMINF[6]=PPM_end[6]-INF_DAT[PPM_mid6];}
}
EXTI_ClearITPendingBit(EXTI_Line13);
}
}
给你个例程看看 |