[[[slow]]]
parent
76f049e4c1
commit
43d45025d3
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue