examples/console: add check for CONFIG_ESP_CONSOLE_UART_NUM

pull/5628/head
Ivan Grokhotkov 2020-05-12 14:54:55 +02:00
rodzic f07a7805a6
commit b767e6191d
1 zmienionych plików z 3 dodań i 2 usunięć

Wyświetl plik

@ -10,6 +10,7 @@
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
#include <ctype.h> #include <ctype.h>
#include <unistd.h>
#include "esp_log.h" #include "esp_log.h"
#include "esp_console.h" #include "esp_console.h"
#include "esp_system.h" #include "esp_system.h"
@ -295,13 +296,13 @@ static int light_sleep(int argc, char **argv)
if (io_count > 0) { if (io_count > 0) {
ESP_ERROR_CHECK( esp_sleep_enable_gpio_wakeup() ); ESP_ERROR_CHECK( esp_sleep_enable_gpio_wakeup() );
} }
if (CONFIG_ESP_CONSOLE_UART_NUM <= UART_NUM_1) { if (CONFIG_ESP_CONSOLE_UART_NUM >= 0 && CONFIG_ESP_CONSOLE_UART_NUM <= UART_NUM_1) {
ESP_LOGI(TAG, "Enabling UART wakeup (press ENTER to exit light sleep)"); ESP_LOGI(TAG, "Enabling UART wakeup (press ENTER to exit light sleep)");
ESP_ERROR_CHECK( uart_set_wakeup_threshold(CONFIG_ESP_CONSOLE_UART_NUM, 3) ); ESP_ERROR_CHECK( uart_set_wakeup_threshold(CONFIG_ESP_CONSOLE_UART_NUM, 3) );
ESP_ERROR_CHECK( esp_sleep_enable_uart_wakeup(CONFIG_ESP_CONSOLE_UART_NUM) ); ESP_ERROR_CHECK( esp_sleep_enable_uart_wakeup(CONFIG_ESP_CONSOLE_UART_NUM) );
} }
fflush(stdout); fflush(stdout);
uart_wait_tx_idle_polling(CONFIG_ESP_CONSOLE_UART_NUM); fsync(fileno(stdout));
esp_light_sleep_start(); esp_light_sleep_start();
esp_sleep_wakeup_cause_t cause = esp_sleep_get_wakeup_cause(); esp_sleep_wakeup_cause_t cause = esp_sleep_get_wakeup_cause();
const char *cause_str; const char *cause_str;