Implementation of virtual timers
Posted: Thu Dec 28, 2017 3:03 pm
I 'm having trouble in generating the delay at correct time using virtual timers.
if (LED1== ON)
{
led2ON();
chSysLockFromIsr();
if (chVTIsArmedI(&close_pulse_timer))
chVTResetI(&close_pulse_timer);
chVTSetI(&close_pulse_timer, MS2ST(2000), led2OFF, NULL); // TURNS OFF LED2 AFTER 2 SECONDS.
chSysUnlockFromIsr();
}
This is my function, I'm suposed to turn 2nd LED ON for 2 seconds when 1st led is ON.
But with this code the call back function is called after the 1st LED turned OFF.
I would like to call the callback function to turnOff 2nd led when 1st Led is ON.
Can you please correct me if I'm going wrong some where?
if (LED1== ON)
{
led2ON();
chSysLockFromIsr();
if (chVTIsArmedI(&close_pulse_timer))
chVTResetI(&close_pulse_timer);
chVTSetI(&close_pulse_timer, MS2ST(2000), led2OFF, NULL); // TURNS OFF LED2 AFTER 2 SECONDS.
chSysUnlockFromIsr();
}
This is my function, I'm suposed to turn 2nd LED ON for 2 seconds when 1st led is ON.
But with this code the call back function is called after the 1st LED turned OFF.
I would like to call the callback function to turnOff 2nd led when 1st Led is ON.
Can you please correct me if I'm going wrong some where?