mbed library sources

Dependents:   Encrypted my_mbed lklk CyaSSL_DTLS_Cellular ... more

Superseded

This library was superseded by mbed-dev - https://os.mbed.com/users/mbed_official/code/mbed-dev/.

Development branch of the mbed library sources. This library is kept in synch with the latest changes from the mbed SDK and it is not guaranteed to work.

If you are looking for a stable and tested release, please import one of the official mbed library releases:

Import librarymbed

The official Mbed 2 C/C++ SDK provides the software platform and libraries to build your applications.

Revision:
361:56c2a6244bba
Parent:
304:89b9c3a9a045
Child:
452:a2b30f7d1bc5
--- a/targets/hal/TARGET_NORDIC/TARGET_MCU_NRF51822/us_ticker.c	Mon Oct 20 09:15:07 2014 +0100
+++ b/targets/hal/TARGET_NORDIC/TARGET_MCU_NRF51822/us_ticker.c	Tue Oct 21 08:15:06 2014 +0100
@@ -42,7 +42,7 @@
 
     timestamp_t value;
     app_timer_cnt_get(&value); /* This returns the RTC counter (which is fed by the 32khz crystal clock source) */
-    return (uint32_t)((value * 1000000) / APP_TIMER_CLOCK_FREQ); /* Return a pseudo microsecond counter value.
+    return ((value * 1000000) / (uint32_t)APP_TIMER_CLOCK_FREQ); /* Return a pseudo microsecond counter value.
                                                                   * This is only as precise as the 32khz low-freq
                                                                   * clock source, but could be adequate.*/
 }
@@ -78,15 +78,17 @@
     uint32_t targetCounter = ((uint32_t)((timestamp * (uint64_t)APP_TIMER_CLOCK_FREQ) / 1000000) + 1) & MAX_RTC_COUNTER_VAL;
     uint32_t ticksToCount = (targetCounter >= currentCounter) ?
                              (targetCounter - currentCounter) : (MAX_RTC_COUNTER_VAL + 1) - (currentCounter - targetCounter);
-    if (ticksToCount > 0) {
-        uint32_t rc;
-        rc = app_timer_start(us_ticker_appTimerID, ticksToCount, NULL /*p_context*/);
-        if (rc != NRF_SUCCESS) {
-            /* placeholder to do something to recover from error */
-            return;
-        }
-        us_ticker_appTimerRunning = true;
+    if (ticksToCount < APP_TIMER_MIN_TIMEOUT_TICKS) { /* Honour the minimum value of the timeout_ticks parameter of app_timer_start() */
+        ticksToCount = APP_TIMER_MIN_TIMEOUT_TICKS;
     }
+
+    uint32_t rc;
+    rc = app_timer_start(us_ticker_appTimerID, ticksToCount, NULL /*p_context*/);
+    if (rc != NRF_SUCCESS) {
+        /* placeholder to do something to recover from error */
+        return;
+    }
+    us_ticker_appTimerRunning = true;
 }
 
 void us_ticker_disable_interrupt(void)