Fix RAK3401 SKY66122-11 FEM control: enable CSD/CPS for proper PA and LNA operation

The RAK13302 1W module uses a Skyworks SKY66122-11 front-end module with
three digital control pins (CSD, CTX, CPS) that must be actively driven
by the host MCU. The previous code only managed CTX (GPIO 31) — toggling
it for TX/RX — but never initialized CSD (GPIO 24) or CPS (GPIO 21),
leaving them floating with no pull-up/pull-down resistors on the PCB.

With floating CSD and CPS, the SKY66122 was in an undefined operating
mode:
- The 30 dB TX PA may not have been reliably engaging
- The 16 dB RX LNA was never reliably active, degrading receive
sensitivity
This commit is contained in:
Wessel Nieboer 2026-02-25 00:26:38 +01:00
parent 06ab9f7f6b
commit 70f1ad4aeb
No known key found for this signature in database
GPG key ID: 27BB1C3D63DEEFFF
3 changed files with 41 additions and 12 deletions

View file

@ -23,10 +23,33 @@ void RAK3401Board::begin() {
pinMode(PIN_3V3_EN, OUTPUT);
digitalWrite(PIN_3V3_EN, HIGH);
#ifdef P_LORA_PA_EN
// Initialize RAK13302 1W LoRa transceiver module PA control pin
// Initialize SKY66122-11 FEM on the RAK13302 module.
// CSD (P0.24) and CPS (P0.21) must be HIGH for both TX and RX modes.
// CTX (P0.31) selects TX(HIGH) vs RX(LOW) and also enables the 5V boost
// converter that powers the PA section (VCC1/VCC2).
// The LNA section (VSUP1/VCC0) runs on 3.3V and works with boost off.
pinMode(P_LORA_PA_CSD, OUTPUT);
digitalWrite(P_LORA_PA_CSD, HIGH); // CSD=1: enable FEM
pinMode(SX126X_POWER_EN, OUTPUT);
digitalWrite(SX126X_POWER_EN, HIGH); // CPS=1: enable TX/RX paths
pinMode(P_LORA_PA_EN, OUTPUT);
digitalWrite(P_LORA_PA_EN, LOW); // Start with PA disabled
delay(10); // Allow PA module to initialize
digitalWrite(P_LORA_PA_EN, LOW); // CTX=0: RX mode, boost off
delay(1); // SKY66122 turn-on settling time
}
#ifdef NRF52_POWER_MANAGEMENT
void RAK3401Board::initiateShutdown(uint8_t reason) {
// Put SKY66122 in guaranteed <1 uA shutdown (Mode 4: CSD=0, CTX=0, CPS=0)
digitalWrite(P_LORA_PA_EN, LOW); // CTX=0, boost off
digitalWrite(SX126X_POWER_EN, LOW); // CPS=0
digitalWrite(P_LORA_PA_CSD, LOW); // CSD=0
// Disable 3V3 switched peripherals
digitalWrite(PIN_3V3_EN, LOW);
enterSystemOff(reason);
}
#endif
}