INTERRUPT_HANDLER(TIM1_CAP_COM_IRQHandler, 12)
{
/* In order to detect unexpected events during development,
it is recommended to set a breakpoint on the following instruction.
*/
if((TIM1->SR1 & TIM1_FLAG_CC1) == TIM1_FLAG_CC1)
{
TIM1_ClearFlag(TIM1_FLAG_CC1);
if(bCapture1_Rising == FALSE)
{
bCapture_Timer_Reset = TRUE;
bCapture1_Rising = TRUE;
}
else
{
wRed_Period = TIM1_GetCapture1();
wRed_PWM = (100 * (DWORD)wRed_On_Time) / wRed_Period;
bCapture_Timer_Reset = TRUE;
wRed_OVF_Flag = 0;
}
}
if((TIM1->SR1 & TIM1_FLAG_CC2) == TIM1_FLAG_CC2)
{
TIM1_ClearFlag(TIM1_FLAG_CC2);
wRed_On_Time = TIM1_GetCapture2();
}
if((TIM1->SR1 & TIM1_FLAG_CC3) == TIM1_FLAG_CC3)
{
TIM1_ClearFlag(TIM1_FLAG_CC3);
if(bCapture2_Rising == FALSE)
{
bCapture_Timer_Reset = TRUE;
bCapture2_Rising = TRUE;
}
else
{
wGreen_Period = TIM1_GetCapture3();
wGreen_PWM = (100 * (DWORD)wGreen_On_Time) / wGreen_Period;
bCapture_Timer_Reset = TRUE;
}
}
if((TIM1->SR1 & TIM1_FLAG_CC4) == TIM1_FLAG_CC4)
{
TIM1_ClearFlag(TIM1_FLAG_CC4);
wGreen_On_Time = TIM1_GetCapture4();
}
if(bCapture_Timer_Reset == TRUE)
{
bCapture_Timer_Reset = FALSE;
TIM1_SetCounter(0x00);
}
}