mirror of
https://github.com/espressif/esp-idf.git
synced 2024-10-05 20:47:46 -04:00
examples console: Fix parts of the code related to deep sleep on ESP32-C3
Example not yet working on ESP32-C3, crashes in _findenv_r
This commit is contained in:
parent
b432fc8853
commit
241af87c58
@ -190,8 +190,10 @@ static void register_tasks(void)
|
|||||||
|
|
||||||
static struct {
|
static struct {
|
||||||
struct arg_int *wakeup_time;
|
struct arg_int *wakeup_time;
|
||||||
|
#if SOC_PM_SUPPORT_EXT_WAKEUP
|
||||||
struct arg_int *wakeup_gpio_num;
|
struct arg_int *wakeup_gpio_num;
|
||||||
struct arg_int *wakeup_gpio_level;
|
struct arg_int *wakeup_gpio_level;
|
||||||
|
#endif
|
||||||
struct arg_end *end;
|
struct arg_end *end;
|
||||||
} deep_sleep_args;
|
} deep_sleep_args;
|
||||||
|
|
||||||
@ -208,6 +210,8 @@ static int deep_sleep(int argc, char **argv)
|
|||||||
ESP_LOGI(TAG, "Enabling timer wakeup, timeout=%lluus", timeout);
|
ESP_LOGI(TAG, "Enabling timer wakeup, timeout=%lluus", timeout);
|
||||||
ESP_ERROR_CHECK( esp_sleep_enable_timer_wakeup(timeout) );
|
ESP_ERROR_CHECK( esp_sleep_enable_timer_wakeup(timeout) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if SOC_PM_SUPPORT_EXT_WAKEUP
|
||||||
if (deep_sleep_args.wakeup_gpio_num->count) {
|
if (deep_sleep_args.wakeup_gpio_num->count) {
|
||||||
int io_num = deep_sleep_args.wakeup_gpio_num->ival[0];
|
int io_num = deep_sleep_args.wakeup_gpio_num->ival[0];
|
||||||
if (!esp_sleep_is_valid_wakeup_gpio(io_num)) {
|
if (!esp_sleep_is_valid_wakeup_gpio(io_num)) {
|
||||||
@ -226,26 +230,36 @@ static int deep_sleep(int argc, char **argv)
|
|||||||
io_num, level ? "HIGH" : "LOW");
|
io_num, level ? "HIGH" : "LOW");
|
||||||
|
|
||||||
ESP_ERROR_CHECK( esp_sleep_enable_ext1_wakeup(1ULL << io_num, level) );
|
ESP_ERROR_CHECK( esp_sleep_enable_ext1_wakeup(1ULL << io_num, level) );
|
||||||
|
ESP_LOGE(TAG, "GPIO wakeup from deep sleep currently unsupported on ESP32-C3");
|
||||||
}
|
}
|
||||||
|
#endif // SOC_PM_SUPPORT_EXT_WAKEUP
|
||||||
rtc_gpio_isolate(GPIO_NUM_12);
|
rtc_gpio_isolate(GPIO_NUM_12);
|
||||||
esp_deep_sleep_start();
|
esp_deep_sleep_start();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void register_deep_sleep(void)
|
static void register_deep_sleep(void)
|
||||||
{
|
{
|
||||||
|
int num_args = 1;
|
||||||
deep_sleep_args.wakeup_time =
|
deep_sleep_args.wakeup_time =
|
||||||
arg_int0("t", "time", "<t>", "Wake up time, ms");
|
arg_int0("t", "time", "<t>", "Wake up time, ms");
|
||||||
|
#if SOC_PM_SUPPORT_EXT_WAKEUP
|
||||||
deep_sleep_args.wakeup_gpio_num =
|
deep_sleep_args.wakeup_gpio_num =
|
||||||
arg_int0(NULL, "io", "<n>",
|
arg_int0(NULL, "io", "<n>",
|
||||||
"If specified, wakeup using GPIO with given number");
|
"If specified, wakeup using GPIO with given number");
|
||||||
deep_sleep_args.wakeup_gpio_level =
|
deep_sleep_args.wakeup_gpio_level =
|
||||||
arg_int0(NULL, "io_level", "<0|1>", "GPIO level to trigger wakeup");
|
arg_int0(NULL, "io_level", "<0|1>", "GPIO level to trigger wakeup");
|
||||||
deep_sleep_args.end = arg_end(3);
|
num_args += 2;
|
||||||
|
#endif
|
||||||
|
deep_sleep_args.end = arg_end(num_args);
|
||||||
|
|
||||||
const esp_console_cmd_t cmd = {
|
const esp_console_cmd_t cmd = {
|
||||||
.command = "deep_sleep",
|
.command = "deep_sleep",
|
||||||
.help = "Enter deep sleep mode. "
|
.help = "Enter deep sleep mode. "
|
||||||
|
#if SOC_PM_SUPPORT_EXT_WAKEUP
|
||||||
"Two wakeup modes are supported: timer and GPIO. "
|
"Two wakeup modes are supported: timer and GPIO. "
|
||||||
|
#else
|
||||||
|
"Timer wakeup mode is supported. "
|
||||||
|
#endif
|
||||||
"If no wakeup option is specified, will sleep indefinitely.",
|
"If no wakeup option is specified, will sleep indefinitely.",
|
||||||
.hint = NULL,
|
.hint = NULL,
|
||||||
.func = &deep_sleep,
|
.func = &deep_sleep,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user