Просмотр исходного кода

sleep: allow disabling all wakeup sources

Ivan Grokhotkov 7 лет назад
Родитель
Сommit
cf4f2c19e4
2 измененных файлов с 4 добавлено и 1 удалено
  1. 1 0
      components/esp32/include/esp_sleep.h
  2. 3 1
      components/esp32/sleep_modes.c

+ 1 - 0
components/esp32/include/esp_sleep.h

@@ -56,6 +56,7 @@ typedef enum {
  */
 typedef enum {
     ESP_SLEEP_WAKEUP_UNDEFINED,    //!< In case of deep sleep, reset was not caused by exit from deep sleep
+    ESP_SLEEP_WAKEUP_ALL,          //!< Not a wakeup cause, used to disable all wakeup sources with esp_sleep_disable_wakeup_source
     ESP_SLEEP_WAKEUP_EXT0,         //!< Wakeup caused by external signal using RTC_IO
     ESP_SLEEP_WAKEUP_EXT1,         //!< Wakeup caused by external signal using RTC_CNTL
     ESP_SLEEP_WAKEUP_TIMER,        //!< Wakeup caused by timer

+ 3 - 1
components/esp32/sleep_modes.c

@@ -361,7 +361,9 @@ esp_err_t esp_sleep_disable_wakeup_source(esp_sleep_source_t source)
     // For most of sources it is enough to set trigger mask in local
     // configuration structure. The actual RTC wake up options
     // will be updated by esp_sleep_start().
-    if (CHECK_SOURCE(source, ESP_SLEEP_WAKEUP_TIMER, RTC_TIMER_TRIG_EN)) {
+    if (source == ESP_SLEEP_WAKEUP_ALL) {
+        s_config.wakeup_triggers = 0;
+    } else if (CHECK_SOURCE(source, ESP_SLEEP_WAKEUP_TIMER, RTC_TIMER_TRIG_EN)) {
         s_config.wakeup_triggers &= ~RTC_TIMER_TRIG_EN;
         s_config.sleep_duration = 0;
     } else if (CHECK_SOURCE(source, ESP_SLEEP_WAKEUP_EXT0, RTC_EXT0_TRIG_EN)) {