mbed library sources(for async_print)
Fork of mbed-src by
Revision 484:b5ae48b573d3, committed 2015-03-03
- Comitter:
- mbed_official
- Date:
- Tue Mar 03 07:15:07 2015 +0000
- Parent:
- 483:37da4976ca27
- Child:
- 485:f7652ef73633
- Commit message:
- Synchronized with git revision 38514db08e270ed489f24230e15a248e23ca5a95
Full URL: https://github.com/mbedmicro/mbed/commit/38514db08e270ed489f24230e15a248e23ca5a95/
Fix issue #934: Handled condition when head is NULL.
Changed in this revision
common/us_ticker_api.c | Show annotated file Show diff for this revision Revisions of this file |
hal/us_ticker_api.h | Show annotated file Show diff for this revision Revisions of this file |
--- a/common/us_ticker_api.c Sat Feb 28 07:15:07 2015 +0000 +++ b/common/us_ticker_api.c Tue Mar 03 07:15:07 2015 +0000 @@ -117,6 +117,16 @@ __enable_irq(); } -timestamp_t us_ticker_get_next_timestamp(void) { - return head->timestamp; +int us_ticker_get_next_timestamp(timestamp_t *timestamp) { + int ret = 0; + + /* if head is NULL, there are no pending events */ + __disable_irq(); + if (head != NULL) { + *timestamp = head->timestamp; + ret = 1; + } + __enable_irq(); + + return ret; }
--- a/hal/us_ticker_api.h Sat Feb 28 07:15:07 2015 +0000 +++ b/hal/us_ticker_api.h Tue Mar 03 07:15:07 2015 +0000 @@ -43,7 +43,7 @@ void us_ticker_insert_event(ticker_event_t *obj, timestamp_t timestamp, uint32_t id); void us_ticker_remove_event(ticker_event_t *obj); -timestamp_t us_ticker_get_next_timestamp(void); +int us_ticker_get_next_timestamp(timestamp_t *timestamp); #ifdef __cplusplus }