From 43d45025d38aad8a4a8689d3bda50de2fad75a2a Mon Sep 17 00:00:00 2001 From: Piotr Dobrowolski Date: Thu, 9 May 2019 20:18:18 +0200 Subject: [PATCH] [[[slow]]] --- app/application.cpp | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/app/application.cpp b/app/application.cpp index 2db7855..a2c11f1 100644 --- a/app/application.cpp +++ b/app/application.cpp @@ -21,7 +21,7 @@ private: int wpos = 0; int rpos = 0; - Timer bitTimer; + HardwareTimer bitTimer; // (HardwareTimerMode::eHWT_Maskable); int pin; @@ -35,6 +35,7 @@ private: static SoftwareSerial* instance; public: + SoftwareSerial() : bitTimer(eHWT_Maskable) { } bool write(uint8_t byte) { if (full()) { return false; @@ -57,8 +58,8 @@ public: return (wpos + 1) % BUFSIZE == rpos; } - void feedBit() { - Serial.printf("."); + void IRAM_ATTR feedBit() { + //Serial.write('.'); if (empty()) { bitnum = -startbits; end(); @@ -88,16 +89,16 @@ public: digitalWrite(pin, cb); } + static void IRAM_ATTR staticFeedBit(void) { + if (SoftwareSerial::instance) { + SoftwareSerial::instance->feedBit(); + } + } + void begin(int pin_, int rxtime) { pin = pin_; instance = this; - bitTimer.initializeMs(rxtime, *[]() { - // FIXME - //Serial.write('!'); - if (SoftwareSerial::instance) { - SoftwareSerial::instance->feedBit(); - } - }); + bitTimer.initializeMs(rxtime, &SoftwareSerial::staticFeedBit); } void start() { @@ -126,7 +127,7 @@ void tcpServerClientConnected (TcpClient* client) { System.setCpuFrequency(eCF_160MHz); if (clientcount == 0) { - tty.begin(DATA_TX, 20); + tty.begin(DATA_TX, 19); } clientcount++; @@ -138,7 +139,7 @@ void tcpServerClientConnected (TcpClient* client) { bool tcpServerClientReceive (TcpClient& client, char *data, int size) { for (int i = 0; i < size; i++) { tty.write(data[i]); - Serial.write(data[i]); + //Serial.write(data[i]); } return true; }