Skip to content

Commit 72ccf0b

Browse files
authored
Force events into the future
1 parent 094d9ac commit 72ccf0b

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

targets/TARGET_Freescale/TARGET_KLXX/us_ticker.c

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -185,13 +185,14 @@ static void lptmr_isr(void) {
185185
}
186186

187187
void us_ticker_set_interrupt(timestamp_t timestamp) {
188-
int delta = (int)((uint32_t)timestamp - us_ticker_read());
188+
uint32_t tcur = us_ticker_read();
189+
int delta = (int)((uint32_t)timestamp - tcur);
189190
if (delta <= 0) {
190-
// This event was in the past:
191-
us_ticker_irq_handler();
192-
return;
193-
}
194-
191+
// This event was in the past. Force it into the very near
192+
// future instead.
193+
timestamp = tcur + 2;
194+
}
195+
195196
us_ticker_int_counter = (uint32_t)(delta >> 16);
196197
us_ticker_int_remainder = (uint16_t)(0xFFFF & delta);
197198
if (us_ticker_int_counter > 0) {

0 commit comments

Comments
 (0)