Skip to content

Commit 67779ad

Browse files
authored
Merge pull request #1600 from weebl2000/heltec_deep_sleep_lna
Hold GC1109 PA_POWER during deep sleep for LNA RX wake
2 parents bbd621b + 2bb6f63 commit 67779ad

3 files changed

Lines changed: 32 additions & 13 deletions

File tree

variants/heltec_tracker_v2/HeltecTrackerV2Board.cpp

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,26 @@ void HeltecTrackerV2Board::begin() {
66
pinMode(PIN_ADC_CTRL, OUTPUT);
77
digitalWrite(PIN_ADC_CTRL, LOW); // Initially inactive
88

9+
// Set up digital GPIO registers before releasing RTC hold. The hold latches
10+
// the pad state including function select, so register writes accumulate
11+
// without affecting the pad. On hold release, all changes apply atomically
12+
// (IO MUX switches to digital GPIO with output already HIGH — no glitch).
913
pinMode(P_LORA_PA_POWER, OUTPUT);
1014
digitalWrite(P_LORA_PA_POWER,HIGH);
15+
rtc_gpio_hold_dis((gpio_num_t)P_LORA_PA_POWER);
1116

12-
rtc_gpio_hold_dis((gpio_num_t)P_LORA_PA_EN);
1317
pinMode(P_LORA_PA_EN, OUTPUT);
1418
digitalWrite(P_LORA_PA_EN,HIGH);
19+
rtc_gpio_hold_dis((gpio_num_t)P_LORA_PA_EN);
1520
pinMode(P_LORA_PA_TX_EN, OUTPUT);
1621
digitalWrite(P_LORA_PA_TX_EN,LOW);
1722

18-
periph_power.begin();
19-
2023
esp_reset_reason_t reason = esp_reset_reason();
24+
if (reason != ESP_RST_DEEPSLEEP) {
25+
delay(1); // GC1109 startup time after cold power-on
26+
}
27+
28+
periph_power.begin();
2129
if (reason == ESP_RST_DEEPSLEEP) {
2230
long wakeup_source = esp_sleep_get_ext1_wakeup_status();
2331
if (wakeup_source & (1 << P_LORA_DIO_1)) { // received a LoRa packet (while in deep sleep)
@@ -48,7 +56,9 @@ void HeltecTrackerV2Board::begin() {
4856

4957
rtc_gpio_hold_en((gpio_num_t)P_LORA_NSS);
5058

51-
rtc_gpio_hold_en((gpio_num_t)P_LORA_PA_EN); //It also needs to be enabled in receive mode
59+
// Hold GC1109 FEM pins during sleep to keep LNA active for RX wake
60+
rtc_gpio_hold_en((gpio_num_t)P_LORA_PA_POWER);
61+
rtc_gpio_hold_en((gpio_num_t)P_LORA_PA_EN);
5262

5363
if (pin_wake_btn < 0) {
5464
esp_sleep_enable_ext1_wakeup( (1L << P_LORA_DIO_1), ESP_EXT1_WAKEUP_ANY_HIGH); // wake up on: recv LoRa packet

variants/heltec_tracker_v2/platformio.ini

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,11 @@ build_flags =
1717
-D P_LORA_SCLK=9
1818
-D P_LORA_MISO=11
1919
-D P_LORA_MOSI=10
20-
-D P_LORA_PA_POWER=7 ;power en
21-
-D P_LORA_PA_EN=4
22-
-D P_LORA_PA_TX_EN=46 ;enable tx
23-
-D LORA_TX_POWER=10 ;If it is configured as 10 here, the final output will be 22 dbm.
24-
-D MAX_LORA_TX_POWER=22 ;Max SX1262 output
20+
-D P_LORA_PA_POWER=7 ; VFEM_Ctrl - GC1109 LDO power enable
21+
-D P_LORA_PA_EN=4 ; CSD - GC1109 chip enable (HIGH=on)
22+
-D P_LORA_PA_TX_EN=46 ; CPS - GC1109 PA mode (HIGH=full PA, LOW=bypass)
23+
-D LORA_TX_POWER=10 ; 10dBm + ~11dB GC1109 gain = ~21dBm output
24+
-D MAX_LORA_TX_POWER=22 ; Max SX1262 output -> ~28dBm at antenna
2525
-D SX126X_DIO2_AS_RF_SWITCH=true
2626
-D SX126X_DIO3_TCXO_VOLTAGE=1.8
2727
-D SX126X_CURRENT_LIMIT=140

variants/heltec_v4/HeltecV4Board.cpp

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,26 @@ void HeltecV4Board::begin() {
77
pinMode(PIN_ADC_CTRL, OUTPUT);
88
digitalWrite(PIN_ADC_CTRL, LOW); // Initially inactive
99

10+
// Set up digital GPIO registers before releasing RTC hold. The hold latches
11+
// the pad state including function select, so register writes accumulate
12+
// without affecting the pad. On hold release, all changes apply atomically
13+
// (IO MUX switches to digital GPIO with output already HIGH — no glitch).
1014
pinMode(P_LORA_PA_POWER, OUTPUT);
1115
digitalWrite(P_LORA_PA_POWER,HIGH);
16+
rtc_gpio_hold_dis((gpio_num_t)P_LORA_PA_POWER);
1217

13-
rtc_gpio_hold_dis((gpio_num_t)P_LORA_PA_EN);
1418
pinMode(P_LORA_PA_EN, OUTPUT);
1519
digitalWrite(P_LORA_PA_EN,HIGH);
20+
rtc_gpio_hold_dis((gpio_num_t)P_LORA_PA_EN);
1621
pinMode(P_LORA_PA_TX_EN, OUTPUT);
1722
digitalWrite(P_LORA_PA_TX_EN,LOW);
1823

24+
esp_reset_reason_t reason = esp_reset_reason();
25+
if (reason != ESP_RST_DEEPSLEEP) {
26+
delay(1); // GC1109 startup time after cold power-on
27+
}
1928

2029
periph_power.begin();
21-
22-
esp_reset_reason_t reason = esp_reset_reason();
2330
if (reason == ESP_RST_DEEPSLEEP) {
2431
long wakeup_source = esp_sleep_get_ext1_wakeup_status();
2532
if (wakeup_source & (1 << P_LORA_DIO_1)) { // received a LoRa packet (while in deep sleep)
@@ -50,7 +57,9 @@ void HeltecV4Board::begin() {
5057

5158
rtc_gpio_hold_en((gpio_num_t)P_LORA_NSS);
5259

53-
rtc_gpio_hold_en((gpio_num_t)P_LORA_PA_EN); //It also needs to be enabled in receive mode
60+
// Hold GC1109 FEM pins during sleep to keep LNA active for RX wake
61+
rtc_gpio_hold_en((gpio_num_t)P_LORA_PA_POWER);
62+
rtc_gpio_hold_en((gpio_num_t)P_LORA_PA_EN);
5463

5564
if (pin_wake_btn < 0) {
5665
esp_sleep_enable_ext1_wakeup( (1L << P_LORA_DIO_1), ESP_EXT1_WAKEUP_ANY_HIGH); // wake up on: recv LoRa packet

0 commit comments

Comments
 (0)