From 5afa92395dedb87649a755d1a7f87ec29ec50af4 Mon Sep 17 00:00:00 2001 From: Ben Meadors Date: Tue, 2 May 2023 15:04:23 -0500 Subject: [PATCH 1/5] Disable TX/RX EN in favor of power EN over TX_EN --- variants/diy/v1/variant.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/variants/diy/v1/variant.h b/variants/diy/v1/variant.h index 541edfa9..9ef2153b 100644 --- a/variants/diy/v1/variant.h +++ b/variants/diy/v1/variant.h @@ -38,8 +38,10 @@ #define SX126X_DIO1 LORA_DIO1 #define SX126X_BUSY LORA_DIO2 #define SX126X_RESET LORA_RESET -#define SX126X_RXEN 14 -#define SX126X_TXEN 13 +//#define SX126X_RXEN 14 +//#define SX126X_TXEN 13 +#define SX126X_POWER_EN (13) +#define SX126X_E22 // RX/TX for RFM95/SX127x #define RF95_RXEN 14 From 6aa9e3787237e0178c7e2d9416078fa6b84fd6e9 Mon Sep 17 00:00:00 2001 From: Ben Meadors Date: Tue, 2 May 2023 15:05:23 -0500 Subject: [PATCH 2/5] Oops --- variants/diy/v1/variant.h | 1 - 1 file changed, 1 deletion(-) diff --git a/variants/diy/v1/variant.h b/variants/diy/v1/variant.h index 9ef2153b..da9e4155 100644 --- a/variants/diy/v1/variant.h +++ b/variants/diy/v1/variant.h @@ -41,7 +41,6 @@ //#define SX126X_RXEN 14 //#define SX126X_TXEN 13 #define SX126X_POWER_EN (13) -#define SX126X_E22 // RX/TX for RFM95/SX127x #define RF95_RXEN 14 From 75504793e84f760c3c10a313d93d6ab8fe89d302 Mon Sep 17 00:00:00 2001 From: Ben Meadors Date: Thu, 11 May 2023 06:52:27 -0500 Subject: [PATCH 3/5] Skip setting dio2 as rf switch altogether if txen is defined --- src/mesh/SX126xInterface.cpp | 15 ++++++++------- variants/diy/v1/variant.h | 6 +++--- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/src/mesh/SX126xInterface.cpp b/src/mesh/SX126xInterface.cpp index c26b773f..a6a4e9dc 100644 --- a/src/mesh/SX126xInterface.cpp +++ b/src/mesh/SX126xInterface.cpp @@ -60,19 +60,20 @@ template bool SX126xInterface::init() LOG_DEBUG("Current limit set to %f\n", currentLimit); LOG_DEBUG("Current limit set result %d\n", res); -#ifdef SX126X_E22 - // E22 Emulation explicitly requires DIO2 as RF switch, so set it to TRUE again for good measure. In case somebody defines - // SX126X_TX for an E22 Module - if (res == RADIOLIB_ERR_NONE) - res = lora.setDio2AsRfSwitch(true); -#endif - #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) { + LOG_DEBUG("SX126X_TX/RX EN pins defined. Setting RF Switch: RXEN=%i, TXEN=%i\n", SX126X_RXEN, SX126X_TXEN); res = lora.setDio2AsRfSwitch(false); lora.setRfSwitchPins(SX126X_RXEN, SX126X_TXEN); } +#elif defined(SX126X_E22) + // E22 Emulation explicitly requires DIO2 as RF switch, so set it to TRUE again for good measure. In case somebody defines + // SX126X_TX for an E22 Module + if (res == RADIOLIB_ERR_NONE) { + LOG_DEBUG("SX126X_E22 mode enabled. Setting DIO2 as RF Switch\n"); + res = lora.setDio2AsRfSwitch(true); + } #endif if (config.lora.sx126x_rx_boosted_gain) { diff --git a/variants/diy/v1/variant.h b/variants/diy/v1/variant.h index da9e4155..51bc0f74 100644 --- a/variants/diy/v1/variant.h +++ b/variants/diy/v1/variant.h @@ -38,9 +38,9 @@ #define SX126X_DIO1 LORA_DIO1 #define SX126X_BUSY LORA_DIO2 #define SX126X_RESET LORA_RESET -//#define SX126X_RXEN 14 -//#define SX126X_TXEN 13 -#define SX126X_POWER_EN (13) +#define SX126X_RXEN 14 +#define SX126X_TXEN 13 +//#define SX126X_POWER_EN (13) // RX/TX for RFM95/SX127x #define RF95_RXEN 14 From f7e1f4cea664e35c43c345d9113060088913c05f Mon Sep 17 00:00:00 2001 From: Ben Meadors Date: Thu, 11 May 2023 19:56:55 -0500 Subject: [PATCH 4/5] Fix hydra (for real this time) --- variants/diy/v1/variant.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/variants/diy/v1/variant.h b/variants/diy/v1/variant.h index 51bc0f74..c4743764 100644 --- a/variants/diy/v1/variant.h +++ b/variants/diy/v1/variant.h @@ -38,9 +38,8 @@ #define SX126X_DIO1 LORA_DIO1 #define SX126X_BUSY LORA_DIO2 #define SX126X_RESET LORA_RESET -#define SX126X_RXEN 14 +#define SX126X_RXEN RADIOLIB_NC // Defining the RXEN ruins RFSwitching for the E22 900M30S in RadioLib #define SX126X_TXEN 13 -//#define SX126X_POWER_EN (13) // RX/TX for RFM95/SX127x #define RF95_RXEN 14 From 6cdf2817f43c345455fc083d1feef73cf56ac83c Mon Sep 17 00:00:00 2001 From: Ben Meadors Date: Thu, 11 May 2023 20:09:34 -0500 Subject: [PATCH 5/5] Put this back in place --- src/mesh/SX126xInterface.cpp | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/mesh/SX126xInterface.cpp b/src/mesh/SX126xInterface.cpp index a6a4e9dc..5305adfe 100644 --- a/src/mesh/SX126xInterface.cpp +++ b/src/mesh/SX126xInterface.cpp @@ -60,6 +60,15 @@ template bool SX126xInterface::init() LOG_DEBUG("Current limit set to %f\n", currentLimit); LOG_DEBUG("Current limit set result %d\n", res); +#if defined(SX126X_E22) + // E22 Emulation explicitly requires DIO2 as RF switch, so set it to TRUE again for good measure. In case somebody defines + // SX126X_TX for an E22 Module + if (res == RADIOLIB_ERR_NONE) { + LOG_DEBUG("SX126X_E22 mode enabled. Setting DIO2 as RF Switch\n"); + res = lora.setDio2AsRfSwitch(true); + } +#endif + #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) { @@ -67,13 +76,6 @@ template bool SX126xInterface::init() res = lora.setDio2AsRfSwitch(false); lora.setRfSwitchPins(SX126X_RXEN, SX126X_TXEN); } -#elif defined(SX126X_E22) - // E22 Emulation explicitly requires DIO2 as RF switch, so set it to TRUE again for good measure. In case somebody defines - // SX126X_TX for an E22 Module - if (res == RADIOLIB_ERR_NONE) { - LOG_DEBUG("SX126X_E22 mode enabled. Setting DIO2 as RF Switch\n"); - res = lora.setDio2AsRfSwitch(true); - } #endif if (config.lora.sx126x_rx_boosted_gain) {