From 04a6d5513ba9e1790e27b080fbc8d3f286f99ea5 Mon Sep 17 00:00:00 2001 From: Theo Arends <11044339+arendst@users.noreply.github.com> Date: Thu, 4 Jul 2024 16:04:59 +0200 Subject: [PATCH] Prep serial IDF 5.2 support --- lib/default/TasmotaSerial-3.6.0/src/TasmotaSerial.cpp | 2 +- lib/default/TasmotaSerial-3.6.0/src/TasmotaSerial.h | 6 ++++++ lib/libesp32/ESP32-to-ESP8266-compat/src/esp8266toEsp32.h | 6 ------ tasmota/tasmota_xsns_sensor/xsns_53_sml.ino | 2 +- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/lib/default/TasmotaSerial-3.6.0/src/TasmotaSerial.cpp b/lib/default/TasmotaSerial-3.6.0/src/TasmotaSerial.cpp index 5f9b10561..2200e06ba 100644 --- a/lib/default/TasmotaSerial-3.6.0/src/TasmotaSerial.cpp +++ b/lib/default/TasmotaSerial-3.6.0/src/TasmotaSerial.cpp @@ -150,7 +150,7 @@ void TasmotaSerial::setTransmitEnablePin(int tx_enable_pin) { #ifdef ESP32 bool TasmotaSerial::freeUart(void) { - for (uint32_t i = SOC_UART_NUM -1; i >= 0; i--) { + for (uint32_t i = SOC_UART_HP_NUM -1; i >= 0; i--) { if (0 == bitRead(tasmota_serial_uart_bitmap, i)) { m_uart = uart_port_t(i); bitSet(tasmota_serial_uart_bitmap, m_uart); diff --git a/lib/default/TasmotaSerial-3.6.0/src/TasmotaSerial.h b/lib/default/TasmotaSerial-3.6.0/src/TasmotaSerial.h index da946d8eb..b380bec69 100644 --- a/lib/default/TasmotaSerial-3.6.0/src/TasmotaSerial.h +++ b/lib/default/TasmotaSerial-3.6.0/src/TasmotaSerial.h @@ -33,6 +33,12 @@ #ifdef ESP32 #include + +// IDF 5.2 has changed counting UART channels, SOC_UART_NUM includes now LP UARTS too for ESP32-C6 and -P4 +#ifndef SOC_UART_HP_NUM +#define SOC_UART_HP_NUM SOC_UART_NUM // Set new define SOC_UART_HP_NUM in pre IDF 5.2 to SOC_UART_NUM +#endif + #endif class TasmotaSerial : public Stream { diff --git a/lib/libesp32/ESP32-to-ESP8266-compat/src/esp8266toEsp32.h b/lib/libesp32/ESP32-to-ESP8266-compat/src/esp8266toEsp32.h index 5ff821a16..99a4b1b30 100644 --- a/lib/libesp32/ESP32-to-ESP8266-compat/src/esp8266toEsp32.h +++ b/lib/libesp32/ESP32-to-ESP8266-compat/src/esp8266toEsp32.h @@ -191,11 +191,5 @@ typedef int SerConfu8; #define LCD_CAM_LCD_UPDATE_REG LCD_CAM_LCD_UPDATE_M #endif // LCD_CAM_LCD_UPDATE_M -// IDF 5.2 has changed counting UART channels, SOC_UART_NUM includes now LP UARTS too -#ifdef SOC_UART_HP_NUM -#undef SOC_UART_NUM -#define SOC_UART_NUM SOC_UART_HP_NUM -#endif - #endif // ESP32 #endif // __ESP8266TOESP32_H__ diff --git a/tasmota/tasmota_xsns_sensor/xsns_53_sml.ino b/tasmota/tasmota_xsns_sensor/xsns_53_sml.ino index ec73da332..433af4462 100755 --- a/tasmota/tasmota_xsns_sensor/xsns_53_sml.ino +++ b/tasmota/tasmota_xsns_sensor/xsns_53_sml.ino @@ -3125,7 +3125,7 @@ void SML_Init(void) { uint16_t memory = 0; #ifdef ESP32 - uint32_t uart_index = SOC_UART_NUM - 1; + uint32_t uart_index = SOC_UART_HP_NUM - 1; #endif sml_globs.sml_send_blocks = 0;