Skip to content

Commit

Permalink
Merge branch 'feat/add_internal_pull_up_or_pull_down_option_for_deeps…
Browse files Browse the repository at this point in the history
…leep_wakeup_prepare' into 'master'

feat(pm): add internal pull-up/downs option for gpio used for deepsleep wakeup

Closes IDFGH-10994

See merge request espressif/esp-idf!25972
  • Loading branch information
10086loutianhao committed Sep 20, 2023
2 parents 5a9a962 + 88364b8 commit 925a731
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
6 changes: 6 additions & 0 deletions components/esp_hw_support/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,12 @@ menu "Hardware Settings"
help
Enable esp sleep debug.

config ESP_SLEEP_GPIO_ENABLE_INTERNAL_RESISTORS
bool "Allow to enable internal pull-up/downs for the Deep-Sleep wakeup IOs"
default y
help
When using rtc gpio wakeup source during deepsleep without external pull-up/downs, you may want to
make use of the internal ones.
endmenu

menu "ESP_SLEEP_WORKAROUND"
Expand Down
10 changes: 7 additions & 3 deletions components/esp_hw_support/include/esp_sleep.h
Original file line number Diff line number Diff line change
Expand Up @@ -340,9 +340,13 @@ esp_err_t esp_sleep_enable_ext1_wakeup_with_level_mask(uint64_t io_mask, uint64_
* @note This function does not modify pin configuration. The pins are
* configured inside esp_deep_sleep_start, immediately before entering sleep mode.
*
* @note You don't need to care to pull-up or pull-down before using this
* function, because this will be set internally in esp_deep_sleep_start
* based on the wakeup mode. BTW, when you use low level to wake up the
* @note You don't need to worry about pull-up or pull-down resistors before
* using this function because the ESP_SLEEP_GPIO_ENABLE_INTERNAL_RESISTORS
* option is enabled by default. It will automatically set pull-up or pull-down
* resistors internally in esp_deep_sleep_start based on the wakeup mode. However,
* when using external pull-up or pull-down resistors, please be sure to disable
* the ESP_SLEEP_GPIO_ENABLE_INTERNAL_RESISTORS option, as the combination of internal
* and external resistors may cause interference. BTW, when you use low level to wake up the
* chip, we strongly recommend you to add external resistors (pull-up).
*
* @param gpio_pin_mask Bit mask of GPIO numbers which will cause wakeup. Only GPIOs
Expand Down
2 changes: 2 additions & 0 deletions components/esp_hw_support/sleep_modes.c
Original file line number Diff line number Diff line change
Expand Up @@ -1531,13 +1531,15 @@ static void gpio_deep_sleep_wakeup_prepare(void)
if (((1ULL << gpio_idx) & s_config.gpio_wakeup_mask) == 0) {
continue;
}
#if CONFIG_ESP_SLEEP_GPIO_ENABLE_INTERNAL_RESISTORS
if (s_config.gpio_trigger_mode & BIT(gpio_idx)) {
ESP_ERROR_CHECK(gpio_pullup_dis(gpio_idx));
ESP_ERROR_CHECK(gpio_pulldown_en(gpio_idx));
} else {
ESP_ERROR_CHECK(gpio_pullup_en(gpio_idx));
ESP_ERROR_CHECK(gpio_pulldown_dis(gpio_idx));
}
#endif
ESP_ERROR_CHECK(gpio_hold_en(gpio_idx));
}
// Clear state from previous wakeup
Expand Down

0 comments on commit 925a731

Please sign in to comment.