change(pm/deepsleep): remove disable rtcio before hold it when ext1 wakeup

This commit is contained in:
Lou Tianhao 2023-07-11 17:15:59 +08:00
parent a80c8c018c
commit 44cd96b543
3 changed files with 35 additions and 27 deletions

View File

@ -1416,6 +1416,12 @@ static void ext1_wakeup_prepare(void)
rtcio_hal_function_select(rtc_pin, RTCIO_FUNC_RTC);
// set input enable in sleep mode
rtcio_hal_input_enable(rtc_pin);
#if SOC_PM_SUPPORT_RTC_PERIPH_PD
// Pad configuration depends on RTC_PERIPH state in sleep mode
if (s_config.domain[ESP_PD_DOMAIN_RTC_PERIPH].pd_option != ESP_PD_OPTION_ON) {
rtcio_hal_hold_enable(rtc_pin);
}
#endif
#else
/* ESP32H2 use hp iomux to config rtcio, and there is no complete
* rtcio functionality. In the case of EXT1 wakeup, rtcio only provides
@ -1427,19 +1433,6 @@ static void ext1_wakeup_prepare(void)
gpio_ll_input_enable(&GPIO, gpio);
// hold rtc_pin to use it during sleep state
rtcio_hal_hold_enable(rtc_pin);
#endif
#if SOC_PM_SUPPORT_RTC_PERIPH_PD
// Pad configuration depends on RTC_PERIPH state in sleep mode
if (s_config.domain[ESP_PD_DOMAIN_RTC_PERIPH].pd_option != ESP_PD_OPTION_ON) {
#if SOC_RTCIO_INPUT_OUTPUT_SUPPORTED
// RTC_PERIPH will be powered down, so RTC_IO_ registers will
// loose their state. Lock pad configuration.
// Pullups/pulldowns also need to be disabled.
rtcio_hal_pullup_disable(rtc_pin);
rtcio_hal_pulldown_disable(rtc_pin);
#endif
rtcio_hal_hold_enable(rtc_pin);
}
#endif
// Keep track of pins which are processed to bail out early
rtc_gpio_mask &= ~BIT(rtc_pin);

View File

@ -244,9 +244,10 @@ menu "Example Configuration"
When using EXT1 wakeup source without external pull-up/downs, you may want to make use of
the internal ones.
However, the RTC IO reside in the RTC Periph power domain. Enable this option to force that
power domain ON during deep sleep. Note that this will increase some power comsumption, so
it's still suggested to use external ones instead.
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.
but if we turn on the RTC_PERIPH domain, we don not need to use HOLD feature and this will
increase some power comsumption.
EXT0 wakeup source resides in the same power domain as RTCIO (RTC Periph), so internal
pull-up/downs are always available. There's no need to explicitly force it on for EXT0.

View File

@ -49,19 +49,33 @@ 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
* during deepsleep. However, RTC IO relies on the RTC_PERIPH power domain. Keeping this power domain on will
* increase some power comsumption. */
* increase some power comsumption. 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.*/
#if CONFIG_EXAMPLE_EXT1_USE_INTERNAL_PULLUPS
#if !CONFIG_IDF_TARGET_ESP32H2
ESP_ERROR_CHECK(esp_sleep_pd_config(ESP_PD_DOMAIN_RTC_PERIPH, ESP_PD_OPTION_ON));
ESP_ERROR_CHECK(rtc_gpio_pullup_dis(ext_wakeup_pin_1));
ESP_ERROR_CHECK(rtc_gpio_pulldown_en(ext_wakeup_pin_1));
ESP_ERROR_CHECK(rtc_gpio_pullup_dis(ext_wakeup_pin_2));
ESP_ERROR_CHECK(rtc_gpio_pulldown_en(ext_wakeup_pin_2));
#if SOC_RTCIO_INPUT_OUTPUT_SUPPORTED
if (ext_wakeup_mode) {
ESP_ERROR_CHECK(rtc_gpio_pullup_dis(ext_wakeup_pin_1));
ESP_ERROR_CHECK(rtc_gpio_pulldown_en(ext_wakeup_pin_1));
ESP_ERROR_CHECK(rtc_gpio_pullup_dis(ext_wakeup_pin_2));
ESP_ERROR_CHECK(rtc_gpio_pulldown_en(ext_wakeup_pin_2));
} else {
ESP_ERROR_CHECK(rtc_gpio_pulldown_dis(ext_wakeup_pin_1));
ESP_ERROR_CHECK(rtc_gpio_pullup_en(ext_wakeup_pin_1));
ESP_ERROR_CHECK(rtc_gpio_pulldown_dis(ext_wakeup_pin_2));
ESP_ERROR_CHECK(rtc_gpio_pullup_en(ext_wakeup_pin_2));
}
#else
gpio_pullup_dis(ext_wakeup_pin_1);
gpio_pulldown_en(ext_wakeup_pin_1);
gpio_pullup_dis(ext_wakeup_pin_2);
gpio_pulldown_en(ext_wakeup_pin_2);
if (ext_wakeup_mode) {
ESP_ERROR_CHECK(gpio_pullup_dis(ext_wakeup_pin_1));
ESP_ERROR_CHECK(gpio_pulldown_en(ext_wakeup_pin_1));
ESP_ERROR_CHECK(gpio_pullup_dis(ext_wakeup_pin_2));
ESP_ERROR_CHECK(gpio_pulldown_en(ext_wakeup_pin_2));
} else {
ESP_ERROR_CHECK(gpio_pulldown_dis(ext_wakeup_pin_1));
ESP_ERROR_CHECK(gpio_pullup_en(ext_wakeup_pin_1));
ESP_ERROR_CHECK(gpio_pulldown_dis(ext_wakeup_pin_2));
ESP_ERROR_CHECK(gpio_pullup_en(ext_wakeup_pin_2));
}
#endif
#endif //CONFIG_EXAMPLE_EXT1_USE_INTERNAL_PULLUPS
}