mbed library sources(for async_print)

Dependents:   AsyncPrint

Fork of mbed-src by mbed official

Revision:
484:b5ae48b573d3
Parent:
481:ca51ab3eed5a
Child:
495:01cb89f68337
diff -r 37da4976ca27 -r b5ae48b573d3 common/us_ticker_api.c
--- 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;
 }