From 9fe3559e142a115d1d58501d0a78b02fc82602fd Mon Sep 17 00:00:00 2001 From: Henry Potgieter Date: Mon, 30 Mar 2026 00:36:09 -0400 Subject: [PATCH] Throw in changes based on meshtastic's support of the v4.3 board --- Boards.h | 6 +++--- RNode_Firmware.ino | 6 +++++- sx126x.cpp | 54 ++++++++++++++++++++++------------------------ 3 files changed, 34 insertions(+), 32 deletions(-) diff --git a/Boards.h b/Boards.h index 1e9cf42..9d69bf6 100644 --- a/Boards.h +++ b/Boards.h @@ -422,14 +422,14 @@ #define LORA_LNA_GAIN 17 #define LORA_LNA_GVT 12 - #define LORA_PA_GC1109 true + #define LORA_PA_KCT8103L true #define LORA_PA_PWR_EN 7 #define LORA_PA_CSD 2 - #define LORA_PA_CPS 46 + #define LORA_PA_CTX 5 #define PA_MAX_OUTPUT 28 #define PA_GAIN_POINTS 22 - #define PA_GAIN_VALUES 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 10, 10, 9, 9, 8, 7 + #define PA_GAIN_VALUES 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 12, 12, 11, 11, 10, 9, 8, 7 const int pin_cs = 8; const int pin_busy = 13; diff --git a/RNode_Firmware.ino b/RNode_Firmware.ino index 5649206..1f13040 100644 --- a/RNode_Firmware.ino +++ b/RNode_Firmware.ino @@ -1767,7 +1767,11 @@ void sleep_now() { #endif #endif #if BOARD_MODEL == BOARD_HELTEC32_V4 - digitalWrite(LORA_PA_CPS, LOW); + #if LORA_PA_KCT8103L + digitalWrite(LORA_PA_CTX, LOW); + #elif LORA_PA_GC1109 + digitalWrite(LORA_PA_CPS, LOW); + #endif digitalWrite(LORA_PA_CSD, LOW); digitalWrite(LORA_PA_PWR_EN, LOW); digitalWrite(Vext, HIGH); diff --git a/sx126x.cpp b/sx126x.cpp index c67a4df..ddb7c07 100644 --- a/sx126x.cpp +++ b/sx126x.cpp @@ -343,7 +343,21 @@ int sx126x::begin(long frequency) { setPacketParams(_preambleLength, _implicitHeaderMode, _payloadLength, _crcMode); #if HAS_LORA_PA - #if LORA_PA_GC1109 + #if LORA_PA_KCT8103L + // Enable Vfem_ctl for supply to PA power net. + pinMode(LORA_PA_PWR_EN, OUTPUT); + digitalWrite(LORA_PA_PWR_EN, HIGH); + + // Enable KCT8103L: CSD=HIGH activates the chip. + pinMode(LORA_PA_CSD, OUTPUT); + digitalWrite(LORA_PA_CSD, HIGH); + + // CTX=LOW selects LNA/RX mode by default. + // CTX=HIGH switches to PA/TX mode. + // Must be toggled on each TX/RX transition. + pinMode(LORA_PA_CTX, OUTPUT); + digitalWrite(LORA_PA_CTX, LOW); + #elif LORA_PA_GC1109 // Enable Vfem_ctl for supply to // PA power net. pinMode(LORA_PA_PWR_EN, OUTPUT); @@ -353,21 +367,9 @@ int sx126x::begin(long frequency) { pinMode(LORA_PA_CSD, OUTPUT); digitalWrite(LORA_PA_CSD, HIGH); - // Keep PA CPS low until actual - // transmit. Does it save power? - // Who knows? Will have to measure. - // Note from the future: Nope. - // Power consumption is the same, - // and turning it on and off is - // not something that it likes. - // Keeping it high for now. + // Keep PA CPS high permanently. pinMode(LORA_PA_CPS, OUTPUT); digitalWrite(LORA_PA_CPS, HIGH); - - // On Heltec V4, the PA CTX pin - // is driven by the SX1262 DIO2 - // pin directly, so we do not - // need to manually raise this. #endif #endif @@ -378,12 +380,11 @@ void sx126x::end() { sleep(); SPI.end(); _preinit_done = false; } int sx126x::beginPacket(int implicitHeader) { #if HAS_LORA_PA - #if LORA_PA_GC1109 - // Enable PA CPS for transmit - // digitalWrite(LORA_PA_CPS, HIGH); - // Disabled since we're keeping it - // on permanently as long as the - // radio is powered up. + #if LORA_PA_KCT8103L + // CTX=HIGH: switch KCT8103L to PA/TX mode. + digitalWrite(LORA_PA_CTX, HIGH); + #elif LORA_PA_GC1109 + // CPS kept HIGH permanently, no action needed. #endif #endif @@ -595,14 +596,11 @@ void sx126x::onReceive(void(*callback)(int)){ void sx126x::receive(int size) { #if HAS_LORA_PA - #if LORA_PA_GC1109 - // Disable PA CPS for receive - // digitalWrite(LORA_PA_CPS, LOW); - // That turned out to be a bad idea. - // The LNA goes wonky if it's toggled - // on and off too quickly. We'll keep - // it on permanently, as long as the - // radio is powered up. + #if LORA_PA_KCT8103L + // CTX=LOW: switch KCT8103L to LNA/RX mode. + digitalWrite(LORA_PA_CTX, LOW); + #elif LORA_PA_GC1109 + // CPS kept HIGH permanently, no action needed. #endif #endif