1

Revision:
21:96db08266089
Parent:
17:5f34cbe2ac53
--- a/radio_lr1110.cpp	Fri Jul 10 10:52:39 2020 -0700
+++ b/radio_lr1110.cpp	Fri Feb 05 16:35:05 2021 -0800
@@ -188,6 +188,13 @@
     }
 }
 
+bool Radio::init_irq;
+void Radio::my_irq_handler()
+{
+    /* radio irq immediately after hardware reset: hf_xosc start due to TCXO */
+    init_irq = true;
+}
+
 void Radio::dio9_top_half()
 {
     irqAt = lpt.read_us();
@@ -228,6 +235,7 @@
 
 void Radio::Init(const RadioEvents_t* e, unsigned spi_hz)
 {
+    uint64_t a, b;
     /* initialize payload length to zero in packet params */
     lora_pp_buf[3] = 0;
     gfsk_pp_buf[6] = 0;
@@ -236,14 +244,26 @@
     radio.rxDone = rx_done;
     radio.timeout = timeout_callback;
     //radio.chipModeChange = chipModeChange;
-    radio.dio9_topHalf = dio9_top_half;
 
     RadioEvents = e;
     lpt.start();
 
     spi.frequency(spi_hz);
 
+    radio.dio9_topHalf = my_irq_handler;
+    init_irq = false;
     radio.hw_reset();
+    a = Kernel::get_ms_count();
+    do {
+        b = Kernel::get_ms_count();
+        /* wait for radio interrupt at hardware reset, failure to start hf_xosc */
+        if (init_irq) {
+            radio.service();
+            break;
+        }
+    } while ((b - a) < 30);
+
+    radio.dio9_topHalf = dio9_top_half;
 
     initRfSwDIO();
 }