mbed library sources. Supersedes mbed-src.

Dependents:   Nucleo_Hello_Encoder BLE_iBeaconScan AM1805_DEMO DISCO-F429ZI_ExportTemplate1 ... more

Revision:
186:707f6e361f3e
Parent:
176:447f873cad2f
Child:
188:bcfe06ba3d64
--- a/platform/mbed_poll.cpp	Thu Apr 19 17:12:19 2018 +0100
+++ b/platform/mbed_poll.cpp	Fri Jun 22 16:45:37 2018 +0100
@@ -15,9 +15,13 @@
  */
 #include "mbed_poll.h"
 #include "FileHandle.h"
+#if MBED_CONF_RTOS_PRESENT
+#include "rtos/Kernel.h"
+#include "rtos/Thread.h"
+using namespace rtos;
+#else
 #include "Timer.h"
-#ifdef MBED_CONF_RTOS_PRESENT
-#include "rtos/Thread.h"
+#include "LowPowerTimer.h"
 #endif
 
 namespace mbed {
@@ -34,10 +38,23 @@
      * interested in. In future, his spinning behaviour will be replaced with
      * condition variables.
      */
+#if MBED_CONF_RTOS_PRESENT
+    uint64_t start_time = 0;
+    if (timeout > 0) {
+        start_time = Kernel::get_ms_count();
+    }
+#define TIME_ELAPSED() int64_t(Kernel::get_ms_count() - start_time)
+#else
+#if MBED_CONF_PLATFORM_POLL_USE_LOWPOWER_TIMER
+    LowPowerTimer timer;
+#else
     Timer timer;
+#endif
     if (timeout > 0) {
         timer.start();
     }
+#define TIME_ELAPSED() timer.read_ms()
+#endif // MBED_CONF_RTOS_PRESENT
 
     int count = 0;
     for (;;) {
@@ -60,7 +77,7 @@
         }
 
         /* Nothing selected - this is where timeout handling would be needed */
-        if (timeout == 0 || (timeout > 0 && timer.read_ms() > timeout)) {
+        if (timeout == 0 || (timeout > 0 && TIME_ELAPSED() > timeout)) {
             break;
         }
 #ifdef MBED_CONF_RTOS_PRESENT