From 27393e47c3162e42f516b7b5d47d26fe06b4bb56 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kuba=20Szczodrzy=C5=84ski?= Date: Wed, 23 Aug 2023 16:06:01 +0200 Subject: [PATCH] [beken-72xx] Initialize UART to fix deep sleep --- cores/beken-72xx/arduino/libraries/Serial/Serial.cpp | 4 ++++ cores/beken-72xx/base/api/lt_init.c | 5 +++++ cores/common/base/api/lt_sleep.h | 2 +- 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/cores/beken-72xx/arduino/libraries/Serial/Serial.cpp b/cores/beken-72xx/arduino/libraries/Serial/Serial.cpp index c4a071d..0aafcb9 100644 --- a/cores/beken-72xx/arduino/libraries/Serial/Serial.cpp +++ b/cores/beken-72xx/arduino/libraries/Serial/Serial.cpp @@ -47,6 +47,10 @@ void SerialClass::configure(unsigned long baudrate, uint16_t config) { .flow_control = FLOW_CTRL_DISABLED, }; + if (port == 1) + uart1_init(); + else if (port == 2) + uart2_init(); uart_hw_set_change(port, &cfg); uart_rx_callback_set(port, callback, &BUF); diff --git a/cores/beken-72xx/base/api/lt_init.c b/cores/beken-72xx/base/api/lt_init.c index 05d28b1..2064d73 100644 --- a/cores/beken-72xx/base/api/lt_init.c +++ b/cores/beken-72xx/base/api/lt_init.c @@ -6,4 +6,9 @@ void lt_init_family() { // set default UART output port uart_print_port = LT_UART_DEFAULT_PORT - 1; + // initialize the UART (needed e.g. after deep sleep) + if (uart_print_port == 1) + uart1_init(); + else if (uart_print_port == 2) + uart2_init(); } diff --git a/cores/common/base/api/lt_sleep.h b/cores/common/base/api/lt_sleep.h index 7c03bdf..2ccf0aa 100644 --- a/cores/common/base/api/lt_sleep.h +++ b/cores/common/base/api/lt_sleep.h @@ -21,7 +21,7 @@ void lt_deep_sleep_unset_gpio(uint32_t gpio_index_map); /** * @brief Set a sleep timer to wake up the device - * @param sleep_duration the time in seconds to sleep + * @param sleep_duration the time in milliseconds to sleep */ void lt_deep_sleep_config_timer(uint32_t sleep_duration);