From 7d0d9b7782a9ce1c5b2e4b34666754ca3ad6aa43 Mon Sep 17 00:00:00 2001 From: Theo Arends <11044339+arendst@users.noreply.github.com> Date: Fri, 17 Jul 2020 18:00:17 +0200 Subject: [PATCH] Remove Arduino ESP8266 Core support before 2.7.1 --- .../README.md | 0 .../examples/swsertest/swsertest.ino | 0 .../keywords.txt | 0 .../library.json | 2 +- .../library.properties | 2 +- .../src/TasmotaSerial.cpp | 89 ++----------------- .../src/TasmotaSerial.h | 5 -- 7 files changed, 10 insertions(+), 88 deletions(-) rename lib/{TasmotaSerial-3.0.0 => TasmotaSerial-3.1.0}/README.md (100%) rename lib/{TasmotaSerial-3.0.0 => TasmotaSerial-3.1.0}/examples/swsertest/swsertest.ino (100%) rename lib/{TasmotaSerial-3.0.0 => TasmotaSerial-3.1.0}/keywords.txt (100%) rename lib/{TasmotaSerial-3.0.0 => TasmotaSerial-3.1.0}/library.json (94%) rename lib/{TasmotaSerial-3.0.0 => TasmotaSerial-3.1.0}/library.properties (94%) rename lib/{TasmotaSerial-3.0.0 => TasmotaSerial-3.1.0}/src/TasmotaSerial.cpp (79%) rename lib/{TasmotaSerial-3.0.0 => TasmotaSerial-3.1.0}/src/TasmotaSerial.h (91%) diff --git a/lib/TasmotaSerial-3.0.0/README.md b/lib/TasmotaSerial-3.1.0/README.md similarity index 100% rename from lib/TasmotaSerial-3.0.0/README.md rename to lib/TasmotaSerial-3.1.0/README.md diff --git a/lib/TasmotaSerial-3.0.0/examples/swsertest/swsertest.ino b/lib/TasmotaSerial-3.1.0/examples/swsertest/swsertest.ino similarity index 100% rename from lib/TasmotaSerial-3.0.0/examples/swsertest/swsertest.ino rename to lib/TasmotaSerial-3.1.0/examples/swsertest/swsertest.ino diff --git a/lib/TasmotaSerial-3.0.0/keywords.txt b/lib/TasmotaSerial-3.1.0/keywords.txt similarity index 100% rename from lib/TasmotaSerial-3.0.0/keywords.txt rename to lib/TasmotaSerial-3.1.0/keywords.txt diff --git a/lib/TasmotaSerial-3.0.0/library.json b/lib/TasmotaSerial-3.1.0/library.json similarity index 94% rename from lib/TasmotaSerial-3.0.0/library.json rename to lib/TasmotaSerial-3.1.0/library.json index 19197cce4..17764a8f2 100644 --- a/lib/TasmotaSerial-3.0.0/library.json +++ b/lib/TasmotaSerial-3.1.0/library.json @@ -1,6 +1,6 @@ { "name": "TasmotaSerial", - "version": "3.0.0", + "version": "3.1.0", "keywords": [ "serial", "io", "TasmotaSerial" ], diff --git a/lib/TasmotaSerial-3.0.0/library.properties b/lib/TasmotaSerial-3.1.0/library.properties similarity index 94% rename from lib/TasmotaSerial-3.0.0/library.properties rename to lib/TasmotaSerial-3.1.0/library.properties index d1d9e718a..8229443e9 100644 --- a/lib/TasmotaSerial-3.0.0/library.properties +++ b/lib/TasmotaSerial-3.1.0/library.properties @@ -1,5 +1,5 @@ name=TasmotaSerial -version=3.0.0 +version=3.1.0 author=Theo Arends maintainer=Theo Arends sentence=Implementation of software serial with hardware serial fallback for ESP8266 and ESP32. diff --git a/lib/TasmotaSerial-3.0.0/src/TasmotaSerial.cpp b/lib/TasmotaSerial-3.1.0/src/TasmotaSerial.cpp similarity index 79% rename from lib/TasmotaSerial-3.0.0/src/TasmotaSerial.cpp rename to lib/TasmotaSerial-3.1.0/src/TasmotaSerial.cpp index 6982779d5..0ceed70f5 100644 --- a/lib/TasmotaSerial-3.0.0/src/TasmotaSerial.cpp +++ b/lib/TasmotaSerial-3.1.0/src/TasmotaSerial.cpp @@ -29,66 +29,19 @@ extern "C" { #ifdef ESP8266 -// for STAGE and pre-2.6, we can have a single wrapper using attachInterruptArg() void ICACHE_RAM_ATTR callRxRead(void *self) { ((TasmotaSerial*)self)->rxRead(); }; // As the Arduino attachInterrupt has no parameter, lists of objects // and callbacks corresponding to each possible GPIO pins have to be defined TasmotaSerial *tms_obj_list[16]; -#ifdef TM_SERIAL_USE_IRAM -void ICACHE_RAM_ATTR tms_isr_0() { tms_obj_list[0]->rxRead(); }; -void ICACHE_RAM_ATTR tms_isr_1() { tms_obj_list[1]->rxRead(); }; -void ICACHE_RAM_ATTR tms_isr_2() { tms_obj_list[2]->rxRead(); }; -void ICACHE_RAM_ATTR tms_isr_3() { tms_obj_list[3]->rxRead(); }; -void ICACHE_RAM_ATTR tms_isr_4() { tms_obj_list[4]->rxRead(); }; -void ICACHE_RAM_ATTR tms_isr_5() { tms_obj_list[5]->rxRead(); }; -// Pin 6 to 11 can not be used -void ICACHE_RAM_ATTR tms_isr_12() { tms_obj_list[12]->rxRead(); }; -void ICACHE_RAM_ATTR tms_isr_13() { tms_obj_list[13]->rxRead(); }; -void ICACHE_RAM_ATTR tms_isr_14() { tms_obj_list[14]->rxRead(); }; -void ICACHE_RAM_ATTR tms_isr_15() { tms_obj_list[15]->rxRead(); }; -#else -void tms_isr_0() { tms_obj_list[0]->rxRead(); }; -void tms_isr_1() { tms_obj_list[1]->rxRead(); }; -void tms_isr_2() { tms_obj_list[2]->rxRead(); }; -void tms_isr_3() { tms_obj_list[3]->rxRead(); }; -void tms_isr_4() { tms_obj_list[4]->rxRead(); }; -void tms_isr_5() { tms_obj_list[5]->rxRead(); }; -// Pin 6 to 11 can not be used -void tms_isr_12() { tms_obj_list[12]->rxRead(); }; -void tms_isr_13() { tms_obj_list[13]->rxRead(); }; -void tms_isr_14() { tms_obj_list[14]->rxRead(); }; -void tms_isr_15() { tms_obj_list[15]->rxRead(); }; -#endif // TM_SERIAL_USE_IRAM - -static void (*ISRList[16])() = { - tms_isr_0, - tms_isr_1, - tms_isr_2, - tms_isr_3, - tms_isr_4, - tms_isr_5, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - tms_isr_12, - tms_isr_13, - tms_isr_14, - tms_isr_15 -}; - #else // ESP32 - static int tasmota_serial_index = 2; // Allow UART2 and UART1 only +static int tasmota_serial_index = 2; // Allow UART2 and UART1 only #endif // ESP8266 -TasmotaSerial::TasmotaSerial(int receive_pin, int transmit_pin, int hardware_fallback, int nwmode, int buffer_size) -{ +TasmotaSerial::TasmotaSerial(int receive_pin, int transmit_pin, int hardware_fallback, int nwmode, int buffer_size) { m_valid = false; m_hardserial = false; m_hardswap = false; @@ -118,11 +71,7 @@ TasmotaSerial::TasmotaSerial(int receive_pin, int transmit_pin, int hardware_fal m_bit_start_time = m_bit_time + m_bit_time/3 - 500; // pre-compute first wait pinMode(m_rx_pin, INPUT); tms_obj_list[m_rx_pin] = this; -#if defined(ARDUINO_ESP8266_RELEASE_2_3_0) || defined(ARDUINO_ESP8266_RELEASE_2_4_2) || defined(ARDUINO_ESP8266_RELEASE_2_5_2) - attachInterrupt(m_rx_pin, ISRList[m_rx_pin], (m_nwmode) ? CHANGE : FALLING); -#else attachInterruptArg(m_rx_pin, callRxRead, this, (m_nwmode) ? CHANGE : FALLING); -#endif } if (m_tx_pin > -1) { pinMode(m_tx_pin, OUTPUT); @@ -136,8 +85,7 @@ TasmotaSerial::TasmotaSerial(int receive_pin, int transmit_pin, int hardware_fal m_valid = true; } -TasmotaSerial::~TasmotaSerial() -{ +TasmotaSerial::~TasmotaSerial() { #ifdef ESP8266 if (!m_hardserial) { if (m_rx_pin > -1) { @@ -151,8 +99,7 @@ TasmotaSerial::~TasmotaSerial() #endif // ESP8266 } -bool TasmotaSerial::isValidGPIOpin(int pin) -{ +bool TasmotaSerial::isValidGPIOpin(int pin) { return (pin >= -1 && pin <= 5) || (pin >= 12 && pin <= 15); } @@ -234,8 +181,7 @@ int TasmotaSerial::peek() { } } -int TasmotaSerial::read() -{ +int TasmotaSerial::read() { if (m_hardserial) { #ifdef ESP8266 return Serial.read(); @@ -250,8 +196,7 @@ int TasmotaSerial::read() } } -int TasmotaSerial::available() -{ +int TasmotaSerial::available() { if (m_hardserial) { #ifdef ESP8266 return Serial.available(); @@ -265,23 +210,12 @@ int TasmotaSerial::available() } } -#ifdef TM_SERIAL_USE_IRAM #define TM_SERIAL_WAIT_SND { while (ESP.getCycleCount() < (wait + start)) if (!m_high_speed) optimistic_yield(1); wait += m_bit_time; } // Watchdog timeouts #define TM_SERIAL_WAIT_SND_FAST { while (ESP.getCycleCount() < (wait + start)); wait += m_bit_time; } #define TM_SERIAL_WAIT_RCV { while (ESP.getCycleCount() < (wait + start)); wait += m_bit_time; } #define TM_SERIAL_WAIT_RCV_LOOP { while (ESP.getCycleCount() < (wait + start)); } -#else -#define TM_SERIAL_WAIT_SND { while (ESP.getCycleCount() < (wait + start)); wait += m_bit_time; } -#define TM_SERIAL_WAIT_SND_FAST { while (ESP.getCycleCount() < (wait + start)); wait += m_bit_time; } -#define TM_SERIAL_WAIT_RCV { while (ESP.getCycleCount() < (wait + start)); wait += m_bit_time; } -#define TM_SERIAL_WAIT_RCV_LOOP { while (ESP.getCycleCount() < (wait + start)); } -#endif -#ifdef TM_SERIAL_USE_IRAM void ICACHE_RAM_ATTR TasmotaSerial::_fast_write(uint8_t b) { -#else -void TasmotaSerial::_fast_write(uint8_t b) { -#endif uint32_t wait = m_bit_time; uint32_t start = ESP.getCycleCount(); // Start bit; @@ -299,8 +233,7 @@ void TasmotaSerial::_fast_write(uint8_t b) { } } -size_t TasmotaSerial::write(uint8_t b) -{ +size_t TasmotaSerial::write(uint8_t b) { if (m_hardserial) { #ifdef ESP8266 return Serial.write(b); @@ -337,13 +270,7 @@ size_t TasmotaSerial::write(uint8_t b) } } -#ifdef TM_SERIAL_USE_IRAM -void ICACHE_RAM_ATTR TasmotaSerial::rxRead() -{ -#else -void TasmotaSerial::rxRead() -{ -#endif +void ICACHE_RAM_ATTR TasmotaSerial::rxRead() { if (!m_nwmode) { int32_t loop_read = m_very_high_speed ? serial_buffer_size : 1; // Advance the starting point for the samples but compensate for the diff --git a/lib/TasmotaSerial-3.0.0/src/TasmotaSerial.h b/lib/TasmotaSerial-3.1.0/src/TasmotaSerial.h similarity index 91% rename from lib/TasmotaSerial-3.0.0/src/TasmotaSerial.h rename to lib/TasmotaSerial-3.1.0/src/TasmotaSerial.h index 42a3f120e..bc5161d65 100644 --- a/lib/TasmotaSerial-3.0.0/src/TasmotaSerial.h +++ b/lib/TasmotaSerial-3.1.0/src/TasmotaSerial.h @@ -28,11 +28,6 @@ #define TM_SERIAL_BAUDRATE 9600 // Default baudrate #define TM_SERIAL_BUFFER_SIZE 64 // Receive buffer size -#include // Arduino_Esp8266 version information (ARDUINO_ESP8266_RELEASE and ARDUINO_ESP8266_RELEASE_2_3_0) -#ifndef ARDUINO_ESP8266_RELEASE_2_3_0 - #define TM_SERIAL_USE_IRAM // Enable to use iram (+368 bytes) -#endif - #include #include