mbed library sources
Fork of mbed-src by
Diff: common/us_ticker_api.c
- Revision:
- 304:89b9c3a9a045
- Parent:
- 221:8276e3a4886f
- Child:
- 361:56c2a6244bba
--- a/common/us_ticker_api.c Fri Aug 29 11:45:07 2014 +0100 +++ b/common/us_ticker_api.c Fri Aug 29 17:15:07 2014 +0100 @@ -45,6 +45,8 @@ if (event_handler != NULL) { event_handler(p->id); // NOTE: the handler can set new events } + /* Note: We continue back to examining the head because calling the + * event handler may have altered the chain of pending events. */ } else { // This event and the following ones in the list are in the future: // set it as next interrupt and return @@ -54,7 +56,7 @@ } } -void us_ticker_insert_event(ticker_event_t *obj, unsigned int timestamp, uint32_t id) { +void us_ticker_insert_event(ticker_event_t *obj, timestamp_t timestamp, uint32_t id) { /* disable interrupts for the duration of the function */ __disable_irq(); @@ -95,7 +97,9 @@ if (head == obj) { // first in the list, so just drop me head = obj->next; - if (obj->next != NULL) { + if (head == NULL) { + us_ticker_disable_interrupt(); + } else { us_ticker_set_interrupt(head->timestamp); } } else {