Skip to content

Commit 1069dfc

Browse files
authored
Merge pull request #3982 from mjrgh/patch-3
Ticker - kl25z bugfix for handling events in the past
2 parents 9c141b6 + 15c740f commit 1069dfc

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

hal/mbed_ticker_api.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,15 +74,17 @@ void ticker_insert_event(const ticker_data_t *const data, ticker_event_t *obj, t
7474
prev = p;
7575
p = p->next;
7676
}
77+
78+
/* if we're at the end p will be NULL, which is correct */
79+
obj->next = p;
80+
7781
/* if prev is NULL we're at the head */
7882
if (prev == NULL) {
7983
data->queue->head = obj;
8084
data->interface->set_interrupt(timestamp);
8185
} else {
8286
prev->next = obj;
8387
}
84-
/* if we're at the end p will be NULL, which is correct */
85-
obj->next = p;
8688

8789
core_util_critical_section_exit();
8890
}

targets/TARGET_Freescale/TARGET_KLXX/us_ticker.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -187,11 +187,11 @@ static void lptmr_isr(void) {
187187
void us_ticker_set_interrupt(timestamp_t timestamp) {
188188
int delta = (int)((uint32_t)timestamp - us_ticker_read());
189189
if (delta <= 0) {
190-
// This event was in the past:
191-
us_ticker_irq_handler();
192-
return;
193-
}
194-
190+
// This event was in the past. Force it into the very near
191+
// future instead.
192+
delta = 1;
193+
}
194+
195195
us_ticker_int_counter = (uint32_t)(delta >> 16);
196196
us_ticker_int_remainder = (uint16_t)(0xFFFF & delta);
197197
if (us_ticker_int_counter > 0) {

0 commit comments

Comments
 (0)