change(pm/ext1): replace deprecated ext1 func

This commit is contained in:
Lou Tianhao 2023-11-10 15:24:05 +08:00
parent 5b91acb1a1
commit a02f72bb81
7 changed files with 16 additions and 17 deletions

View File

@ -402,7 +402,8 @@ esp_err_t esp_sleep_clear_ext1_wakeup_io(uint64_t io_mask);
* - ESP_ERR_INVALID_ARG if any of the selected GPIOs is not an RTC GPIO, * - ESP_ERR_INVALID_ARG if any of the selected GPIOs is not an RTC GPIO,
* or mode is invalid * or mode is invalid
*/ */
esp_err_t esp_sleep_enable_ext1_wakeup_with_level_mask(uint64_t io_mask, uint64_t level_mask); esp_err_t esp_sleep_enable_ext1_wakeup_with_level_mask(uint64_t io_mask, uint64_t level_mask)
__attribute__((deprecated("please use 'esp_sleep_set_ext1_wakeup_io' and 'esp_sleep_clear_ext1_wakeup_io' instead")));
#endif // SOC_PM_SUPPORT_EXT1_WAKEUP_MODE_PER_PIN #endif // SOC_PM_SUPPORT_EXT1_WAKEUP_MODE_PER_PIN
#endif // SOC_PM_SUPPORT_EXT1_WAKEUP #endif // SOC_PM_SUPPORT_EXT1_WAKEUP

View File

@ -182,7 +182,7 @@ TEST_CASE("Can wake up from automatic light sleep by GPIO", "[pm][ignore]")
rtc_gpio_set_level(ext1_wakeup_gpio, 0); rtc_gpio_set_level(ext1_wakeup_gpio, 0);
/* Enable wakeup */ /* Enable wakeup */
TEST_ESP_OK(esp_sleep_enable_ext1_wakeup(1ULL << ext1_wakeup_gpio, ESP_EXT1_WAKEUP_ANY_HIGH)); TEST_ESP_OK(esp_sleep_set_ext1_wakeup_io(1ULL << ext1_wakeup_gpio, ESP_EXT1_WAKEUP_ANY_HIGH));
/* To simplify test environment, we'll use a ULP program to set GPIO high */ /* To simplify test environment, we'll use a ULP program to set GPIO high */
ulp_insn_t ulp_code[] = { ulp_insn_t ulp_code[] = {

View File

@ -416,7 +416,7 @@ TEST_CASE("wake up using ext1 when RTC_PERIPH is off (13 high)", "[deepsleep][ig
{ {
// This test needs external pulldown // This test needs external pulldown
ESP_ERROR_CHECK(rtc_gpio_init(GPIO_NUM_13)); ESP_ERROR_CHECK(rtc_gpio_init(GPIO_NUM_13));
ESP_ERROR_CHECK(esp_sleep_enable_ext1_wakeup(BIT(GPIO_NUM_13), ESP_EXT1_WAKEUP_ANY_HIGH)); ESP_ERROR_CHECK(esp_sleep_set_ext1_wakeup_io(BIT(GPIO_NUM_13), ESP_EXT1_WAKEUP_ANY_HIGH));
esp_deep_sleep_start(); esp_deep_sleep_start();
} }
@ -425,9 +425,9 @@ TEST_CASE("wake up using ext1 when RTC_PERIPH is off (13 low)", "[deepsleep][ign
// This test needs external pullup // This test needs external pullup
ESP_ERROR_CHECK(rtc_gpio_init(GPIO_NUM_13)); ESP_ERROR_CHECK(rtc_gpio_init(GPIO_NUM_13));
#if CONFIG_IDF_TARGET_ESP32 #if CONFIG_IDF_TARGET_ESP32
ESP_ERROR_CHECK(esp_sleep_enable_ext1_wakeup(BIT(GPIO_NUM_13), ESP_EXT1_WAKEUP_ALL_LOW)); ESP_ERROR_CHECK(esp_sleep_set_ext1_wakeup_io(BIT(GPIO_NUM_13), ESP_EXT1_WAKEUP_ALL_LOW));
#else #else
ESP_ERROR_CHECK(esp_sleep_enable_ext1_wakeup(BIT(GPIO_NUM_13), ESP_EXT1_WAKEUP_ANY_LOW)); ESP_ERROR_CHECK(esp_sleep_set_ext1_wakeup_io(BIT(GPIO_NUM_13), ESP_EXT1_WAKEUP_ANY_LOW));
#endif #endif
esp_deep_sleep_start(); esp_deep_sleep_start();
} }
@ -438,7 +438,7 @@ TEST_CASE("wake up using ext1 when RTC_PERIPH is on (13 high)", "[deepsleep][ign
ESP_ERROR_CHECK(gpio_pullup_dis(GPIO_NUM_13)); ESP_ERROR_CHECK(gpio_pullup_dis(GPIO_NUM_13));
ESP_ERROR_CHECK(gpio_pulldown_en(GPIO_NUM_13)); ESP_ERROR_CHECK(gpio_pulldown_en(GPIO_NUM_13));
ESP_ERROR_CHECK(esp_sleep_pd_config(ESP_PD_DOMAIN_RTC_PERIPH, ESP_PD_OPTION_ON)); ESP_ERROR_CHECK(esp_sleep_pd_config(ESP_PD_DOMAIN_RTC_PERIPH, ESP_PD_OPTION_ON));
ESP_ERROR_CHECK(esp_sleep_enable_ext1_wakeup(BIT(GPIO_NUM_13), ESP_EXT1_WAKEUP_ANY_HIGH)); ESP_ERROR_CHECK(esp_sleep_set_ext1_wakeup_io(BIT(GPIO_NUM_13), ESP_EXT1_WAKEUP_ANY_HIGH));
esp_deep_sleep_start(); esp_deep_sleep_start();
} }
@ -449,9 +449,9 @@ TEST_CASE("wake up using ext1 when RTC_PERIPH is on (13 low)", "[deepsleep][igno
ESP_ERROR_CHECK(gpio_pulldown_dis(GPIO_NUM_13)); ESP_ERROR_CHECK(gpio_pulldown_dis(GPIO_NUM_13));
ESP_ERROR_CHECK(esp_sleep_pd_config(ESP_PD_DOMAIN_RTC_PERIPH, ESP_PD_OPTION_ON)); ESP_ERROR_CHECK(esp_sleep_pd_config(ESP_PD_DOMAIN_RTC_PERIPH, ESP_PD_OPTION_ON));
#if CONFIG_IDF_TARGET_ESP32 #if CONFIG_IDF_TARGET_ESP32
ESP_ERROR_CHECK(esp_sleep_enable_ext1_wakeup(BIT(GPIO_NUM_13), ESP_EXT1_WAKEUP_ALL_LOW)); ESP_ERROR_CHECK(esp_sleep_set_ext1_wakeup_io(BIT(GPIO_NUM_13), ESP_EXT1_WAKEUP_ALL_LOW));
#else #else
ESP_ERROR_CHECK(esp_sleep_enable_ext1_wakeup(BIT(GPIO_NUM_13), ESP_EXT1_WAKEUP_ANY_LOW)); ESP_ERROR_CHECK(esp_sleep_set_ext1_wakeup_io(BIT(GPIO_NUM_13), ESP_EXT1_WAKEUP_ANY_LOW));
#endif #endif
esp_deep_sleep_start(); esp_deep_sleep_start();
} }

View File

@ -217,7 +217,7 @@ static int deep_sleep(int argc, char **argv)
io_num, level ? "HIGH" : "LOW"); io_num, level ? "HIGH" : "LOW");
#if SOC_PM_SUPPORT_EXT1_WAKEUP #if SOC_PM_SUPPORT_EXT1_WAKEUP
ESP_ERROR_CHECK( esp_sleep_enable_ext1_wakeup(1ULL << io_num, level) ); ESP_ERROR_CHECK( esp_sleep_set_ext1_wakeup_io(1ULL << io_num, level) );
#endif #endif
} }

View File

@ -150,8 +150,8 @@ static void ot_deep_sleep_init(void)
const uint64_t gpio_wakeup_pin_mask = 1ULL << gpio_wakeup_pin; const uint64_t gpio_wakeup_pin_mask = 1ULL << gpio_wakeup_pin;
// The configuration mode depends on your hardware design. // The configuration mode depends on your hardware design.
// Since the BOOT button is connected to a pull-up resistor, the wake-up mode is configured as LOW. // Since the BOOT button is connected to a pull-up resistor, the wake-up mode is configured as LOW.
const uint64_t ext_wakeup_mode = 0 << gpio_wakeup_pin; const uint64_t ext_wakeup_mode = 0;
ESP_ERROR_CHECK(esp_sleep_enable_ext1_wakeup_with_level_mask(gpio_wakeup_pin_mask, ext_wakeup_mode)); ESP_ERROR_CHECK(esp_sleep_set_ext1_wakeup_io(gpio_wakeup_pin_mask, ext_wakeup_mode));
// Also these two GPIO configurations are also depended on the hardware design. // Also these two GPIO configurations are also depended on the hardware design.
// The BOOT button is connected to the pull-up resistor, so enable the pull-up mode and disable the pull-down mode. // The BOOT button is connected to the pull-up resistor, so enable the pull-up mode and disable the pull-down mode.

View File

@ -82,7 +82,7 @@ static int deep_sleep(int argc, char **argv)
ESP_LOGI(TAG, "Enabling wakeup on GPIO%d, wakeup on %s level", ESP_LOGI(TAG, "Enabling wakeup on GPIO%d, wakeup on %s level",
io_num, level ? "HIGH" : "LOW"); io_num, level ? "HIGH" : "LOW");
ESP_ERROR_CHECK( esp_sleep_enable_ext1_wakeup(1ULL << io_num, level) ); ESP_ERROR_CHECK( esp_sleep_set_ext1_wakeup_io(1ULL << io_num, level) );
ESP_LOGE(TAG, "GPIO wakeup from deep sleep currently unsupported on ESP32-C3"); ESP_LOGE(TAG, "GPIO wakeup from deep sleep currently unsupported on ESP32-C3");
} }
#endif // SOC_PM_SUPPORT_EXT1_WAKEUP #endif // SOC_PM_SUPPORT_EXT1_WAKEUP

View File

@ -40,12 +40,10 @@ void example_deep_sleep_register_ext1_wakeup(void)
printf("Enabling EXT1 wakeup on pins GPIO%d, GPIO%d\n", ext_wakeup_pin_1, ext_wakeup_pin_2); printf("Enabling EXT1 wakeup on pins GPIO%d, GPIO%d\n", ext_wakeup_pin_1, ext_wakeup_pin_2);
#if SOC_PM_SUPPORT_EXT1_WAKEUP_MODE_PER_PIN #if SOC_PM_SUPPORT_EXT1_WAKEUP_MODE_PER_PIN
const uint64_t ext_wakeup_mode = CONFIG_EXAMPLE_EXT1_WAKEUP_MODE_PIN_1 << ext_wakeup_pin_1 | \ ESP_ERROR_CHECK(esp_sleep_set_ext1_wakeup_io(ext_wakeup_pin_1_mask, CONFIG_EXAMPLE_EXT1_WAKEUP_MODE_PIN_1));
CONFIG_EXAMPLE_EXT1_WAKEUP_MODE_PIN_2 << ext_wakeup_pin_2; ESP_ERROR_CHECK(esp_sleep_set_ext1_wakeup_io(ext_wakeup_pin_2_mask, CONFIG_EXAMPLE_EXT1_WAKEUP_MODE_PIN_2));
ESP_ERROR_CHECK(esp_sleep_enable_ext1_wakeup_with_level_mask(ext_wakeup_pin_1_mask | ext_wakeup_pin_2_mask, ext_wakeup_mode));
#else #else
const esp_sleep_ext1_wakeup_mode_t ext_wakeup_mode = CONFIG_EXAMPLE_EXT1_WAKEUP_MODE; ESP_ERROR_CHECK(esp_sleep_set_ext1_wakeup_io(ext_wakeup_pin_1_mask | ext_wakeup_pin_2_mask, CONFIG_EXAMPLE_EXT1_WAKEUP_MODE));
ESP_ERROR_CHECK(esp_sleep_enable_ext1_wakeup(ext_wakeup_pin_1_mask | ext_wakeup_pin_2_mask, ext_wakeup_mode));
#endif #endif
/* 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