Fix for issue #6054 - interrupts scheduled in the past.

When ticker is not driven by the 1 MHz clock and HAL driver need to perform conversion between microseconds and ticks, then the interrupt might be scheduled in the past. For details see: https://github.com/ARMmbed/mbed-os/issues/6054.

This patch provides fix for such case. Interrupt is fired immidiatelly when last read tick is equal to the calculated tick when interrupt should be generated.
pull/6068/head
Przemyslaw Stekiel 2018-02-12 14:40:11 +00:00
parent 04f0f2b1aa
commit c2760be01c
1 changed files with 8 additions and 0 deletions

View File

@ -235,6 +235,14 @@ static void schedule_interrupt(const ticker_data_t *const ticker)
}
timestamp_t match_tick = compute_tick(ticker, match_time);
// The time has been checked to be future, but it could still round
// to the last tick as a result of us to ticks conversion
if (match_tick == queue->tick_last_read) {
// Match time has already expired so fire immediately
ticker->interface->fire_interrupt();
return;
}
ticker->interface->set_interrupt(match_tick);
timestamp_t cur_tick = ticker->interface->read();