Reduce TasmotaSerial iRam usage

Reduce TasmotaSerial iRam usage for core stage and Pre-2.6 (#6373)
This commit is contained in:
Theo Arends 2019-09-08 17:38:13 +02:00
parent 612654ffca
commit c44765d37f
7 changed files with 9 additions and 2 deletions

View File

@ -1,6 +1,6 @@
{
"name": "TasmotaSerial",
"version": "2.3.3",
"version": "2.3.4",
"keywords": [
"serial", "io", "TasmotaSerial"
],

View File

@ -1,5 +1,5 @@
name=TasmotaSerial
version=2.3.3
version=2.3.4
author=Theo Arends
maintainer=Theo Arends <theo@arends.com>
sentence=Implementation of software serial with hardware serial fallback for ESP8266.

View File

@ -27,6 +27,9 @@ extern "C" {
#include <TasmotaSerial.h>
// 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);