esp_light_sleep_start causes ESP_ERR_INVALID_STATE
Posted: Fri Aug 16, 2024 10:13 am
Hi
I use an ESP32-S3 board with LCD and GT911 touch. I want to use the light sleep function. The touch IRQ should be used for wakeup.
I use this shortend core, similar to the GPIO example for light sleep:
The problem is that esp_light_sleep_start() returns ESP_ERR_INVALID_STATE. I was able to narrow it down to the initialization of the touch controller. The wakeup pin is configured as input, PU, irq on fallind edge. Without this, the ESP32-S3 will go into light sleep.
Therefore, I tried to reset to GPIO before going into sleep. For this, I added the following code in front:
This code doesn't help, ESP_ERR_INVALID_STATE is still thrown. What is the right way to reset the GPIO so I can use it as wakeup pin?
Thank you very much.
I use an ESP32-S3 board with LCD and GT911 touch. I want to use the light sleep function. The touch IRQ should be used for wakeup.
I use this shortend core, similar to the GPIO example for light sleep:
Code: Select all
gpio_config_t config = {
.pin_bit_mask = (1ULL<<GPIO_NUM_4),
.mode = GPIO_MODE_INPUT,
.pull_down_en = false,
.pull_up_en = false,
.intr_type = GPIO_INTR_DISABLE
};
gpio_config(&config);
gpio_wakeup_enable(GPIO_NUM_4, GPIO_INTR_LOW_LEVEL );
esp_sleep_enable_gpio_wakeup();
/* Wait for pin to settle down. TODO: This could cause a stall. */
while (gpio_get_level(GPIO_NUM_4) == 0) {
vTaskDelay(pdMS_TO_TICKS(10));
}
/* Start light sleep. */
err = esp_light_sleep_start();
if (err != ESP_OK) {
ESP_LOGI(RTC_TAG,"rtc_sleep: esp_light_sleep_start failed: %s", esp_err_to_name(err));
return err;
}
Therefore, I tried to reset to GPIO before going into sleep. For this, I added the following code in front:
Code: Select all
gpio_reset_pin(GPIO_NUM_4);
gpio_intr_disable(GPIO_NUM_4);
gpio_isr_handler_remove(GPIO_NUM_4);
Thank you very much.