mirror of
https://github.com/espressif/esp-idf.git
synced 2025-08-09 07:34:32 +02:00
sleep: fix gpio wakeup not working properly in some cases
Before this fix, when we call esp_pm_configure after gpio_wakeup_enable, the configuration of GPIO in sleep state in gpio_wakeup_enable will be overwritten by esp_pm_configure.
This commit is contained in:
@@ -589,7 +589,7 @@ esp_err_t gpio_wakeup_enable(gpio_num_t gpio_num, gpio_int_type_t intr_type)
|
|||||||
portENTER_CRITICAL(&gpio_context.gpio_spinlock);
|
portENTER_CRITICAL(&gpio_context.gpio_spinlock);
|
||||||
gpio_hal_set_intr_type(gpio_context.gpio_hal, gpio_num, intr_type);
|
gpio_hal_set_intr_type(gpio_context.gpio_hal, gpio_num, intr_type);
|
||||||
gpio_hal_wakeup_enable(gpio_context.gpio_hal, gpio_num);
|
gpio_hal_wakeup_enable(gpio_context.gpio_hal, gpio_num);
|
||||||
#if CONFIG_ESP_SLEEP_GPIO_RESET_WORKAROUND
|
#if CONFIG_ESP_SLEEP_GPIO_RESET_WORKAROUND || CONFIG_PM_SLP_DISABLE_GPIO
|
||||||
gpio_hal_sleep_sel_dis(gpio_context.gpio_hal, gpio_num);
|
gpio_hal_sleep_sel_dis(gpio_context.gpio_hal, gpio_num);
|
||||||
#endif
|
#endif
|
||||||
portEXIT_CRITICAL(&gpio_context.gpio_spinlock);
|
portEXIT_CRITICAL(&gpio_context.gpio_spinlock);
|
||||||
@@ -612,7 +612,7 @@ esp_err_t gpio_wakeup_disable(gpio_num_t gpio_num)
|
|||||||
#endif
|
#endif
|
||||||
portENTER_CRITICAL(&gpio_context.gpio_spinlock);
|
portENTER_CRITICAL(&gpio_context.gpio_spinlock);
|
||||||
gpio_hal_wakeup_disable(gpio_context.gpio_hal, gpio_num);
|
gpio_hal_wakeup_disable(gpio_context.gpio_hal, gpio_num);
|
||||||
#if CONFIG_ESP_SLEEP_GPIO_RESET_WORKAROUND
|
#if CONFIG_ESP_SLEEP_GPIO_RESET_WORKAROUND || CONFIG_PM_SLP_DISABLE_GPIO
|
||||||
gpio_hal_sleep_sel_en(gpio_context.gpio_hal, gpio_num);
|
gpio_hal_sleep_sel_en(gpio_context.gpio_hal, gpio_num);
|
||||||
#endif
|
#endif
|
||||||
portEXIT_CRITICAL(&gpio_context.gpio_spinlock);
|
portEXIT_CRITICAL(&gpio_context.gpio_spinlock);
|
||||||
@@ -935,7 +935,7 @@ esp_err_t gpio_deep_sleep_wakeup_enable(gpio_num_t gpio_num, gpio_int_type_t int
|
|||||||
}
|
}
|
||||||
portENTER_CRITICAL(&gpio_context.gpio_spinlock);
|
portENTER_CRITICAL(&gpio_context.gpio_spinlock);
|
||||||
gpio_hal_deepsleep_wakeup_enable(gpio_context.gpio_hal, gpio_num, intr_type);
|
gpio_hal_deepsleep_wakeup_enable(gpio_context.gpio_hal, gpio_num, intr_type);
|
||||||
#if CONFIG_ESP_SLEEP_GPIO_RESET_WORKAROUND
|
#if CONFIG_ESP_SLEEP_GPIO_RESET_WORKAROUND || CONFIG_PM_SLP_DISABLE_GPIO
|
||||||
gpio_hal_sleep_sel_dis(gpio_context.gpio_hal, gpio_num);
|
gpio_hal_sleep_sel_dis(gpio_context.gpio_hal, gpio_num);
|
||||||
#endif
|
#endif
|
||||||
portEXIT_CRITICAL(&gpio_context.gpio_spinlock);
|
portEXIT_CRITICAL(&gpio_context.gpio_spinlock);
|
||||||
@@ -950,7 +950,7 @@ esp_err_t gpio_deep_sleep_wakeup_disable(gpio_num_t gpio_num)
|
|||||||
}
|
}
|
||||||
portENTER_CRITICAL(&gpio_context.gpio_spinlock);
|
portENTER_CRITICAL(&gpio_context.gpio_spinlock);
|
||||||
gpio_hal_deepsleep_wakeup_disable(gpio_context.gpio_hal, gpio_num);
|
gpio_hal_deepsleep_wakeup_disable(gpio_context.gpio_hal, gpio_num);
|
||||||
#if CONFIG_ESP_SLEEP_GPIO_RESET_WORKAROUND
|
#if CONFIG_ESP_SLEEP_GPIO_RESET_WORKAROUND || CONFIG_PM_SLP_DISABLE_GPIO
|
||||||
gpio_hal_sleep_sel_en(gpio_context.gpio_hal, gpio_num);
|
gpio_hal_sleep_sel_en(gpio_context.gpio_hal, gpio_num);
|
||||||
#endif
|
#endif
|
||||||
portEXIT_CRITICAL(&gpio_context.gpio_spinlock);
|
portEXIT_CRITICAL(&gpio_context.gpio_spinlock);
|
||||||
|
@@ -182,7 +182,7 @@ void esp_deep_sleep_wakeup_io_reset(void)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
#if CONFIG_ESP_SLEEP_GPIO_RESET_WORKAROUND && !CONFIG_PM_SLP_DISABLE_GPIO
|
#if CONFIG_ESP_SLEEP_GPIO_RESET_WORKAROUND || CONFIG_PM_SLP_DISABLE_GPIO
|
||||||
ESP_SYSTEM_INIT_FN(esp_sleep_startup_init, BIT(0), 105)
|
ESP_SYSTEM_INIT_FN(esp_sleep_startup_init, BIT(0), 105)
|
||||||
{
|
{
|
||||||
// Configure to isolate (disable the Input/Output/Pullup/Pulldown
|
// Configure to isolate (disable the Input/Output/Pullup/Pulldown
|
||||||
|
@@ -322,10 +322,6 @@ esp_err_t esp_pm_configure(const void* vconfig)
|
|||||||
s_config_changed = true;
|
s_config_changed = true;
|
||||||
portEXIT_CRITICAL(&s_switch_lock);
|
portEXIT_CRITICAL(&s_switch_lock);
|
||||||
|
|
||||||
#if CONFIG_PM_SLP_DISABLE_GPIO
|
|
||||||
esp_sleep_enable_gpio_switch(config->light_sleep_enable);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if CONFIG_PM_POWER_DOWN_CPU_IN_LIGHT_SLEEP && SOC_PM_SUPPORT_CPU_PD
|
#if CONFIG_PM_POWER_DOWN_CPU_IN_LIGHT_SLEEP && SOC_PM_SUPPORT_CPU_PD
|
||||||
if (config->light_sleep_enable) {
|
if (config->light_sleep_enable) {
|
||||||
if (esp_sleep_cpu_retention_init() != ESP_OK) {
|
if (esp_sleep_cpu_retention_init() != ESP_OK) {
|
||||||
@@ -773,9 +769,6 @@ void esp_pm_impl_init(void)
|
|||||||
esp_pm_trace_init();
|
esp_pm_trace_init();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if CONFIG_PM_SLP_DISABLE_GPIO
|
|
||||||
esp_sleep_config_gpio_isolate();
|
|
||||||
#endif
|
|
||||||
ESP_ERROR_CHECK(esp_pm_lock_create(ESP_PM_CPU_FREQ_MAX, 0, "rtos0",
|
ESP_ERROR_CHECK(esp_pm_lock_create(ESP_PM_CPU_FREQ_MAX, 0, "rtos0",
|
||||||
&s_rtos_lock_handle[0]));
|
&s_rtos_lock_handle[0]));
|
||||||
ESP_ERROR_CHECK(esp_pm_lock_acquire(s_rtos_lock_handle[0]));
|
ESP_ERROR_CHECK(esp_pm_lock_acquire(s_rtos_lock_handle[0]));
|
||||||
|
Reference in New Issue
Block a user