sleep: add light sleep, factor out APIs common for deep/light sleep

This commit is contained in:
Ivan Grokhotkov
2017-04-21 12:32:50 +08:00
parent 65b046f17f
commit d2acf1ce77
18 changed files with 716 additions and 475 deletions

View File

@@ -13,6 +13,7 @@
#include "esp_log.h"
#include "esp_console.h"
#include "esp_system.h"
#include "esp_sleep.h"
#include "driver/rtc_io.h"
#include "argtable3/argtable3.h"
#include "cmd_decl.h"
@@ -91,7 +92,7 @@ static int deep_sleep(int argc, char** argv)
if (deep_sleep_args.wakeup_time->count) {
uint64_t timeout = 1000ULL * deep_sleep_args.wakeup_time->ival[0];
ESP_LOGI(__func__, "Enabling timer wakeup, timeout=%lluus", timeout);
ESP_ERROR_CHECK( esp_deep_sleep_enable_timer_wakeup(timeout) );
ESP_ERROR_CHECK( esp_sleep_enable_timer_wakeup(timeout) );
}
if (deep_sleep_args.wakeup_gpio_num->count) {
int io_num = deep_sleep_args.wakeup_gpio_num->ival[0];
@@ -110,7 +111,7 @@ static int deep_sleep(int argc, char** argv)
ESP_LOGI(__func__, "Enabling wakeup on GPIO%d, wakeup on %s level",
io_num, level ? "HIGH" : "LOW");
ESP_ERROR_CHECK( esp_deep_sleep_enable_ext1_wakeup(1ULL << io_num, level) );
ESP_ERROR_CHECK( esp_sleep_enable_ext1_wakeup(1ULL << io_num, level) );
}
esp_deep_sleep_start();
}