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:
452:a2b30f7d1bc5
Parent:
361:56c2a6244bba
Child:
453:a290c6acf95e
--- a/targets/hal/TARGET_NORDIC/TARGET_MCU_NRF51822/us_ticker.c	Mon Jan 26 07:00:07 2015 +0000
+++ b/targets/hal/TARGET_NORDIC/TARGET_MCU_NRF51822/us_ticker.c	Mon Jan 26 14:15:07 2015 +0000
@@ -18,6 +18,7 @@
 #include "cmsis.h"
 #include "PeripheralNames.h"
 #include "app_timer.h"
+#include "projectconfig.h"
 
 static bool           us_ticker_inited          = false;
 static volatile bool  us_ticker_appTimerRunning = false;
@@ -29,7 +30,7 @@
         return;
     }
 
-    APP_TIMER_INIT(0 /*CFG_TIMER_PRESCALER*/ , 1 /*CFG_TIMER_MAX_INSTANCE*/, 1 /*CFG_TIMER_OPERATION_QUEUE_SIZE*/, false /*CFG_SCHEDULER_ENABLE*/);
+    APP_TIMER_INIT(CFG_TIMER_PRESCALER, CFG_TIMER_MAX_INSTANCE, CFG_TIMER_OPERATION_QUEUE_SIZE, CFG_SCHEDULER_ENABLE);
 
     us_ticker_inited = true;
 }
@@ -40,7 +41,7 @@
         us_ticker_init();
     }
 
-    timestamp_t value;
+    uint64_t value;
     app_timer_cnt_get(&value); /* This returns the RTC counter (which is fed by the 32khz crystal clock source) */
     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
@@ -72,7 +73,7 @@
         return;
     }
 
-    timestamp_t currentCounter64;
+    uint64_t currentCounter64;
     app_timer_cnt_get(&currentCounter64);
     uint32_t currentCounter = currentCounter64 & MAX_RTC_COUNTER_VAL;
     uint32_t targetCounter = ((uint32_t)((timestamp * (uint64_t)APP_TIMER_CLOCK_FREQ) / 1000000) + 1) & MAX_RTC_COUNTER_VAL;
@@ -94,13 +95,17 @@
 void us_ticker_disable_interrupt(void)
 {
     if (us_ticker_appTimerRunning) {
-        app_timer_stop(us_ticker_appTimerID);
+        if (app_timer_stop(us_ticker_appTimerID) == NRF_SUCCESS) {
+            us_ticker_appTimerRunning = false;
+        }
     }
 }
 
 void us_ticker_clear_interrupt(void)
 {
     if (us_ticker_appTimerRunning) {
-        app_timer_stop(us_ticker_appTimerID);
+        if (app_timer_stop(us_ticker_appTimerID) == NRF_SUCCESS) {
+            us_ticker_appTimerRunning = false;
+        }
     }
 }