1

Revision:
20:75635d50262e
Parent:
17:5f34cbe2ac53
--- a/radio_sx128x.cpp	Thu Jun 25 12:39:08 2020 -0700
+++ b/radio_sx128x.cpp	Fri Jul 10 10:52:39 2020 -0700
@@ -3,6 +3,18 @@
 #include "SPIu.h"
 #include <float.h>
 
+#ifdef DEVICE_LPTICKER
+LowPowerTimer Radio::lpt;
+#else
+Timer Radio::lpt;
+#endif
+
+#if (MBED_MAJOR_VERSION < 6)
+volatile us_timestamp_t Radio::irqAt;
+#else
+LowPowerClock::time_point Radio::irqAt;
+#endif
+
 #ifdef TARGET_FF_ARDUINO    /* pins of SX126xDVK1xAS board */
     #define NRST_PIN        A0
     SPIu spi(D11, D12, D13); // mosi, miso, sclk
@@ -43,11 +55,6 @@
     #define RX_INDICATION       pc3
 #endif /* TARGET_FF_MORPHO */
 
-#ifdef DEVICE_LPTICKER
-LowPowerTimer Radio::lpt;
-#else
-Timer Radio::lpt;
-#endif
 
 PacketParams_t Radio::ppGFSK;
 PacketParams_t Radio::ppLORA;
@@ -58,7 +65,6 @@
 ModulationParams_t Radio::mpLORA;
 
 const RadioEvents_t* RadioEvents;
-volatile us_timestamp_t Radio::irqAt;
 
 unsigned Radio::symbolPeriodUs;
 unsigned Radio::nSymbs;
@@ -249,7 +255,11 @@
 
 void Radio:: diox_top_half()
 {
+#if (MBED_MAJOR_VERSION < 6)
     irqAt = lpt.read_us();
+#else
+    irqAt = LowPowerClock::now();
+#endif
 
     if (RadioEvents->DioPin_top_half)
         RadioEvents->DioPin_top_half();
@@ -350,19 +360,35 @@
         int rssi;
         us_timestamp_t startAt, chFreeAt, now;
         radio.start_rx(-1);
+    #if (MBED_MAJOR_VERSION < 6)
         startAt = lpt.read_us();
+    #else
+        startAt = LowPowerClock::now().time_since_epoch().count();
+    #endif
 Lstart:
         do {
+    #if (MBED_MAJOR_VERSION < 6)
             now = lpt.read_us();
+    #else
+            now = LowPowerClock::now().time_since_epoch().count();
+    #endif
             if ((now - startAt) > maxListenTime) {
                 return -1;
             }
             radio.xfer(OPCODE_GET_RSSIINST, 0, 2, buf);
             rssi = buf[1] / -2;
         } while (rssi > rssiThresh);
+    #if (MBED_MAJOR_VERSION < 6)
         chFreeAt = lpt.read_us();
+    #else
+        chFreeAt = LowPowerClock::now().time_since_epoch().count();
+    #endif
         do {
+    #if (MBED_MAJOR_VERSION < 6)
             now = lpt.read_us();
+    #else
+            now = LowPowerClock::now().time_since_epoch().count();
+    #endif
             radio.xfer(OPCODE_GET_RSSIINST, 0, 2, buf);
             rssi = buf[1] / -2;
             if (rssi > rssiThresh) {