Skip to content
Closed
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
11 changes: 11 additions & 0 deletions src/mesh/SX126xInterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
#ifdef ARCH_PORTDUINO
#include "PortduinoGlue.h"
#endif
#if defined(USE_GC1109_PA) && defined(ARCH_ESP32)
#include "esp_sleep.h"
#endif

#include "Throttle.h"

Expand Down Expand Up @@ -60,6 +63,14 @@ template <typename T> bool SX126xInterface<T>::init()
pinMode(LORA_PA_POWER, OUTPUT);
digitalWrite(LORA_PA_POWER, HIGH);

// TLV75733P LDO has ~550us startup time (datasheet tSTR). On cold boot, wait
// for VBAT to stabilise before driving CSD/CPS, per GC1109 requirement:
// "VBAT must be prior to CSD/CPS/CTX for the power on sequence"
// On deep sleep wake the LDO was held on via RTC latch, so no delay needed.
if (esp_sleep_get_wakeup_cause() == ESP_SLEEP_WAKEUP_UNDEFINED) {
delayMicroseconds(1000);
}
Comment on lines +69 to +72
Copy link

Copilot AI Feb 8, 2026

Choose a reason for hiding this comment

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

This code calls esp_sleep_get_wakeup_cause() inside a USE_GC1109_PA-only block, but the header include is guarded by USE_GC1109_PA && ARCH_ESP32. To avoid a compile break if USE_GC1109_PA is ever enabled on a non-ESP32 target, guard the esp_sleep_get_wakeup_cause() usage with ARCH_ESP32 as well (or avoid the ESP32-specific API entirely).

Suggested change
// On deep sleep wake the LDO was held on via RTC latch, so no delay needed.
if (esp_sleep_get_wakeup_cause() == ESP_SLEEP_WAKEUP_UNDEFINED) {
delayMicroseconds(1000);
}
// On deep sleep wake the LDO was held on via RTC latch, so no delay needed.
#if defined(ARCH_ESP32)
if (esp_sleep_get_wakeup_cause() == ESP_SLEEP_WAKEUP_UNDEFINED) {
delayMicroseconds(1000);
}
#else
// On non-ESP32 architectures we cannot query wakeup cause; apply conservative delay.
delayMicroseconds(1000);
#endif

Copilot uses AI. Check for mistakes.

Comment on lines +66 to +73
Copy link

Copilot AI Feb 8, 2026

Choose a reason for hiding this comment

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

The delay is skipped for any deep-sleep wakeup cause, but on ESP32 a deep-sleep wake is a full reset and GPIO output state is typically not held unless explicitly latched (I don’t see LORA_PA_POWER being held in sleep code). That means the LDO will still be enabled immediately before this block, and PA_EN may again be asserted before VBAT is stable. Consider always waiting 1ms here (or only skipping if you can positively confirm the LDO rail is already up), rather than keying off ESP_SLEEP_WAKEUP_UNDEFINED.

Suggested change
// TLV75733P LDO has ~550us startup time (datasheet tSTR). On cold boot, wait
// for VBAT to stabilise before driving CSD/CPS, per GC1109 requirement:
// "VBAT must be prior to CSD/CPS/CTX for the power on sequence"
// On deep sleep wake the LDO was held on via RTC latch, so no delay needed.
if (esp_sleep_get_wakeup_cause() == ESP_SLEEP_WAKEUP_UNDEFINED) {
delayMicroseconds(1000);
}
// TLV75733P LDO has ~550us startup time (datasheet tSTR). Wait for VBAT to
// stabilise before driving CSD/CPS, per GC1109 requirement:
// "VBAT must be prior to CSD/CPS/CTX for the power on sequence"
delayMicroseconds(1000);

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

See #9572, I might just combine these two changes.

// CSD (LORA_PA_EN): Chip enable - must be HIGH to enable GC1109 for both RX and TX
pinMode(LORA_PA_EN, OUTPUT);
digitalWrite(LORA_PA_EN, HIGH);
Expand Down