From 980720b5a0f19d71102f6f8cd0888e734245e86c Mon Sep 17 00:00:00 2001 From: Stephan Hadinger Date: Mon, 14 Jun 2021 19:36:21 +0200 Subject: [PATCH] Esp32c3 fix wrong baudrate --- tasmota/support.ino | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/tasmota/support.ino b/tasmota/support.ino index 21037bea6..dd85c9f07 100644 --- a/tasmota/support.ino +++ b/tasmota/support.ino @@ -984,10 +984,19 @@ String GetSerialConfig(void) { return String(config); } +#if defined(ESP32) && CONFIG_IDF_TARGET_ESP32C3 +// temporary workaround, see https://github.com/espressif/arduino-esp32/issues/5287 +#include +uint32_t GetSerialBaudrate(void) { + uint32_t br; + uart_get_baudrate(0, &br); + return (br / 300) * 300; // Fix ESP32 strange results like 115201 +} +#else uint32_t GetSerialBaudrate(void) { - // Serial.printf(">> GetSerialBaudrate baudrate = %d\n", Serial.baudRate()); return (Serial.baudRate() / 300) * 300; // Fix ESP32 strange results like 115201 } +#endif void SetSerialBegin(void) { TasmotaGlobal.baudrate = Settings->baudrate * 300; @@ -1019,9 +1028,7 @@ void SetSerialBaudrate(uint32_t baudrate) { TasmotaGlobal.baudrate = baudrate; Settings->baudrate = TasmotaGlobal.baudrate / 300; if (GetSerialBaudrate() != TasmotaGlobal.baudrate) { -#if defined(CONFIG_IDF_TARGET_ESP32C3) && !CONFIG_IDF_TARGET_ESP32C3 // crashes on ESP32C3 - TODO SetSerialBegin(); -#endif } }