Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 31 additions & 5 deletions variants/rak3401/RAK3401Board.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,36 @@ 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.
//
// Drive CTX LOW first to prevent transient TX mode (Mode 2) while CSD/CPS
// are being enabled — the RAK13302 has no pull-downs on these pins.
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

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

delay(1); // SKY66122 turn-on settling time
}

#ifdef NRF52_POWER_MANAGEMENT
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is NRF52_POWER_MANAGEMENT enabled in the build for rak3401?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not currently it seems.

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
}
9 changes: 5 additions & 4 deletions variants/rak3401/RAK3401Board.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,14 @@ class RAK3401Board : public NRF52BoardDCDC {
return "RAK 3401";
}

#ifdef P_LORA_PA_EN
// SKY66122 FEM TX/RX switching via CTX pin.
// CTX=HIGH: TX mode + 5V boost ON (PA powered from VCC1/VCC2)
// CTX=LOW: RX mode + 5V boost OFF (LNA powered from VSUP1 at 3.3V)
void onBeforeTransmit() override {
digitalWrite(P_LORA_PA_EN, HIGH); // Enable PA before transmission
digitalWrite(P_LORA_PA_EN, HIGH); // CTX=1: TX mode, boost on
}

void onAfterTransmit() override {
digitalWrite(P_LORA_PA_EN, LOW); // Disable PA after transmission to save power
digitalWrite(P_LORA_PA_EN, LOW); // CTX=0: RX mode, boost off
}
#endif
};
1 change: 1 addition & 0 deletions variants/rak3401/platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ build_flags = ${nrf52_base.build_flags}
-D LORA_TX_POWER=22
-D SX126X_CURRENT_LIMIT=140
-D SX126X_RX_BOOSTED_GAIN=1
-D SX126X_REGISTER_PATCH=1 ; Patch register 0x8B5 for improved RX with SKY66122 FEM
build_src_filter = ${nrf52_base.build_src_filter}
+<../variants/rak3401>
+<helpers/sensors>
Expand Down
11 changes: 8 additions & 3 deletions variants/rak3401/variant.h
Original file line number Diff line number Diff line change
Expand Up @@ -147,8 +147,14 @@ static const uint8_t AREF = PIN_AREF;
#define SX126X_BUSY (9)
#define SX126X_RESET (4)

#define SX126X_POWER_EN (21)
// DIO2 controlls an antenna switch and the TCXO voltage is controlled by DIO3
// SKY66122-11 FEM control pins (active HIGH, active LOW = shutdown <1uA)
// CSD+CPS must be HIGH for TX and RX; CTX selects TX(HIGH) vs RX(LOW)
// CTX also enables the 5V boost converter for the PA during TX
#define P_LORA_PA_CSD (24) // P0.24 -> SKY66122 CSD (pin 11) - FEM enable
#define SX126X_POWER_EN (21) // P0.21 -> SKY66122 CPS (pin 1) - path select
#define P_LORA_PA_EN (31) // P0.31 -> SKY66122 CTX (pin 2) - TX/RX + boost EN

// DIO2 has a NC 0R footprint (R25) to CTX; not connected by default
#define SX126X_DIO2_AS_RF_SWITCH
#define SX126X_DIO3_TCXO_VOLTAGE 1.8

Expand All @@ -159,7 +165,6 @@ static const uint8_t AREF = PIN_AREF;
#define P_LORA_DIO_1 SX126X_DIO1
#define P_LORA_BUSY SX126X_BUSY
#define P_LORA_RESET SX126X_RESET
#define P_LORA_PA_EN 31

// enables 3.3V periphery like GPS or IO Module
// Do not toggle this for GPS power savings
Expand Down