From c44765d37f8dc1d9c98b250968b94bb9b011d9ab Mon Sep 17 00:00:00 2001 From: Theo Arends <11044339+arendst@users.noreply.github.com> Date: Sun, 8 Sep 2019 17:38:13 +0200 Subject: [PATCH] Reduce TasmotaSerial iRam usage Reduce TasmotaSerial iRam usage for core stage and Pre-2.6 (#6373) --- lib/{TasmotaSerial-2.3.3 => TasmotaSerial-2.3.4}/README.md | 0 .../examples/swsertest/swsertest.ino | 0 .../keywords.txt | 0 .../library.json | 2 +- .../library.properties | 2 +- .../src/TasmotaSerial.cpp | 7 +++++++ .../src/TasmotaSerial.h | 0 7 files changed, 9 insertions(+), 2 deletions(-) rename lib/{TasmotaSerial-2.3.3 => TasmotaSerial-2.3.4}/README.md (100%) rename lib/{TasmotaSerial-2.3.3 => TasmotaSerial-2.3.4}/examples/swsertest/swsertest.ino (100%) rename lib/{TasmotaSerial-2.3.3 => TasmotaSerial-2.3.4}/keywords.txt (100%) rename lib/{TasmotaSerial-2.3.3 => TasmotaSerial-2.3.4}/library.json (94%) rename lib/{TasmotaSerial-2.3.3 => TasmotaSerial-2.3.4}/library.properties (94%) rename lib/{TasmotaSerial-2.3.3 => TasmotaSerial-2.3.4}/src/TasmotaSerial.cpp (96%) rename lib/{TasmotaSerial-2.3.3 => TasmotaSerial-2.3.4}/src/TasmotaSerial.h (100%) diff --git a/lib/TasmotaSerial-2.3.3/README.md b/lib/TasmotaSerial-2.3.4/README.md similarity index 100% rename from lib/TasmotaSerial-2.3.3/README.md rename to lib/TasmotaSerial-2.3.4/README.md diff --git a/lib/TasmotaSerial-2.3.3/examples/swsertest/swsertest.ino b/lib/TasmotaSerial-2.3.4/examples/swsertest/swsertest.ino similarity index 100% rename from lib/TasmotaSerial-2.3.3/examples/swsertest/swsertest.ino rename to lib/TasmotaSerial-2.3.4/examples/swsertest/swsertest.ino diff --git a/lib/TasmotaSerial-2.3.3/keywords.txt b/lib/TasmotaSerial-2.3.4/keywords.txt similarity index 100% rename from lib/TasmotaSerial-2.3.3/keywords.txt rename to lib/TasmotaSerial-2.3.4/keywords.txt diff --git a/lib/TasmotaSerial-2.3.3/library.json b/lib/TasmotaSerial-2.3.4/library.json similarity index 94% rename from lib/TasmotaSerial-2.3.3/library.json rename to lib/TasmotaSerial-2.3.4/library.json index 46a55b7dc..271deceb0 100644 --- a/lib/TasmotaSerial-2.3.3/library.json +++ b/lib/TasmotaSerial-2.3.4/library.json @@ -1,6 +1,6 @@ { "name": "TasmotaSerial", - "version": "2.3.3", + "version": "2.3.4", "keywords": [ "serial", "io", "TasmotaSerial" ], diff --git a/lib/TasmotaSerial-2.3.3/library.properties b/lib/TasmotaSerial-2.3.4/library.properties similarity index 94% rename from lib/TasmotaSerial-2.3.3/library.properties rename to lib/TasmotaSerial-2.3.4/library.properties index c99402e68..4dccb28ad 100644 --- a/lib/TasmotaSerial-2.3.3/library.properties +++ b/lib/TasmotaSerial-2.3.4/library.properties @@ -1,5 +1,5 @@ name=TasmotaSerial -version=2.3.3 +version=2.3.4 author=Theo Arends maintainer=Theo Arends sentence=Implementation of software serial with hardware serial fallback for ESP8266. diff --git a/lib/TasmotaSerial-2.3.3/src/TasmotaSerial.cpp b/lib/TasmotaSerial-2.3.4/src/TasmotaSerial.cpp similarity index 96% rename from lib/TasmotaSerial-2.3.3/src/TasmotaSerial.cpp rename to lib/TasmotaSerial-2.3.4/src/TasmotaSerial.cpp index 88151a8f1..472425336 100644 --- a/lib/TasmotaSerial-2.3.3/src/TasmotaSerial.cpp +++ b/lib/TasmotaSerial-2.3.4/src/TasmotaSerial.cpp @@ -27,6 +27,9 @@ extern "C" { #include +// 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]; @@ -105,7 +108,11 @@ TasmotaSerial::TasmotaSerial(int receive_pin, int transmit_pin, int hardware_fal m_bit_time = ESP.getCpuFreqMHz() * 1000000 / TM_SERIAL_BAUDRATE; 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); diff --git a/lib/TasmotaSerial-2.3.3/src/TasmotaSerial.h b/lib/TasmotaSerial-2.3.4/src/TasmotaSerial.h similarity index 100% rename from lib/TasmotaSerial-2.3.3/src/TasmotaSerial.h rename to lib/TasmotaSerial-2.3.4/src/TasmotaSerial.h