mirror of
https://github.com/meshcore-dev/MeshCore.git
synced 2026-04-20 22:13:47 +00:00
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
55 lines
1.6 KiB
C++
55 lines
1.6 KiB
C++
#include <Arduino.h>
|
|
#include <Wire.h>
|
|
|
|
#include "RAK3401Board.h"
|
|
|
|
void RAK3401Board::begin() {
|
|
NRF52BoardDCDC::begin();
|
|
pinMode(PIN_VBAT_READ, INPUT);
|
|
#ifdef PIN_USER_BTN
|
|
pinMode(PIN_USER_BTN, INPUT_PULLUP);
|
|
#endif
|
|
|
|
#ifdef PIN_USER_BTN_ANA
|
|
pinMode(PIN_USER_BTN_ANA, INPUT_PULLUP);
|
|
#endif
|
|
|
|
#if defined(PIN_BOARD_SDA) && defined(PIN_BOARD_SCL)
|
|
Wire.setPins(PIN_BOARD_SDA, PIN_BOARD_SCL);
|
|
#endif
|
|
|
|
Wire.begin();
|
|
|
|
pinMode(PIN_3V3_EN, OUTPUT);
|
|
digitalWrite(PIN_3V3_EN, HIGH);
|
|
|
|
// 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); // 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
|