]> git.tnoah.ca Git - lora-radio.git/commitdiff
Add new modem TX IRQ handling
authorjacob.eva <x00010@disroot.org>
Tue, 11 Feb 2025 18:24:13 +0000 (18:24 +0000)
committerjacob.eva <x00010@disroot.org>
Tue, 11 Feb 2025 18:24:13 +0000 (18:24 +0000)
RNode_Firmware_CE.ino
src/misc/ModemISR.h [new file with mode: 0644]

index f32ae50e6a41f746728a351c796563a23ac815b4..1904e87d62635ccd60e9097094e132ce63aec6bc 100644 (file)
@@ -66,6 +66,9 @@ volatile uint16_t queued_bytes[INTERFACE_COUNT] = {0};
 volatile uint16_t queue_cursor[INTERFACE_COUNT] = {0};
 volatile uint16_t current_packet_start[INTERFACE_COUNT] = {0};
 volatile bool serial_buffering = false;
+
+extern void setup_interfaces(); // from /src/misc/ModemISR.h
+
 #if HAS_BLUETOOTH || HAS_BLE == true
   bool bt_init_ran = false;
 #endif
diff --git a/src/misc/ModemISR.h b/src/misc/ModemISR.h
new file mode 100644 (file)
index 0000000..5f1f374
--- /dev/null
@@ -0,0 +1,45 @@
+extern RadioInterface* interface_obj[INTERFACE_COUNT];
+void (*onIntRise[INTERFACE_COUNT]) (void);
+
+#if INTERFACE_COUNT == 1
+void onInt0Rise() {
+    if (interfaces[0] == SX1280) {
+        // On the SX1280, there is a bug which can cause the busy line
+        // to remain high if a high amount of packets are received when
+        // in continuous RX mode. This is documented as Errata 16.1 in
+        // the SX1280 datasheet v3.2 (page 149)
+        // Therefore, the modem is set into receive mode each time a packet is received.
+        interface_obj[0]->receive();
+    }
+    if (interface_obj[0]->getPacketValidity()) {
+        interface_obj[0]->handleDio0Rise();
+    }
+}
+
+void setup_interfaces() {
+    onIntRise[0] = onInt0Rise;
+}
+#elif BOARD_MODEL == BOARD_RAK4631 || BOARD_MODEL == BOARD_OPENCOM_XL
+void onInt0Rise() {
+    if (interface_obj[0]->getPacketValidity()) {
+        interface_obj[0]->handleDio0Rise();
+    }
+}
+
+void onInt1Rise() {
+    // On the SX1280, there is a bug which can cause the busy line
+    // to remain high if a high amount of packets are received when
+    // in continuous RX mode. This is documented as Errata 16.1 in
+    // the SX1280 datasheet v3.2 (page 149)
+    // Therefore, the modem is set into receive mode each time a packet is received.
+    interface_obj[1]->receive();
+    if (interface_obj[1]->getPacketValidity()) {
+        interface_obj[1]->handleDio0Rise();
+    }
+}
+
+void setup_interfaces() {
+    onIntRise[0] = &onInt0Rise;
+    onIntRise[1] = &onInt1Rise;
+}
+#endif