Skip to content

Commit

Permalink
Updated examples. Requires inverse logic support in ESP8266 HardwareS…
Browse files Browse the repository at this point in the history
…erial API.
  • Loading branch information
dok-net committed Nov 20, 2019
1 parent b1b0438 commit bbffcd2
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 10 deletions.
13 changes: 7 additions & 6 deletions examples/loopback/loopback.ino
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
#ifdef ESP32
constexpr int IUTBITRATE = 57600;
#else
constexpr int IUTBITRATE = 153600;
constexpr int IUTBITRATE = 74880;
#endif

#if defined(ESP8266)
Expand All @@ -45,6 +45,7 @@ constexpr uint32_t hwSerialConfig = SERIAL_8E1;
#else
constexpr unsigned swSerialConfig = 3;
#endif
constexpr bool invert = false;

constexpr int BLOCKSIZE = 16; // use fractions of 256

Expand Down Expand Up @@ -88,7 +89,7 @@ HardwareSerial& logger(Serial);
void setup() {
#if defined(ESP8266)
#if defined(HWLOOPBACK) || defined(HWSOURCESINK) || defined(HWSOURCESWSINK)
Serial.begin(IUTBITRATE, hwSerialConfig);
Serial.begin(IUTBITRATE, hwSerialConfig, SERIAL_FULL, 1, invert);
Serial.swap();
Serial.setRxBufferSize(2 * BLOCKSIZE);
logger.begin(9600, SWSERIAL_8N1, -1, TX);
Expand All @@ -97,11 +98,11 @@ void setup() {
#endif
#elif defined(ESP32)
#if defined(HWLOOPBACK) || defined(HWSOURCESWSINK)
Serial2.begin(IUTBITRATE, hwSerialConfig, D4, D3, false);
Serial2.begin(IUTBITRATE, hwSerialConfig, D4, D3, invert);
Serial2.setRxBufferSize(2 * BLOCKSIZE);
logger.begin(9600);
#elif defined(HWSOURCESINK)
serialIUT.begin(IUTBITRATE, hwSerialConfig, D5, D6);
serialIUT.begin(IUTBITRATE, hwSerialConfig, D5, D6, invert);
serialIUT.setRxBufferSize(2 * BLOCKSIZE);
logger.begin(9600);
#else
Expand All @@ -113,12 +114,12 @@ void setup() {

#if !defined(HWSOURCESINK)
#if defined(ESP8266)
serialIUT.begin(IUTBITRATE, swSerialConfig, D5, D6, false, 4 * BLOCKSIZE);
serialIUT.begin(IUTBITRATE, swSerialConfig, D5, D6, invert, 4 * BLOCKSIZE);
#ifdef HALFDUPLEX
serialIUT.enableIntTx(false);
#endif
#elif defined(ESP32)
serialIUT.begin(IUTBITRATE, swSerialConfig, D5, D6, false, 2 * BLOCKSIZE);
serialIUT.begin(IUTBITRATE, swSerialConfig, D5, D6, invert, 2 * BLOCKSIZE);
#ifdef HALFDUPLEX
serialIUT.enableIntTx(false);
#endif
Expand Down
5 changes: 3 additions & 2 deletions examples/repeater/repeater.ino
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,16 @@
#define D6 (12)
#define D7 (13)
#define D8 (15)
#define TX (1)
#endif

//#define HWLOOPBACK 1
//#define HALFDUPLEX 1

#ifdef ESP32
constexpr int IUTBITRATE = 19200;
constexpr int IUTBITRATE = 57600;
#else
constexpr int IUTBITRATE = 19200;
constexpr int IUTBITRATE = 74880;
#endif

constexpr SoftwareSerialConfig swSerialConfig = SWSERIAL_8N1;
Expand Down
2 changes: 1 addition & 1 deletion library.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "EspSoftwareSerial",
"version": "6.2.0",
"version": "6.2.2",
"keywords": [
"serial", "io", "softwareserial"
],
Expand Down
2 changes: 1 addition & 1 deletion library.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name=EspSoftwareSerial
version=6.2.0
version=6.2.2
author=Peter Lerup, Dirk Kaar
maintainer=Peter Lerup <[email protected]>
sentence=Implementation of the Arduino software serial for ESP8266/ESP32.
Expand Down

0 comments on commit bbffcd2

Please sign in to comment.