Merge branch 'feat/esp32s3_support_gpio_deepsleep_wakeup' into 'master'
example/deep_sleep: add example of EXT0 and using internal pullups Closes IDF-4657 and IDFGH-6711 See merge request espressif/esp-idf!17099
This commit is contained in:
@@ -103,6 +103,12 @@ void app_main(void)
|
||||
int sleep_time_ms = (now.tv_sec - sleep_enter_time.tv_sec) * 1000 + (now.tv_usec - sleep_enter_time.tv_usec) / 1000;
|
||||
|
||||
switch (esp_sleep_get_wakeup_cause()) {
|
||||
#if CONFIG_EXAMPLE_EXT0_WAKEUP
|
||||
case ESP_SLEEP_WAKEUP_EXT0: {
|
||||
printf("Wake up from ext0\n");
|
||||
break;
|
||||
}
|
||||
#endif // CONFIG_EXAMPLE_EXT0_WAKEUP
|
||||
#ifdef CONFIG_EXAMPLE_EXT1_WAKEUP
|
||||
case ESP_SLEEP_WAKEUP_EXT1: {
|
||||
uint64_t wakeup_pin_mask = esp_sleep_get_ext1_wakeup_status();
|
||||
@@ -174,6 +180,18 @@ void app_main(void)
|
||||
printf("Enabling timer wakeup, %ds\n", wakeup_time_sec);
|
||||
esp_sleep_enable_timer_wakeup(wakeup_time_sec * 1000000);
|
||||
|
||||
#if CONFIG_EXAMPLE_EXT0_WAKEUP
|
||||
const int ext_wakeup_pin_0 = 3;
|
||||
|
||||
printf("Enabling EXT0 wakeup on pin GPIO%d\n", ext_wakeup_pin_0);
|
||||
esp_sleep_enable_ext0_wakeup(ext_wakeup_pin_0, 1);
|
||||
|
||||
// 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.
|
||||
// No need to keep that power domain explicitly, unlike EXT1.
|
||||
rtc_gpio_pullup_dis(ext_wakeup_pin_0);
|
||||
rtc_gpio_pulldown_en(ext_wakeup_pin_0);
|
||||
#endif // CONFIG_EXAMPLE_EXT0_WAKEUP
|
||||
#ifdef CONFIG_EXAMPLE_EXT1_WAKEUP
|
||||
const int ext_wakeup_pin_1 = 2;
|
||||
const uint64_t ext_wakeup_pin_1_mask = 1ULL << ext_wakeup_pin_1;
|
||||
@@ -182,6 +200,17 @@ void app_main(void)
|
||||
|
||||
printf("Enabling EXT1 wakeup on pins GPIO%d, GPIO%d\n", ext_wakeup_pin_1, ext_wakeup_pin_2);
|
||||
esp_sleep_enable_ext1_wakeup(ext_wakeup_pin_1_mask | ext_wakeup_pin_2_mask, ESP_EXT1_WAKEUP_ANY_HIGH);
|
||||
|
||||
/* 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. */
|
||||
# if CONFIG_EXAMPLE_EXT1_USE_INTERNAL_PULLUPS
|
||||
esp_sleep_pd_config(ESP_PD_DOMAIN_RTC_PERIPH, ESP_PD_OPTION_ON);
|
||||
rtc_gpio_pullup_dis(ext_wakeup_pin_1);
|
||||
rtc_gpio_pulldown_en(ext_wakeup_pin_1);
|
||||
rtc_gpio_pullup_dis(ext_wakeup_pin_2);
|
||||
rtc_gpio_pulldown_en(ext_wakeup_pin_2);
|
||||
# endif //CONFIG_EXAMPLE_EXT1_USE_INTERNAL_PULLUPS
|
||||
#endif // CONFIG_EXAMPLE_EXT1_WAKEUP
|
||||
|
||||
#ifdef CONFIG_EXAMPLE_GPIO_WAKEUP
|
||||
|
||||
Reference in New Issue
Block a user