mirror of
https://github.com/espressif/esp-idf.git
synced 2026-10-02 03:00:34 +03:00
Merge branch 'fix/make_deepsleep_gpio_wakeup_usable_for_pd_top_lightsleep_v6.0' into 'release/v6.0'
change(esp_hw_support): deepsleep gpio wakeup API renaming to support PD_TOP lightsleep wakeup (v6.0) See merge request espressif/esp-idf!45416
This commit is contained in:
@@ -41,11 +41,11 @@ typedef enum {
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if SOC_GPIO_SUPPORT_DEEPSLEEP_WAKEUP
|
||||
#if SOC_GPIO_SUPPORT_HP_PERIPH_PD_SLEEP_WAKEUP
|
||||
typedef enum {
|
||||
ESP_GPIO_WAKEUP_GPIO_LOW = 0,
|
||||
ESP_GPIO_WAKEUP_GPIO_HIGH = 1
|
||||
} esp_deepsleep_gpio_wake_up_mode_t;
|
||||
} esp_sleep_gpio_wake_up_mode_t;
|
||||
#endif
|
||||
|
||||
/**
|
||||
@@ -452,14 +452,15 @@ __attribute__((deprecated("please use 'esp_sleep_enable_ext1_wakeup_io' and 'esp
|
||||
#endif // SOC_PM_SUPPORT_EXT1_WAKEUP_MODE_PER_PIN
|
||||
#endif // SOC_PM_SUPPORT_EXT1_WAKEUP
|
||||
|
||||
#if SOC_GPIO_SUPPORT_DEEPSLEEP_WAKEUP
|
||||
#if SOC_GPIO_SUPPORT_HP_PERIPH_PD_SLEEP_WAKEUP
|
||||
/**
|
||||
* @brief Enable wakeup using specific gpio pins
|
||||
*
|
||||
* This function enables an IO pin to wake up the chip from deep sleep.
|
||||
* This function enables an IO pin to wake up the chip from peripheral powerdowned sleep.
|
||||
* (including deepsleep and peripheral powerdowned lightsleep).
|
||||
*
|
||||
* @note 1.This function does not modify pin configuration. The pins are configured
|
||||
* inside `esp_deep_sleep_start`, immediately before entering sleep mode.
|
||||
* inside `esp_sleep_start`, immediately before entering sleep mode.
|
||||
* 2.This function is also applicable to waking up the lightsleep when the peripheral
|
||||
* power domain is powered off, see PM_POWER_DOWN_PERIPHERAL_IN_LIGHT_SLEEP in menuconfig.
|
||||
*
|
||||
@@ -479,9 +480,9 @@ __attribute__((deprecated("please use 'esp_sleep_enable_ext1_wakeup_io' and 'esp
|
||||
* - ESP_GPIO_WAKEUP_GPIO_HIGH: wake up when the gpio turn to high.
|
||||
* @return
|
||||
* - ESP_OK on success
|
||||
* - ESP_ERR_INVALID_ARG if the mask contains any invalid deep sleep wakeup pin or wakeup mode is invalid
|
||||
* - ESP_ERR_INVALID_ARG if the mask contains any invalid wakeup pin or wakeup mode is invalid
|
||||
*/
|
||||
esp_err_t esp_deep_sleep_enable_gpio_wakeup(uint64_t gpio_pin_mask, esp_deepsleep_gpio_wake_up_mode_t mode);
|
||||
esp_err_t esp_sleep_enable_gpio_wakeup_on_hp_periph_powerdown(uint64_t gpio_pin_mask, esp_sleep_gpio_wake_up_mode_t mode);
|
||||
#endif
|
||||
|
||||
/**
|
||||
@@ -499,7 +500,7 @@ esp_err_t esp_deep_sleep_enable_gpio_wakeup(uint64_t gpio_pin_mask, esp_deepslee
|
||||
* @note 1. On ESP32, GPIO wakeup source can not be used together with touch or ULP wakeup sources.
|
||||
* 2. If PM_POWER_DOWN_PERIPHERAL_IN_LIGHT_SLEEP is enabled (if target supported),
|
||||
* this API is unavailable since the GPIO module is powered down during sleep.
|
||||
* You can use `esp_deep_sleep_enable_gpio_wakeup` instead, or use EXT1 wakeup source
|
||||
* You can use `esp_sleep_enable_gpio_wakeup_on_hp_periph_powerdown` instead, or use EXT1 wakeup source
|
||||
* by `esp_sleep_enable_ext1_wakeup_io` to achieve the same function.
|
||||
* (Only GPIOs which have RTC functionality can be used)
|
||||
*
|
||||
@@ -581,7 +582,7 @@ esp_err_t esp_sleep_disable_wifi_beacon_wakeup(void);
|
||||
*/
|
||||
uint64_t esp_sleep_get_ext1_wakeup_status(void);
|
||||
|
||||
#if SOC_GPIO_SUPPORT_DEEPSLEEP_WAKEUP
|
||||
#if SOC_GPIO_SUPPORT_HP_PERIPH_PD_SLEEP_WAKEUP
|
||||
/**
|
||||
* @brief Get the bit mask of GPIOs which caused wakeup (gpio)
|
||||
*
|
||||
@@ -590,7 +591,7 @@ uint64_t esp_sleep_get_ext1_wakeup_status(void);
|
||||
* @return bit mask, if GPIOn caused wakeup, BIT(n) will be set
|
||||
*/
|
||||
uint64_t esp_sleep_get_gpio_wakeup_status(void);
|
||||
#endif //SOC_GPIO_SUPPORT_DEEPSLEEP_WAKEUP
|
||||
#endif //SOC_GPIO_SUPPORT_HP_PERIPH_PD_SLEEP_WAKEUP
|
||||
|
||||
/**
|
||||
* @brief Configure power domain options for sleep mode
|
||||
|
||||
@@ -244,17 +244,17 @@ void esp_deep_sleep_wakeup_io_reset(void)
|
||||
}
|
||||
#endif
|
||||
|
||||
#if SOC_GPIO_SUPPORT_DEEPSLEEP_WAKEUP
|
||||
uint32_t dl_io_mask = SOC_GPIO_DEEP_SLEEP_WAKE_VALID_GPIO_MASK;
|
||||
#if SOC_GPIO_SUPPORT_HP_PERIPH_PD_SLEEP_WAKEUP
|
||||
uint32_t dl_io_mask = SOC_GPIO_HP_PERIPH_PD_SLEEP_WAKEABLE_MASK;
|
||||
gpio_hal_context_t gpio_hal = {
|
||||
.dev = GPIO_HAL_GET_HW(GPIO_PORT_0)
|
||||
};
|
||||
while (dl_io_mask) {
|
||||
int gpio_num = __builtin_ffs(dl_io_mask) - 1;
|
||||
bool wakeup_io_enabled = gpio_hal_deepsleep_wakeup_is_enabled(&gpio_hal, gpio_num);
|
||||
bool wakeup_io_enabled = gpio_hal_wakeup_is_enabled_on_hp_periph_powerdown_sleep(&gpio_hal, gpio_num);
|
||||
if (wakeup_io_enabled) {
|
||||
// Disable the wakeup before releasing hold, such that wakeup status can reflect the correct wakeup pin
|
||||
gpio_hal_deepsleep_wakeup_disable(&gpio_hal, gpio_num);
|
||||
gpio_hal_wakeup_disable_on_hp_periph_powerdown_sleep(&gpio_hal, gpio_num);
|
||||
gpio_hal_hold_dis(&gpio_hal, gpio_num);
|
||||
}
|
||||
dl_io_mask &= ~BIT(gpio_num);
|
||||
|
||||
@@ -276,9 +276,9 @@ typedef struct {
|
||||
uint32_t ext0_trigger_level : 1;
|
||||
uint32_t ext0_rtc_gpio_num : 5;
|
||||
#endif
|
||||
#if SOC_GPIO_SUPPORT_DEEPSLEEP_WAKEUP
|
||||
uint32_t gpio_wakeup_mask : SOC_GPIO_DEEP_SLEEP_WAKE_SUPPORTED_PIN_CNT; // Only RTC_GPIO supports wakeup deepsleep
|
||||
uint32_t gpio_trigger_mode : SOC_GPIO_DEEP_SLEEP_WAKE_SUPPORTED_PIN_CNT;
|
||||
#if SOC_GPIO_SUPPORT_HP_PERIPH_PD_SLEEP_WAKEUP
|
||||
uint32_t gpio_wakeup_mask : SOC_GPIO_HP_PERIPH_PD_SLEEP_WAKEABLE_PIN_CNT;
|
||||
uint32_t gpio_trigger_mode : SOC_GPIO_HP_PERIPH_PD_SLEEP_WAKEABLE_PIN_CNT;
|
||||
#endif
|
||||
uint32_t sleep_time_adjustment;
|
||||
uint32_t ccount_ticks_record;
|
||||
@@ -367,8 +367,8 @@ static void touch_wakeup_prepare(void);
|
||||
#if SOC_VBAT_SUPPORTED
|
||||
static void vbat_under_volt_wakeup_prepare(void);
|
||||
#endif
|
||||
#if SOC_GPIO_SUPPORT_DEEPSLEEP_WAKEUP && SOC_DEEP_SLEEP_SUPPORTED
|
||||
static void gpio_deep_sleep_wakeup_prepare(void);
|
||||
#if SOC_GPIO_SUPPORT_HP_PERIPH_PD_SLEEP_WAKEUP && SOC_DEEP_SLEEP_SUPPORTED
|
||||
static void esp_sleep_gpio_wakeup_prepare_on_hp_periph_powerdown(void);
|
||||
#endif
|
||||
|
||||
#if ESP_ROM_SUPPORT_DEEP_SLEEP_WAKEUP_STUB && SOC_DEEP_SLEEP_SUPPORTED
|
||||
@@ -994,9 +994,9 @@ static esp_err_t SLEEP_FN_ATTR esp_sleep_start(uint32_t sleep_flags, uint32_t cl
|
||||
// for !(s_config.wakeup_triggers & RTC_EXT1_TRIG_EN), ext1 wakeup will be turned off in hardware in the real call to sleep
|
||||
#endif
|
||||
|
||||
#if SOC_GPIO_SUPPORT_DEEPSLEEP_WAKEUP && SOC_DEEP_SLEEP_SUPPORTED
|
||||
#if SOC_GPIO_SUPPORT_HP_PERIPH_PD_SLEEP_WAKEUP && SOC_DEEP_SLEEP_SUPPORTED
|
||||
if (deep_sleep && (s_config.wakeup_triggers & RTC_GPIO_TRIG_EN)) {
|
||||
gpio_deep_sleep_wakeup_prepare();
|
||||
esp_sleep_gpio_wakeup_prepare_on_hp_periph_powerdown();
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -1855,8 +1855,8 @@ bool esp_sleep_is_valid_wakeup_gpio(gpio_num_t gpio_num)
|
||||
{
|
||||
#if SOC_RTCIO_PIN_COUNT > 0
|
||||
return RTC_GPIO_IS_VALID_GPIO(gpio_num);
|
||||
#elif SOC_GPIO_SUPPORT_DEEPSLEEP_WAKEUP
|
||||
return GPIO_IS_DEEP_SLEEP_WAKEUP_VALID_GPIO(gpio_num);
|
||||
#elif SOC_GPIO_SUPPORT_HP_PERIPH_PD_SLEEP_WAKEUP
|
||||
return GPIO_IS_HP_PERIPH_PD_WAKEUP_VALID_IO(gpio_num);
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
@@ -2083,7 +2083,7 @@ uint64_t esp_sleep_get_ext1_wakeup_status(void)
|
||||
|
||||
#endif // SOC_PM_SUPPORT_EXT1_WAKEUP && SOC_RTCIO_PIN_COUNT > 0
|
||||
|
||||
#if SOC_GPIO_SUPPORT_DEEPSLEEP_WAKEUP && SOC_DEEP_SLEEP_SUPPORTED
|
||||
#if SOC_GPIO_SUPPORT_HP_PERIPH_PD_SLEEP_WAKEUP && SOC_DEEP_SLEEP_SUPPORTED
|
||||
uint64_t esp_sleep_get_gpio_wakeup_status(void)
|
||||
{
|
||||
if (!(esp_sleep_get_wakeup_causes() & BIT(ESP_SLEEP_WAKEUP_GPIO))) {
|
||||
@@ -2092,9 +2092,9 @@ uint64_t esp_sleep_get_gpio_wakeup_status(void)
|
||||
return rtc_hal_gpio_get_wakeup_status();
|
||||
}
|
||||
|
||||
static void gpio_deep_sleep_wakeup_prepare(void)
|
||||
static void esp_sleep_gpio_wakeup_prepare_on_hp_periph_powerdown(void)
|
||||
{
|
||||
uint32_t valid_wake_io_mask = SOC_GPIO_DEEP_SLEEP_WAKE_VALID_GPIO_MASK;
|
||||
uint32_t valid_wake_io_mask = SOC_GPIO_HP_PERIPH_PD_SLEEP_WAKEABLE_MASK;
|
||||
for (gpio_num_t gpio_idx = __builtin_ctz(valid_wake_io_mask); valid_wake_io_mask >> gpio_idx; gpio_idx++) {
|
||||
if ((s_config.gpio_wakeup_mask & BIT64(gpio_idx)) == 0) {
|
||||
continue;
|
||||
@@ -2119,7 +2119,7 @@ static void gpio_deep_sleep_wakeup_prepare(void)
|
||||
rtc_hal_gpio_clear_wakeup_status();
|
||||
}
|
||||
|
||||
esp_err_t esp_deep_sleep_enable_gpio_wakeup(uint64_t gpio_pin_mask, esp_deepsleep_gpio_wake_up_mode_t mode)
|
||||
esp_err_t esp_sleep_enable_gpio_wakeup_on_hp_periph_powerdown(uint64_t gpio_pin_mask, esp_sleep_gpio_wake_up_mode_t mode)
|
||||
{
|
||||
if (mode > ESP_GPIO_WAKEUP_GPIO_HIGH) {
|
||||
ESP_LOGE(TAG, "invalid mode");
|
||||
@@ -2128,11 +2128,11 @@ esp_err_t esp_deep_sleep_enable_gpio_wakeup(uint64_t gpio_pin_mask, esp_deepslee
|
||||
gpio_int_type_t intr_type = ((mode == ESP_GPIO_WAKEUP_GPIO_LOW) ? GPIO_INTR_LOW_LEVEL : GPIO_INTR_HIGH_LEVEL);
|
||||
esp_err_t err = ESP_OK;
|
||||
|
||||
uint64_t invalid_io_mask = gpio_pin_mask & ~SOC_GPIO_DEEP_SLEEP_WAKE_VALID_GPIO_MASK;
|
||||
uint64_t invalid_io_mask = gpio_pin_mask & ~SOC_GPIO_HP_PERIPH_PD_SLEEP_WAKEABLE_MASK;
|
||||
if (invalid_io_mask != 0) {
|
||||
for (gpio_num_t gpio_idx = __builtin_ctzll(invalid_io_mask); invalid_io_mask >> gpio_idx; gpio_idx++) {
|
||||
if (invalid_io_mask & BIT64(gpio_idx)) {
|
||||
ESP_LOGE(TAG, "gpio %d is an invalid deep sleep wakeup IO", gpio_idx);
|
||||
ESP_LOGE(TAG, "GPIO %d does not support wakeup on peripheral powerdown sleep", gpio_idx);
|
||||
return ESP_ERR_INVALID_ARG;
|
||||
}
|
||||
}
|
||||
@@ -2142,7 +2142,7 @@ esp_err_t esp_deep_sleep_enable_gpio_wakeup(uint64_t gpio_pin_mask, esp_deepslee
|
||||
if ((gpio_pin_mask & BIT64(gpio_idx)) == 0) {
|
||||
continue;
|
||||
}
|
||||
err = gpio_deep_sleep_wakeup_enable(gpio_idx, intr_type);
|
||||
err = gpio_wakeup_enable_on_hp_periph_powerdown_sleep(gpio_idx, intr_type);
|
||||
|
||||
s_config.gpio_wakeup_mask |= BIT(gpio_idx);
|
||||
if (mode == ESP_GPIO_WAKEUP_GPIO_HIGH) {
|
||||
@@ -2154,8 +2154,7 @@ esp_err_t esp_deep_sleep_enable_gpio_wakeup(uint64_t gpio_pin_mask, esp_deepslee
|
||||
s_config.wakeup_triggers |= RTC_GPIO_TRIG_EN;
|
||||
return err;
|
||||
}
|
||||
|
||||
#endif //SOC_GPIO_SUPPORT_DEEPSLEEP_WAKEUP && SOC_DEEP_SLEEP_SUPPORTED
|
||||
#endif //SOC_GPIO_SUPPORT_HP_PERIPH_PD_SLEEP_WAKEUP
|
||||
|
||||
esp_err_t esp_sleep_enable_gpio_wakeup(void)
|
||||
{
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2023-2025 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2023-2026 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Unlicense OR CC0-1.0
|
||||
*/
|
||||
@@ -142,7 +142,7 @@ static void register_ext1_wakeup(void)
|
||||
}
|
||||
#endif
|
||||
|
||||
#if SOC_GPIO_SUPPORT_DEEPSLEEP_WAKEUP
|
||||
#if SOC_GPIO_SUPPORT_HP_PERIPH_PD_SLEEP_WAKEUP
|
||||
static struct {
|
||||
struct arg_int *pin;
|
||||
struct arg_int *level;
|
||||
@@ -177,7 +177,7 @@ static int process_rtcio_wakeup(int argc, char **argv)
|
||||
ESP_LOGI(TAG, "io_wakeup_level = %d\n", io_wakeup_level);
|
||||
|
||||
if (rtcio_wakeup_args.disable->count) {
|
||||
ESP_ERROR_CHECK(gpio_deep_sleep_wakeup_disable(io_wakeup_num));
|
||||
ESP_ERROR_CHECK(gpio_wakeup_disable_on_hp_periph_powerdown_sleep(io_wakeup_num));
|
||||
} else {
|
||||
gpio_config_t config = {
|
||||
.pin_bit_mask = BIT64(io_wakeup_num),
|
||||
@@ -189,7 +189,7 @@ static int process_rtcio_wakeup(int argc, char **argv)
|
||||
ESP_ERROR_CHECK(gpio_config(&config));
|
||||
|
||||
/* Enable wake up from GPIO */
|
||||
ESP_ERROR_CHECK(esp_deep_sleep_enable_gpio_wakeup(BIT64(io_wakeup_num), io_wakeup_level));
|
||||
ESP_ERROR_CHECK(esp_sleep_enable_gpio_wakeup_on_hp_periph_powerdown(BIT64(io_wakeup_num), io_wakeup_level));
|
||||
}
|
||||
|
||||
return 0;
|
||||
@@ -383,7 +383,7 @@ static int process_get_wakeup_cause(int argc, char **argv)
|
||||
|
||||
if (causes & BIT(ESP_SLEEP_WAKEUP_GPIO)) {
|
||||
if (esp_reset_reason() == ESP_RST_DEEPSLEEP) {
|
||||
#if SOC_GPIO_SUPPORT_DEEPSLEEP_WAKEUP
|
||||
#if SOC_GPIO_SUPPORT_HP_PERIPH_PD_SLEEP_WAKEUP
|
||||
uint64_t wakeup_pin_mask = esp_sleep_get_gpio_wakeup_status();
|
||||
if (wakeup_pin_mask != 0) {
|
||||
int pin = __builtin_ffsll(wakeup_pin_mask) - 1;
|
||||
@@ -440,7 +440,7 @@ void register_io_wakeup_cmd(void)
|
||||
#endif
|
||||
register_gpio_control();
|
||||
register_gpio_wakeup();
|
||||
#if SOC_GPIO_SUPPORT_DEEPSLEEP_WAKEUP
|
||||
#if SOC_GPIO_SUPPORT_HP_PERIPH_PD_SLEEP_WAKEUP
|
||||
register_rtcio_wakeup();
|
||||
#endif
|
||||
register_get_wakeup_cause();
|
||||
|
||||
Reference in New Issue
Block a user