From 5bfc58ed641e637bc5e539c437229eb4535368a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20G=C3=B6ttgens?= Date: Tue, 15 Nov 2022 21:55:27 +0100 Subject: [PATCH 1/3] testing issues with RAK11200/13300 --- src/mesh/SX126xInterface.cpp | 22 +++++++++++++--------- variants/rak11200/variant.h | 22 +++++++++++----------- 2 files changed, 24 insertions(+), 20 deletions(-) diff --git a/src/mesh/SX126xInterface.cpp b/src/mesh/SX126xInterface.cpp index 64758cd0d..cfb97e673 100644 --- a/src/mesh/SX126xInterface.cpp +++ b/src/mesh/SX126xInterface.cpp @@ -25,11 +25,11 @@ bool SX126xInterface::init() pinMode(SX126X_POWER_EN, OUTPUT); #endif -#ifdef SX126X_RXEN // set not rx or tx mode +#if defined(SX126X_RXEN) && (SX126X_RXEN != RADIOLIB_NC) // set not rx or tx mode digitalWrite(SX126X_RXEN, LOW); // Set low before becoming an output pinMode(SX126X_RXEN, OUTPUT); #endif -#ifdef SX126X_TXEN +#if defined(SX126X_TXEN) && (SX126X_TXEN != RADIOLIB_NC) digitalWrite(SX126X_TXEN, LOW); pinMode(SX126X_TXEN, OUTPUT); #endif @@ -66,7 +66,7 @@ bool SX126xInterface::init() DEBUG_MSG("Current limit set to %f\n", currentLimit); DEBUG_MSG("Current limit set result %d\n", res); -#ifdef SX126X_TXEN +#if defined(SX126X_TXEN) && (SX126X_TXEN != RADIOLIB_NC) // lora.begin sets Dio2 as RF switch control, which is not true if we are manually controlling RX and TX if (res == RADIOLIB_ERR_NONE) res = lora.setDio2AsRfSwitch(true); @@ -166,12 +166,16 @@ void SX126xInterface::setStandby() checkNotification(); // handle any pending interrupts before we force standby int err = lora.standby(); + + if (err != RADIOLIB_ERR_NONE) + DEBUG_MSG("SX126x standby failed with error %d\n", err); + assert(err == RADIOLIB_ERR_NONE); -#ifdef SX126X_RXEN // we have RXEN/TXEN control - turn off RX and TX power +#if defined(SX126X_RXEN) && (SX126X_RXEN != RADIOLIB_NC) // we have RXEN/TXEN control - turn off RX and TX power digitalWrite(SX126X_RXEN, LOW); #endif -#ifdef SX126X_TXEN +#if defined(SX126X_TXEN) && (SX126X_TXEN != RADIOLIB_NC) digitalWrite(SX126X_TXEN, LOW); #endif @@ -196,10 +200,10 @@ void SX126xInterface::addReceiveMetadata(MeshPacket *mp) template void SX126xInterface::configHardwareForSend() { -#ifdef SX126X_TXEN // we have RXEN/TXEN control - turn on TX power / off RX power +#if defined(SX126X_TXEN) && (SX126X_TXEN != RADIOLIB_NC) // we have RXEN/TXEN control - turn on TX power / off RX power digitalWrite(SX126X_TXEN, HIGH); #endif -#ifdef SX126X_RXEN +#if defined(SX126X_RXEN) && (SX126X_RXEN != RADIOLIB_NC) digitalWrite(SX126X_RXEN, LOW); #endif @@ -218,10 +222,10 @@ void SX126xInterface::startReceive() setStandby(); -#ifdef SX126X_RXEN // we have RXEN/TXEN control - turn on RX power / off TX power +#if defined(SX126X_RXEN) && (SX126X_RXEN != RADIOLIB_NC) // we have RXEN/TXEN control - turn on RX power / off TX power digitalWrite(SX126X_RXEN, HIGH); #endif -#ifdef SX126X_TXEN +#if defined(SX126X_TXEN) && (SX126X_TXEN != RADIOLIB_NC) digitalWrite(SX126X_TXEN, LOW); #endif diff --git a/variants/rak11200/variant.h b/variants/rak11200/variant.h index 0962d4f45..4a8bf0a57 100644 --- a/variants/rak11200/variant.h +++ b/variants/rak11200/variant.h @@ -59,11 +59,11 @@ static const uint8_t SCK = 33; // https://docs.rakwireless.com/Product-Categories/WisBlock/RAK13300/ -#define LORA_DIO0 -1 // a No connect on the SX1262/SX1268 module -#define LORA_RESET WB_IO4 // RST for SX1276, and for SX1262/SX1268 -#define LORA_DIO1 WB_IO6 // IRQ for SX1262/SX1268 -#define LORA_DIO2 WB_IO5 // BUSY for SX1262/SX1268 -#define LORA_DIO3 // Not connected on PCB, but internally on the TTGO SX1262/SX1268, if DIO3 is high the TXCO is enabled +#define LORA_DIO0 RADIOLIB_NC // a No connect on the SX1262/SX1268 module +#define LORA_RESET WB_IO4 // RST for SX1276, and for SX1262/SX1268 +#define LORA_DIO1 WB_IO6 // IRQ for SX1262/SX1268 +#define LORA_DIO2 WB_IO5 // BUSY for SX1262/SX1268 +#define LORA_DIO3 RADIOLIB_NC // Not connected on PCB, but internally on the TTGO SX1262/SX1268, if DIO3 is high the TXCO is enabled #undef RF95_SCK #define RF95_SCK SCK @@ -75,10 +75,10 @@ static const uint8_t SCK = 33; #define RF95_NSS SS #define USE_SX1262 -#define SX126X_CS (SS)// NSS for SX126X -#define SX126X_DIO1 (LORA_DIO1) -#define SX126X_BUSY (LORA_DIO2) -#define SX126X_RESET (LORA_RESET) -#define SX126X_TXEN (-1) -#define SX126X_RXEN (WB_IO3) +#define SX126X_CS SS// NSS for SX126X +#define SX126X_DIO1 LORA_DIO1 +#define SX126X_BUSY LORA_DIO2 +#define SX126X_RESET LORA_RESET +#define SX126X_TXEN RADIOLIB_NC +#define SX126X_RXEN WB_IO3 #define SX126X_E22 // DIO2 controlls an antenna switch and the TCXO voltage is controlled by DIO3 From 28b428c5a0bd7574cb0eb3e63d345ca1efab9ad2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20G=C3=B6ttgens?= Date: Tue, 15 Nov 2022 22:54:31 +0100 Subject: [PATCH 2/3] potential fix for 13300 --- variants/rak11200/variant.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/variants/rak11200/variant.h b/variants/rak11200/variant.h index 4a8bf0a57..569f8f9de 100644 --- a/variants/rak11200/variant.h +++ b/variants/rak11200/variant.h @@ -79,6 +79,5 @@ static const uint8_t SCK = 33; #define SX126X_DIO1 LORA_DIO1 #define SX126X_BUSY LORA_DIO2 #define SX126X_RESET LORA_RESET -#define SX126X_TXEN RADIOLIB_NC -#define SX126X_RXEN WB_IO3 +#define SX126X_POWER_EN WB_IO3 #define SX126X_E22 // DIO2 controlls an antenna switch and the TCXO voltage is controlled by DIO3 From b23c364fc013c391822c9ff7c2eaf54037230cf2 Mon Sep 17 00:00:00 2001 From: Ben Meadors Date: Tue, 15 Nov 2022 16:22:53 -0600 Subject: [PATCH 3/3] Test it this way --- variants/rak11200/variant.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/variants/rak11200/variant.h b/variants/rak11200/variant.h index 4a8bf0a57..569f8f9de 100644 --- a/variants/rak11200/variant.h +++ b/variants/rak11200/variant.h @@ -79,6 +79,5 @@ static const uint8_t SCK = 33; #define SX126X_DIO1 LORA_DIO1 #define SX126X_BUSY LORA_DIO2 #define SX126X_RESET LORA_RESET -#define SX126X_TXEN RADIOLIB_NC -#define SX126X_RXEN WB_IO3 +#define SX126X_POWER_EN WB_IO3 #define SX126X_E22 // DIO2 controlls an antenna switch and the TCXO voltage is controlled by DIO3