Skip to content

Commit 5a33bae

Browse files
author
Wessel Nieboer
committed
Fix RAK13302 1W FEM control: drive SKY66122-11 CSD/CPS/CTX directly
The RAK13302's SKY66122-11 FEM has three control pins (CSD, CPS, CTX) that must be actively driven by the MCU. The existing code only managed CPS via SX126X_POWER_EN and relied on DIO2 for TX/RX switching, but R25 (DIO2→CTX) is NC by default, leaving CSD floating and CTX undriven. This put the FEM in an undefined state — the PA wouldn't reliably engage during TX and the 16 dB RX LNA was never active. Add USE_SKY66122_FEM support (following the existing USE_GC1109_PA pattern) to explicitly initialize, sleep, and toggle all three FEM pins for correct TX/RX/shutdown modes.
1 parent 58496e5 commit 5a33bae

2 files changed

Lines changed: 43 additions & 3 deletions

File tree

src/mesh/SX126xInterface.cpp

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,18 @@ template <typename T> bool SX126xInterface<T>::init()
9393
digitalWrite(LORA_PA_TX_EN, LOW); // Start in RX-ready state
9494
#endif
9595

96+
#if defined(USE_SKY66122_FEM)
97+
// SKY66122-11 FEM initialization — start in RX mode, boost off
98+
// See variant.h for full pin mapping and control logic documentation
99+
pinMode(SKY66122_CSD, OUTPUT);
100+
digitalWrite(SKY66122_CSD, HIGH); // Enable FEM
101+
pinMode(SKY66122_CPS, OUTPUT);
102+
digitalWrite(SKY66122_CPS, HIGH); // Active path (required for both TX and RX)
103+
pinMode(SKY66122_CTX, OUTPUT);
104+
digitalWrite(SKY66122_CTX, LOW); // Boost off, RX mode
105+
delay(1); // Settling time
106+
#endif
107+
96108
#ifdef RF95_FAN_EN
97109
digitalWrite(RF95_FAN_EN, HIGH);
98110
pinMode(RF95_FAN_EN, OUTPUT);
@@ -431,6 +443,13 @@ template <typename T> bool SX126xInterface<T>::sleep()
431443
digitalWrite(LORA_PA_EN, LOW);
432444
digitalWrite(LORA_PA_TX_EN, LOW);
433445
#endif
446+
447+
#if defined(USE_SKY66122_FEM)
448+
// Full shutdown — all pins LOW, FEM draws <1 μA
449+
digitalWrite(SKY66122_CTX, LOW);
450+
digitalWrite(SKY66122_CPS, LOW);
451+
digitalWrite(SKY66122_CSD, LOW);
452+
#endif
434453
return true;
435454
}
436455

@@ -489,14 +508,20 @@ template <typename T> void SX126xInterface<T>::resetAGC()
489508
startReceive();
490509
}
491510

492-
/** Control PA mode for GC1109 FEM - CPS pin selects full PA (txon=true) or bypass mode (txon=false) */
511+
/** Control PA mode for GC1109 / SKY66122 FEM - selects TX path (txon=true) or RX path (txon=false) */
493512
template <typename T> void SX126xInterface<T>::setTransmitEnable(bool txon)
494513
{
495514
#if defined(USE_GC1109_PA)
496515
digitalWrite(LORA_PA_POWER, HIGH); // Ensure LDO is on
497516
digitalWrite(LORA_PA_EN, HIGH); // CSD=1: Chip enabled
498517
digitalWrite(LORA_PA_TX_EN, txon ? 1 : 0); // CPS: 1=full PA, 0=bypass (for RX, CPS is don't care)
499518
#endif
519+
520+
#if defined(USE_SKY66122_FEM)
521+
digitalWrite(SKY66122_CSD, HIGH); // Ensure FEM is enabled
522+
digitalWrite(SKY66122_CPS, HIGH); // Enable active mode (TX and RX)
523+
digitalWrite(SKY66122_CTX, txon ? 1 : 0); // HIGH=TX (boost on, PA), LOW=RX (boost off, LNA)
524+
#endif
500525
}
501526

502527
#endif

variants/nrf52840/rak3401_1watt/variant.h

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -164,8 +164,23 @@ static const uint8_t SCK = PIN_SPI_SCK;
164164
#define SX126X_BUSY (9)
165165
#define SX126X_RESET (4)
166166

167-
#define SX126X_POWER_EN (21)
168-
// DIO2 controlls an antenna switch and the TCXO voltage is controlled by DIO3
167+
/*
168+
* SKY66122-11 Front-End Module control (RAK13302 1W module)
169+
*
170+
* CSD (P0.24) — Chip enable: HIGH to power up the FEM, LOW for shutdown (<1 μA)
171+
* CPS (P0.21) — Path select: HIGH = active (required for TX and RX), LOW = shutdown
172+
* CTX (P0.31) — TX/RX select + 5 V boost enable:
173+
* HIGH = TX mode (boost on, PA energized at 5 V)
174+
* LOW = RX mode (boost off, LNA on 3.3 V)
175+
*
176+
* R25 (DIO2→CTX) is NC by default on the RAK13302, so the MCU must drive CTX directly.
177+
*/
178+
#define USE_SKY66122_FEM
179+
#define SKY66122_CSD (24)
180+
#define SKY66122_CPS (21)
181+
#define SKY66122_CTX (31)
182+
183+
// DIO2 configures the SX1262 internal RF switch (harmless with R25 NC)
169184
#define SX126X_DIO2_AS_RF_SWITCH
170185
#define SX126X_DIO3_TCXO_VOLTAGE 1.8
171186

0 commit comments

Comments
 (0)