mirror of
https://github.com/espressif/esp-idf.git
synced 2026-10-02 11:10:54 +03:00
fix(example): fix uninitialized gpio/rtcio in deepsleep example
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* SPDX-FileCopyrightText: 2023 Espressif Systems (Shanghai) CO LTD
|
* SPDX-FileCopyrightText: 2023-2026 Espressif Systems (Shanghai) CO LTD
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: Unlicense OR CC0-1.0
|
* SPDX-License-Identifier: Unlicense OR CC0-1.0
|
||||||
*/
|
*/
|
||||||
@@ -7,6 +7,7 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include "esp_sleep.h"
|
#include "esp_sleep.h"
|
||||||
#include "sdkconfig.h"
|
#include "sdkconfig.h"
|
||||||
|
#include "driver/gpio.h"
|
||||||
#include "driver/rtc_io.h"
|
#include "driver/rtc_io.h"
|
||||||
|
|
||||||
|
|
||||||
@@ -25,6 +26,7 @@ void example_deep_sleep_register_ext0_wakeup(void)
|
|||||||
// Configure pullup/downs via RTCIO to tie wakeup pins to inactive level during deepsleep.
|
// Configure pullup/downs via RTCIO to tie wakeup pins to inactive level during deepsleep.
|
||||||
// EXT0 resides in the same power domain (RTC_PERIPH) as the RTC IO pullup/downs.
|
// EXT0 resides in the same power domain (RTC_PERIPH) as the RTC IO pullup/downs.
|
||||||
// No need to keep that power domain explicitly, unlike EXT1.
|
// No need to keep that power domain explicitly, unlike EXT1.
|
||||||
|
ESP_ERROR_CHECK(rtc_gpio_init(ext_wakeup_pin_0));
|
||||||
ESP_ERROR_CHECK(rtc_gpio_pullup_dis(ext_wakeup_pin_0));
|
ESP_ERROR_CHECK(rtc_gpio_pullup_dis(ext_wakeup_pin_0));
|
||||||
ESP_ERROR_CHECK(rtc_gpio_pulldown_en(ext_wakeup_pin_0));
|
ESP_ERROR_CHECK(rtc_gpio_pulldown_en(ext_wakeup_pin_0));
|
||||||
}
|
}
|
||||||
@@ -48,10 +50,12 @@ void example_deep_sleep_register_ext1_wakeup(void)
|
|||||||
|
|
||||||
/* If there are no external pull-up/downs, tie wakeup pins to inactive level with internal pull-up/downs via RTC IO
|
/* If there are no external pull-up/downs, tie wakeup pins to inactive level with internal pull-up/downs via RTC IO
|
||||||
* during deepsleep. However, RTC IO relies on the RTC_PERIPH power domain. Keeping this power domain on will
|
* during deepsleep. However, RTC IO relies on the RTC_PERIPH power domain. Keeping this power domain on will
|
||||||
* increase some power comsumption. However, if we turn off the RTC_PERIPH domain or if certain chips lack the RTC_PERIPH
|
* increase some power consumption. However, if we turn off the RTC_PERIPH domain or if certain chips lack the RTC_PERIPH
|
||||||
* domain, we will use the HOLD feature to maintain the pull-up and pull-down on the pins during sleep.*/
|
* domain, we will use the HOLD feature to maintain the pull-up and pull-down on the pins during sleep.*/
|
||||||
#if CONFIG_EXAMPLE_EXT1_USE_INTERNAL_PULLUPS
|
#if CONFIG_EXAMPLE_EXT1_USE_INTERNAL_PULLUPS
|
||||||
#if SOC_RTCIO_INPUT_OUTPUT_SUPPORTED
|
#if SOC_RTCIO_INPUT_OUTPUT_SUPPORTED
|
||||||
|
ESP_ERROR_CHECK(rtc_gpio_init(ext_wakeup_pin_1));
|
||||||
|
ESP_ERROR_CHECK(rtc_gpio_init(ext_wakeup_pin_2));
|
||||||
#if SOC_PM_SUPPORT_EXT1_WAKEUP_MODE_PER_PIN
|
#if SOC_PM_SUPPORT_EXT1_WAKEUP_MODE_PER_PIN
|
||||||
if (CONFIG_EXAMPLE_EXT1_WAKEUP_MODE_PIN_1) {
|
if (CONFIG_EXAMPLE_EXT1_WAKEUP_MODE_PIN_1) {
|
||||||
ESP_ERROR_CHECK(rtc_gpio_pullup_dis(ext_wakeup_pin_1));
|
ESP_ERROR_CHECK(rtc_gpio_pullup_dis(ext_wakeup_pin_1));
|
||||||
@@ -81,6 +85,11 @@ void example_deep_sleep_register_ext1_wakeup(void)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#else // ! SOC_RTCIO_INPUT_OUTPUT_SUPPORTED
|
#else // ! SOC_RTCIO_INPUT_OUTPUT_SUPPORTED
|
||||||
|
const gpio_config_t config = {
|
||||||
|
.pin_bit_mask = BIT(ext_wakeup_pin_1) | BIT(ext_wakeup_pin_2),
|
||||||
|
.mode = GPIO_MODE_INPUT,
|
||||||
|
};
|
||||||
|
ESP_ERROR_CHECK(gpio_config(&config));
|
||||||
#if SOC_PM_SUPPORT_EXT1_WAKEUP_MODE_PER_PIN
|
#if SOC_PM_SUPPORT_EXT1_WAKEUP_MODE_PER_PIN
|
||||||
if (CONFIG_EXAMPLE_EXT1_WAKEUP_MODE_PIN_1) {
|
if (CONFIG_EXAMPLE_EXT1_WAKEUP_MODE_PIN_1) {
|
||||||
gpio_pullup_dis(ext_wakeup_pin_1);
|
gpio_pullup_dis(ext_wakeup_pin_1);
|
||||||
|
|||||||
Reference in New Issue
Block a user