]> granicus.if.org Git - esp-idf/commitdiff
sleep: allow disabling all wakeup sources
authorIvan Grokhotkov <ivan@espressif.com>
Tue, 14 Aug 2018 00:43:35 +0000 (03:43 +0300)
committerIvan Grokhotkov <ivan@espressif.com>
Thu, 6 Sep 2018 07:40:46 +0000 (15:40 +0800)
components/esp32/include/esp_sleep.h
components/esp32/sleep_modes.c

index 57fb4780e822b6394bedce7a6fbb0470d8920a0b..a9365e3efcc18db32e280aab1a435f8dc9cd0afa 100644 (file)
@@ -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
index 13681a52d978645d2ab9ade3d803e685273b1b6b..ddb3c59149811de10befb8f83fd54b482db6af4a 100644 (file)
@@ -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)) {