Skip to content

Commit 876585a

Browse files
weebl2000portablestew
authored andcommitted
Hold GC1109 FEM power during deep sleep for LNA RX wake (meshtastic#9572)
* Hold GC1109 PA_POWER and PA_EN during deep sleep for LNA RX wake Use rtc_gpio_hold_en to latch PA_POWER (LDO) and PA_EN (CSD) HIGH during deep sleep so the GC1109 LNA remains powered for wake-on-packet RX. Previously these pins used weak pull-ups which could lose state. On deep sleep wake, skip these pins in the blanket RTC hold release and instead release them in SX126xInterface::init() after GPIO registers are set HIGH first, avoiding a power glitch on the GC1109. Trade-off: ~6.5mA additional deep sleep current for significantly improved wake-on-packet RX sensitivity (~17dB). Reference: meshcore-dev/MeshCore#1600 * Add LDO startup delay before GC1109 chip enable TLV75733P LDO has ~550us startup time (datasheet tSTR). On cold boot, wait 1ms for VBAT to stabilise before driving CSD/CPS, per GC1109 power-on sequence requirement. On deep sleep wake the LDO is held on via RTC latch so no delay is needed.
1 parent da18243 commit 876585a

2 files changed

Lines changed: 37 additions & 2 deletions

File tree

src/mesh/SX126xInterface.cpp

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@
66
#ifdef ARCH_PORTDUINO
77
#include "PortduinoGlue.h"
88
#endif
9+
#if defined(USE_GC1109_PA) && defined(ARCH_ESP32)
10+
#include <driver/rtc_io.h>
11+
#include <esp_sleep.h>
12+
#endif
913

1014
#include "Throttle.h"
1115

@@ -55,14 +59,33 @@ template <typename T> bool SX126xInterface<T>::init()
5559
#if defined(USE_GC1109_PA)
5660
// GC1109 FEM chip initialization
5761
// See variant.h for full pin mapping and control logic documentation
62+
//
63+
// On deep sleep wake, PA_POWER and PA_EN are held HIGH by RTC latch (set in
64+
// enableLoraInterrupt). We configure GPIO registers before releasing the hold
65+
// so the pad transitions atomically from held-HIGH to register-HIGH with no
66+
// power glitch. On cold boot the hold_dis is a harmless no-op.
5867

5968
// VFEM_Ctrl (LORA_PA_POWER): Power enable for GC1109 LDO (always on)
6069
pinMode(LORA_PA_POWER, OUTPUT);
6170
digitalWrite(LORA_PA_POWER, HIGH);
71+
rtc_gpio_hold_dis((gpio_num_t)LORA_PA_POWER);
72+
73+
// TLV75733P LDO has ~550us startup time (datasheet tSTR). On cold boot, wait
74+
// for VBAT to stabilise before driving CSD/CPS, per GC1109 requirement:
75+
// "VBAT must be prior to CSD/CPS/CTX for the power on sequence"
76+
// On deep sleep wake the LDO was held on via RTC latch, so no delay needed.
77+
#if defined(ARCH_ESP32)
78+
if (esp_sleep_get_wakeup_cause() == ESP_SLEEP_WAKEUP_UNDEFINED) {
79+
delayMicroseconds(1000);
80+
}
81+
#else
82+
delayMicroseconds(1000);
83+
#endif
6284

6385
// CSD (LORA_PA_EN): Chip enable - must be HIGH to enable GC1109 for both RX and TX
6486
pinMode(LORA_PA_EN, OUTPUT);
6587
digitalWrite(LORA_PA_EN, HIGH);
88+
rtc_gpio_hold_dis((gpio_num_t)LORA_PA_EN);
6689

6790
// CPS (LORA_PA_TX_EN): PA mode select - HIGH enables full PA during TX, LOW for RX (don't care)
6891
// Note: TX/RX path switching (CTX) is handled by DIO2 via SX126X_DIO2_AS_RF_SWITCH

src/sleep.cpp

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,13 @@ void initDeepSleep()
162162
if (wakeCause != ESP_SLEEP_WAKEUP_UNDEFINED) {
163163
LOG_DEBUG("Disable any holds on RTC IO pads");
164164
for (uint8_t i = 0; i <= GPIO_NUM_MAX; i++) {
165+
#if defined(USE_GC1109_PA)
166+
// Skip GC1109 FEM power pins - they are held HIGH during deep sleep to keep
167+
// the LNA active for RX wake. Released later in SX126xInterface::init() after
168+
// GPIO registers are set HIGH first, avoiding a power glitch.
169+
if (i == LORA_PA_POWER || i == LORA_PA_EN)
170+
continue;
171+
#endif
165172
if (rtc_gpio_is_valid_gpio((gpio_num_t)i))
166173
rtc_gpio_hold_dis((gpio_num_t)i);
167174

@@ -556,8 +563,13 @@ void enableLoraInterrupt()
556563
#endif
557564

558565
#if defined(USE_GC1109_PA)
559-
gpio_pullup_en((gpio_num_t)LORA_PA_POWER);
560-
gpio_pullup_en((gpio_num_t)LORA_PA_EN);
566+
// Keep GC1109 FEM powered during deep sleep so LNA remains active for RX wake.
567+
// Set PA_POWER and PA_EN HIGH (overrides SX126xInterface::sleep() shutdown),
568+
// then latch with RTC hold so the state survives deep sleep.
569+
digitalWrite(LORA_PA_POWER, HIGH);
570+
rtc_gpio_hold_en((gpio_num_t)LORA_PA_POWER);
571+
digitalWrite(LORA_PA_EN, HIGH);
572+
rtc_gpio_hold_en((gpio_num_t)LORA_PA_EN);
561573
gpio_pulldown_en((gpio_num_t)LORA_PA_TX_EN);
562574
#endif
563575

0 commit comments

Comments
 (0)