1

Revision:
20:75635d50262e
Parent:
19:94b5382d3fc6
diff -r 94b5382d3fc6 -r 75635d50262e radio_sx127x.cpp
--- a/radio_sx127x.cpp	Thu Jun 25 12:39:08 2020 -0700
+++ b/radio_sx127x.cpp	Fri Jul 10 10:52:39 2020 -0700
@@ -9,6 +9,13 @@
 Timeout TxTimeoutEvent;
 #endif
 
+#if (MBED_MAJOR_VERSION < 6)
+volatile us_timestamp_t Radio::irqAt;
+#else
+using namespace std::chrono;
+LowPowerClock::time_point Radio::irqAt;
+#endif
+
 void Radio::Sleep()
 {
     radio.set_opmode(RF_OPMODE_SLEEP);
@@ -49,8 +56,13 @@
     SetChannel(hz);
     set_tx_dbm(dbm);
 
-    if (timeout_us != 0)
+    if (timeout_us != 0) {
+#if (MBED_MAJOR_VERSION < 6)
         TxTimeoutEvent.attach_us(SX1272OnTimeoutIrq, timeout_us);
+#else
+        TxTimeoutEvent.attach(SX1272OnTimeoutIrq, microseconds(timeout_us));
+#endif
+    }
 
     radio.set_opmode(RF_OPMODE_TRANSMITTER);
 }
@@ -212,11 +224,13 @@
     }
 }
 
-volatile us_timestamp_t Radio::irqAt;
-
 void Radio::dio0isr()
 {
+#if (MBED_MAJOR_VERSION < 6)
     irqAt = lpt.read_us();
+#else
+    irqAt = LowPowerClock::now();
+#endif
 
     if (RadioEvents->DioPin_top_half)
         RadioEvents->DioPin_top_half();
@@ -285,18 +299,34 @@
         int rssi;
         us_timestamp_t startAt, chFreeAt, now;
         lora.start_rx(RF_OPMODE_RECEIVER);
+    #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;
             }
             rssi = lora.get_current_rssi();
         } 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
             rssi = lora.get_current_rssi();
             if (rssi > rssiThresh) {
                 goto Lstart;