From a1793043b2158c2e524855e0fef0e4269b063f2c Mon Sep 17 00:00:00 2001 From: "jacob.eva" Date: Sat, 10 Feb 2024 11:56:58 +0000 Subject: [PATCH] Remove old debug code and add waitOnBusy timeout to SX1262 --- sx126x.cpp | 4 ++++ sx128x.cpp | 8 +------- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/sx126x.cpp b/sx126x.cpp index f6ac76e..4324e69 100644 --- a/sx126x.cpp +++ b/sx126x.cpp @@ -190,9 +190,13 @@ void sx126x::loraMode() { } void sx126x::waitOnBusy() { + unsigned long time = millis(); if (_busy != -1) { while (digitalRead(_busy) == HIGH) { + if (millis() >= (time + 100)) { + break; + } // do nothing } } diff --git a/sx128x.cpp b/sx128x.cpp index baa1f31..17e0775 100644 --- a/sx128x.cpp +++ b/sx128x.cpp @@ -204,9 +204,7 @@ void sx128x::waitOnBusy() { if (_busy != -1) { while (digitalRead(_busy) == HIGH) { - if (millis() >= (time + 300)) { - pinMode(LED_BLUE, OUTPUT); - digitalWrite(LED_BLUE, HIGH); + if (millis() >= (time + 100)) { break; } // do nothing @@ -458,7 +456,6 @@ uint8_t sx128x::modemStatus() { // imitate the register status from the sx1276 / 78 uint8_t buf[2] = {0}; - // debug executeOpcodeRead(OP_GET_IRQ_STATUS_8X, buf, 2); uint8_t clearbuf[2] = {0}; @@ -468,18 +465,15 @@ uint8_t sx128x::modemStatus() { if (buf[0] & IRQ_PREAMBLE_DET_MASK_8X != 0) { byte = byte | 0x01 | 0x04; // clear register after reading - //clearbuf[0] = IRQ_PREAMBLE_DET_MASK_8X; clearbuf[0] = 0xFF; } if (buf[1] & IRQ_HEADER_DET_MASK_8X != 0) { byte = byte | 0x02 | 0x04; // clear register after reading - //clearbuf[1] = IRQ_HEADER_DET_MASK_8X; clearbuf[1] = 0xFF; } - // debug executeOpcode(OP_CLEAR_IRQ_STATUS_8X, clearbuf, 2); return byte;