mirror of
https://github.com/espressif/esp-idf.git
synced 2024-10-05 20:47:46 -04:00
driver(gpio): fix gpio can't wakeup light sleep
This commit is contained in:
parent
bd920d22b0
commit
d91e64cea4
@ -535,11 +535,10 @@ esp_err_t gpio_wakeup_enable(gpio_num_t gpio_num, gpio_int_type_t intr_type)
|
||||
if ((intr_type == GPIO_INTR_LOW_LEVEL) || (intr_type == GPIO_INTR_HIGH_LEVEL)) {
|
||||
if (rtc_gpio_is_valid_gpio(gpio_num)) {
|
||||
ret = rtc_gpio_wakeup_enable(gpio_num, intr_type);
|
||||
} else {
|
||||
portENTER_CRITICAL(&gpio_context.gpio_spinlock);
|
||||
gpio_hal_wakeup_enable(gpio_context.gpio_hal, gpio_num, intr_type);
|
||||
portEXIT_CRITICAL(&gpio_context.gpio_spinlock);
|
||||
}
|
||||
portENTER_CRITICAL(&gpio_context.gpio_spinlock);
|
||||
gpio_hal_wakeup_enable(gpio_context.gpio_hal, gpio_num, intr_type);
|
||||
portEXIT_CRITICAL(&gpio_context.gpio_spinlock);
|
||||
} else {
|
||||
ESP_LOGE(GPIO_TAG, "GPIO wakeup only supports level mode, but edge mode set. gpio_num:%u", gpio_num);
|
||||
ret = ESP_ERR_INVALID_ARG;
|
||||
@ -555,11 +554,10 @@ esp_err_t gpio_wakeup_disable(gpio_num_t gpio_num)
|
||||
|
||||
if (rtc_gpio_is_valid_gpio(gpio_num)) {
|
||||
ret = rtc_gpio_wakeup_disable(gpio_num);
|
||||
} else {
|
||||
portENTER_CRITICAL(&gpio_context.gpio_spinlock);
|
||||
gpio_hal_wakeup_disable(gpio_context.gpio_hal, gpio_num);
|
||||
portEXIT_CRITICAL(&gpio_context.gpio_spinlock);
|
||||
}
|
||||
portENTER_CRITICAL(&gpio_context.gpio_spinlock);
|
||||
gpio_hal_wakeup_disable(gpio_context.gpio_hal, gpio_num);
|
||||
portEXIT_CRITICAL(&gpio_context.gpio_spinlock);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,3 @@
|
||||
| Supported Targets | ESP32 |
|
||||
| ----------------- | ----- |
|
||||
|
||||
# Light Sleep Example
|
||||
|
||||
(See the README.md file in the upper level 'examples' directory for more information about examples.)
|
||||
|
@ -17,7 +17,6 @@
|
||||
#include "esp_sleep.h"
|
||||
#include "esp_log.h"
|
||||
#include "driver/uart.h"
|
||||
#include "driver/rtc_io.h"
|
||||
|
||||
/* Most development boards have "boot" button attached to GPIO0.
|
||||
* You can also change this to another pin.
|
||||
@ -46,11 +45,11 @@ void app_main(void)
|
||||
esp_sleep_enable_gpio_wakeup();
|
||||
|
||||
/* Wait until GPIO goes high */
|
||||
if (rtc_gpio_get_level(button_gpio_num) == wakeup_level) {
|
||||
if (gpio_get_level(button_gpio_num) == wakeup_level) {
|
||||
printf("Waiting for GPIO%d to go high...\n", button_gpio_num);
|
||||
do {
|
||||
vTaskDelay(pdMS_TO_TICKS(10));
|
||||
} while (rtc_gpio_get_level(button_gpio_num) == wakeup_level);
|
||||
} while (gpio_get_level(button_gpio_num) == wakeup_level);
|
||||
}
|
||||
|
||||
printf("Entering light sleep\n");
|
||||
|
Loading…
x
Reference in New Issue
Block a user