-
Notifications
You must be signed in to change notification settings - Fork 274
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
In timing critical sections, use direct register access for digital r…
…ead/write. (#231) * In timing critical sections, use direct register access for digital read/write. Fixes #230 * ESP8266 specific register optimization. * Polymorphism over parameter evaluation. * It's OK to load lazyDelay from ROM on request. * Minor release, use port macros and new bit pattern test * Fix for specifics of ESP8266 UART's swap.
- Loading branch information
Showing
5 changed files
with
130 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
#include "SoftwareSerial.h" | ||
|
||
#ifndef D5 | ||
#if defined(ESP8266) | ||
#define D5 (14) | ||
#define D6 (12) | ||
#elif defined(ESP32) | ||
#define D5 (18) | ||
#define D6 (19) | ||
#endif | ||
#endif | ||
|
||
SoftwareSerial swSer; | ||
#ifdef ESP8266 | ||
auto logSer = SoftwareSerial(-1, TX); | ||
auto hwSer = Serial; | ||
#else | ||
auto logSer = Serial; | ||
auto hwSer = Serial1; | ||
#endif | ||
|
||
void setup() { | ||
delay(2000); | ||
#ifdef ESP8266 | ||
hwSer.begin(115200, SERIAL_8N1); | ||
hwSer.swap(); | ||
#else | ||
hwSer.begin(115200, SERIAL_8N1, -1, D5); | ||
#endif | ||
logSer.begin(115200); | ||
logSer.println(PSTR("\nOne Wire Half Duplex Bitpattern and Datarate Test")); | ||
swSer.begin(115200, SWSERIAL_8N1, D6, -1); | ||
swSer.enableIntTx(true); | ||
logSer.println(PSTR("Tx on hwSer")); | ||
} | ||
|
||
uint8_t val = 0xff; | ||
|
||
void loop() { | ||
hwSer.write((uint8_t)0x00); | ||
hwSer.write(val); | ||
hwSer.write(val); | ||
auto start = ESP.getCycleCount(); | ||
int rxCnt = 0; | ||
while (ESP.getCycleCount() - start < ESP.getCpuFreqMHz() * 1000000 / 10) { | ||
if (swSer.available()) { | ||
auto rxVal = swSer.read(); | ||
if ((!rxCnt && rxVal) || (rxCnt && rxVal != val)) { | ||
logSer.printf(PSTR("Rx bit error: tx = 0x%02x, rx = 0x%02x\n"), val, rxVal); | ||
} | ||
++rxCnt; | ||
} | ||
} | ||
if (rxCnt != 3) { | ||
logSer.printf(PSTR("Rx cnt error, tx = 0x%02x\n"), val); | ||
} | ||
++val; | ||
if (!val) { | ||
logSer.println("Starting over"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
name=EspSoftwareSerial | ||
version=6.15.2 | ||
version=6.16.0 | ||
author=Dirk Kaar, Peter Lerup | ||
maintainer=Dirk Kaar <[email protected]> | ||
sentence=Implementation of the Arduino software serial for ESP8266/ESP32. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters