Skip to content

Commit e44a9dd

Browse files
committed
Fix pin mapping & TX switch (it's DIO2)
1 parent 91dcbf9 commit e44a9dd

3 files changed

Lines changed: 23 additions & 40 deletions

File tree

variants/rak3401/RAK3401Board.cpp

Lines changed: 12 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -20,37 +20,27 @@ void RAK3401Board::begin() {
2020

2121
Wire.begin();
2222

23+
// PIN_3V3_EN (WB_IO2, P0.34) controls the 3V3_S switched peripheral rail
24+
// AND the 5V boost regulator (U5) on the RAK13302 that powers the SKY66122 PA.
25+
// Must stay HIGH during radio operation — do not toggle for power saving.
2326
pinMode(PIN_3V3_EN, OUTPUT);
2427
digitalWrite(PIN_3V3_EN, HIGH);
2528

26-
// Initialize SKY66122-11 FEM on the RAK13302 module.
27-
// CSD (P0.24) and CPS (P0.21) must be HIGH for both TX and RX modes.
28-
// CTX (P0.31) selects TX(HIGH) vs RX(LOW) and also enables the 5V boost
29-
// converter that powers the PA section (VCC1/VCC2).
30-
// The LNA section (VSUP1/VCC0) runs on 3.3V and works with boost off.
31-
//
32-
// Drive CTX LOW first to prevent transient TX mode (Mode 2) while CSD/CPS
33-
// are being enabled — the RAK13302 has no pull-downs on these pins.
34-
pinMode(P_LORA_PA_EN, OUTPUT);
35-
digitalWrite(P_LORA_PA_EN, LOW); // CTX=0: RX mode, boost off
36-
37-
pinMode(P_LORA_PA_CSD, OUTPUT);
38-
digitalWrite(P_LORA_PA_CSD, HIGH); // CSD=1: enable FEM
39-
29+
// Enable SKY66122-11 FEM on the RAK13302 module.
30+
// CSD and CPS are tied together on the RAK13302 PCB, routed to IO3 (P0.21).
31+
// HIGH = FEM active (LNA for RX, PA path available for TX).
32+
// TX/RX switching (CTX) is handled by SX1262 DIO2 via SetDIO2AsRfSwitchCtrl.
4033
pinMode(SX126X_POWER_EN, OUTPUT);
41-
digitalWrite(SX126X_POWER_EN, HIGH); // CPS=1: enable TX/RX paths
42-
43-
delay(1); // SKY66122 turn-on settling time
34+
digitalWrite(SX126X_POWER_EN, HIGH);
35+
delay(1); // SKY66122 turn-on settling time (tON = 3us typ)
4436
}
4537

4638
#ifdef NRF52_POWER_MANAGEMENT
4739
void RAK3401Board::initiateShutdown(uint8_t reason) {
48-
// Put SKY66122 in guaranteed <1 uA shutdown (Mode 4: CSD=0, CTX=0, CPS=0)
49-
digitalWrite(P_LORA_PA_EN, LOW); // CTX=0, boost off
50-
digitalWrite(SX126X_POWER_EN, LOW); // CPS=0
51-
digitalWrite(P_LORA_PA_CSD, LOW); // CSD=0
40+
// Disable SKY66122 FEM (CSD+CPS LOW = shutdown, <1 uA)
41+
digitalWrite(SX126X_POWER_EN, LOW);
5242

53-
// Disable 3V3 switched peripherals
43+
// Disable 3V3 switched peripherals and 5V boost
5444
digitalWrite(PIN_3V3_EN, LOW);
5545

5646
enterSystemOff(reason);

variants/rak3401/RAK3401Board.h

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -38,14 +38,6 @@ class RAK3401Board : public NRF52BoardDCDC {
3838
return "RAK 3401";
3939
}
4040

41-
// SKY66122 FEM TX/RX switching via CTX pin.
42-
// CTX=HIGH: TX mode + 5V boost ON (PA powered from VCC1/VCC2)
43-
// CTX=LOW: RX mode + 5V boost OFF (LNA powered from VSUP1 at 3.3V)
44-
void onBeforeTransmit() override {
45-
digitalWrite(P_LORA_PA_EN, HIGH); // CTX=1: TX mode, boost on
46-
}
47-
48-
void onAfterTransmit() override {
49-
digitalWrite(P_LORA_PA_EN, LOW); // CTX=0: RX mode, boost off
50-
}
41+
// TX/RX switching is handled by SX1262 DIO2 -> SKY66122 CTX (hardware-timed).
42+
// No onBeforeTransmit/onAfterTransmit overrides needed.
5143
};

variants/rak3401/variant.h

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -147,14 +147,15 @@ static const uint8_t AREF = PIN_AREF;
147147
#define SX126X_BUSY (9)
148148
#define SX126X_RESET (4)
149149

150-
// SKY66122-11 FEM control pins (active HIGH, active LOW = shutdown <1uA)
151-
// CSD+CPS must be HIGH for TX and RX; CTX selects TX(HIGH) vs RX(LOW)
152-
// CTX also enables the 5V boost converter for the PA during TX
153-
#define P_LORA_PA_CSD (24) // P0.24 -> SKY66122 CSD (pin 11) - FEM enable
154-
#define SX126X_POWER_EN (21) // P0.21 -> SKY66122 CPS (pin 1) - path select
155-
#define P_LORA_PA_EN (31) // P0.31 -> SKY66122 CTX (pin 2) - TX/RX + boost EN
156-
157-
// DIO2 has a NC 0R footprint (R25) to CTX; not connected by default
150+
// SKY66122-11 FEM control on the RAK13302 module:
151+
// CSD + CPS are tied together on the PCB, routed to WisBlock IO3 (P0.21).
152+
// Setting IO3 HIGH enables the FEM (LNA for RX, PA path for TX).
153+
// CTX is connected to SX1262 DIO2 — the radio handles TX/RX switching
154+
// in hardware via SetDIO2AsRfSwitchCtrl (microsecond-accurate, no GPIO needed).
155+
// The 5V boost for the PA is enabled by WB_IO2 (P0.34 = PIN_3V3_EN).
156+
#define SX126X_POWER_EN (21) // P0.21 = IO3 -> SKY66122 CSD+CPS (FEM enable)
157+
158+
// CTX is driven by SX1262 DIO2, not a GPIO
158159
#define SX126X_DIO2_AS_RF_SWITCH
159160
#define SX126X_DIO3_TCXO_VOLTAGE 1.8
160161

0 commit comments

Comments
 (0)