Skip to content

Commit 47a7038

Browse files
Raffael Rostagnojhedberg
authored andcommitted
samples: esp32: deep_sleep: Internal pull support
Some SoCs support EXT1 wake-up pins (RTC IOs) but do not provide IOMUX features like internal pull-up/down resistors. Support for these features is indicated by SOC_RTCIO_INPUT_OUTPUT_SUPPORTED. This change updates the test configuration to account for this and fixes EXT1 pin mapping for ESP32-H2. Signed-off-by: Raffael Rostagno <[email protected]>
1 parent 73e882f commit 47a7038

File tree

2 files changed

+16
-6
lines changed

2 files changed

+16
-6
lines changed

samples/boards/espressif/deep_sleep/Kconfig

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright (c) 2022 Espressif Systems (Shanghai) Co., Ltd.
1+
# Copyright (c) 2022-2025 Espressif Systems (Shanghai) Co., Ltd.
22
# SPDX-License-Identifier: Apache-2.0
33

44
mainmenu "Espressif Deep Sleep demo"
@@ -8,11 +8,12 @@ config EXAMPLE_EXT1_WAKEUP
88
depends on !SOC_SERIES_ESP32C3
99
select GPIO
1010
help
11-
This option enables wake-up from deep sleep using GPIO2 and
12-
GPIO4. The sample enables internal pull-down on EXT1 pins to
13-
avoid random wake-ups. Otherwise, external pull-down should
14-
be used for the same purpose. To trigger a wake-up, connect
15-
one or both of the pins to HIGH.
11+
This option enables wake-up from deep sleep using RTC IO
12+
pins. On targets which support internal pull resistors for
13+
RTC IOs, the sample enables internal pull-down on EXT1 pins
14+
to avoid spurious wake-ups. On targets without this hardware
15+
feature, external pull-down resistors should be used instead.
16+
To trigger a wake-up, connect one or both of the pins to HIGH.
1617

1718
config EXAMPLE_GPIO_WAKEUP
1819
bool "Enable wakeup from GPIO"

samples/boards/espressif/deep_sleep/src/main.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,21 @@
77
#include <zephyr/drivers/gpio.h>
88
#include <zephyr/sys/poweroff.h>
99
#include <esp_sleep.h>
10+
#if SOC_RTCIO_INPUT_OUTPUT_SUPPORTED
1011
#include <driver/rtc_io.h>
12+
#endif
1113

1214
#include <esp_attr.h>
1315

1416
#ifdef CONFIG_EXAMPLE_EXT1_WAKEUP
17+
#ifdef CONFIG_SOC_SERIES_ESP32H2
18+
#define EXT_WAKEUP_PIN_1 (10)
19+
#define EXT_WAKEUP_PIN_2 (11)
20+
#else
1521
#define EXT_WAKEUP_PIN_1 (2)
1622
#define EXT_WAKEUP_PIN_2 (4)
1723
#endif
24+
#endif
1825

1926
#ifdef CONFIG_EXAMPLE_GPIO_WAKEUP
2027
#if !DT_NODE_HAS_STATUS_OKAY(DT_ALIAS(wakeup_button))
@@ -90,11 +97,13 @@ int main(void)
9097
esp_sleep_enable_ext1_wakeup(ext_wakeup_pin_1_mask | ext_wakeup_pin_2_mask,
9198
ESP_EXT1_WAKEUP_ANY_HIGH);
9299

100+
#if SOC_RTCIO_INPUT_OUTPUT_SUPPORTED
93101
/* enable pull-down on ext1 pins to avoid random wake-ups */
94102
rtc_gpio_pullup_dis(EXT_WAKEUP_PIN_1);
95103
rtc_gpio_pulldown_en(EXT_WAKEUP_PIN_1);
96104
rtc_gpio_pullup_dis(EXT_WAKEUP_PIN_2);
97105
rtc_gpio_pulldown_en(EXT_WAKEUP_PIN_2);
106+
#endif
98107
#endif /* CONFIG_EXAMPLE_EXT1_WAKEUP */
99108
#ifdef CONFIG_EXAMPLE_GPIO_WAKEUP
100109
if (!gpio_is_ready_dt(&wakeup_button)) {

0 commit comments

Comments
 (0)