From 72b2767a745024436fcda76a056d326781782654 Mon Sep 17 00:00:00 2001 From: s-hadinger <49731213+s-hadinger@users.noreply.github.com> Date: Fri, 6 Oct 2023 21:00:42 +0200 Subject: [PATCH] Fix compilation with Arduino 3 alpha 1 (#19690) --- .../berry_tasmota/src/be_serial_lib.c | 37 ++++++++++++++++++- 1 file changed, 35 insertions(+), 2 deletions(-) diff --git a/lib/libesp32/berry_tasmota/src/be_serial_lib.c b/lib/libesp32/berry_tasmota/src/be_serial_lib.c index 504afe0d27d7..3b2c4cfd76df 100644 --- a/lib/libesp32/berry_tasmota/src/be_serial_lib.c +++ b/lib/libesp32/berry_tasmota/src/be_serial_lib.c @@ -6,8 +6,7 @@ * 2 wire communication - I2C *******************************************************************/ #include "be_constobj.h" - -#include "esp32-hal.h" +#include "esp_idf_version.h" extern int b_serial_init(bvm *vm); extern int b_serial_deinit(bvm *vm); @@ -17,6 +16,40 @@ extern int b_serial_read(bvm *vm); extern int b_serial_available(bvm *vm); extern int b_serial_flush(bvm *vm); +#if ESP_IDF_VERSION_MAJOR < 5 + #include "esp32-hal.h" +#else + // it should be #include "HardwareSerial.h" + // but the C++ header cannot be included in a C file + // so there's a copy below + enum SerialConfig { + SERIAL_5N1 = 0x8000010, + SERIAL_6N1 = 0x8000014, + SERIAL_7N1 = 0x8000018, + SERIAL_8N1 = 0x800001c, + SERIAL_5N2 = 0x8000030, + SERIAL_6N2 = 0x8000034, + SERIAL_7N2 = 0x8000038, + SERIAL_8N2 = 0x800003c, + SERIAL_5E1 = 0x8000012, + SERIAL_6E1 = 0x8000016, + SERIAL_7E1 = 0x800001a, + SERIAL_8E1 = 0x800001e, + SERIAL_5E2 = 0x8000032, + SERIAL_6E2 = 0x8000036, + SERIAL_7E2 = 0x800003a, + SERIAL_8E2 = 0x800003e, + SERIAL_5O1 = 0x8000013, + SERIAL_6O1 = 0x8000017, + SERIAL_7O1 = 0x800001b, + SERIAL_8O1 = 0x800001f, + SERIAL_5O2 = 0x8000033, + SERIAL_6O2 = 0x8000037, + SERIAL_7O2 = 0x800003b, + SERIAL_8O2 = 0x800003f + }; +#endif + #include "be_fixed_be_class_serial.h" /* @const_object_info_begin