Skip to content

Commit ea52159

Browse files
committed
Resolve code formatting and style issues.
1 parent 31f7bb3 commit ea52159

File tree

2 files changed

+27
-38
lines changed

2 files changed

+27
-38
lines changed

README.md

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -116,27 +116,24 @@ its valid. For example:
116116
```
117117
#include <SoftwareSerial.h>
118118
119-
#define MYPORT_TX 12
120-
#define MYPORT_RX 13
119+
#define MYPORT_TX 12
120+
#define MYPORT_RX 13
121121
122122
SoftwareSerial myPort;
123123
124+
[...]
124125
125-
....
126-
127-
128-
Serial.begin(115200); // Standard hardware serial port
126+
Serial.begin(115200); // Standard hardware serial port
129127
130128
myPort.begin(38400, SWSERIAL_8N1, MYPORT_RX, MYPORT_TX, false);
131-
if (!myPort) { // If the object did not initilaise, then its configuration is invalid
129+
if (!myPort) { // If the object did not initialize, then its configuration is invalid
132130
Serial.println("Invalid SoftwareSerial pin configuration, check config");
133-
while (1) { // Can't continue with invalid configuration
134-
yield();
135-
delay (1000);
131+
while (1) { // Don't continue with invalid configuration
132+
delay (1000);
136133
}
137134
}
138135
139-
....
136+
[...]
140137
```
141138

142139
## Using and updating EspSoftwareSerial in the esp8266com/esp8266 Arduino build environment

src/SoftwareSerial.cpp

Lines changed: 19 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -49,31 +49,26 @@ SoftwareSerial::~SoftwareSerial() {
4949
bool SoftwareSerial::isValidGPIOpin(int8_t pin) {
5050
#if defined(ESP8266)
5151
return (pin >= 0 && pin <= 16) && !isFlashInterfacePin(pin);
52-
5352
#elif defined(ESP32)
54-
// Remove the strapping pins as defined in the datasheets, they affect bootup and other critical operations
55-
// Remmove the flash memory pins on related devices, since using these causes memory access issues.
56-
#ifdef CONFIG_IDF_TARGET_ESP32
53+
// Remove the strapping pins as defined in the datasheets, they affect bootup and other critical operations
54+
// Remmove the flash memory pins on related devices, since using these causes memory access issues.
55+
#ifdef CONFIG_IDF_TARGET_ESP32
5756
// Datasheet https://www.espressif.com/sites/default/files/documentation/esp32_datasheet_en.pdf,
5857
// Pinout https://docs.espressif.com/projects/esp-idf/en/latest/esp32/_images/esp32-devkitC-v4-pinout.jpg
59-
return (pin >= 1 && pin <= 1) || (pin >= 3 && pin <= 4) || (pin >= 13 && pin <= 14) ||
60-
(pin >= 16 && pin <= 19) || (pin >= 21 && pin <= 23) || (pin >= 25 && pin <= 27) ||
61-
(pin >= 32 && pin <= 39);
62-
63-
#elif CONFIG_IDF_TARGET_ESP32S2
58+
return (pin == 1) || (pin >= 3 && pin <= 4) || (pin >= 13 && pin <= 14) ||
59+
(pin >= 16 && pin <= 19) || (pin >= 21 && pin <= 23) || (pin >= 25 && pin <= 27) ||
60+
(pin >= 32 && pin <= 39);
61+
#elif CONFIG_IDF_TARGET_ESP32S2
6462
// Datasheet https://www.espressif.com/sites/default/files/documentation/esp32-s2_datasheet_en.pdf,
6563
// Pinout https://docs.espressif.com/projects/esp-idf/en/latest/esp32s2/_images/esp32-s2_saola1-pinout.jpg
6664
return (pin >= 1 && pin <= 21) || (pin >= 33 && pin <= 44);
67-
68-
#elif CONFIG_IDF_TARGET_ESP32C3
69-
// Datasheet https://www.espressif.com/sites/default/files/documentation/esp32-c3_datasheet_en.pdf,
70-
// Pinout https://docs.espressif.com/projects/esp-idf/en/latest/esp32c3/_images/esp32-c3-devkitm-1-v1-pinout.jpg
65+
#elif CONFIG_IDF_TARGET_ESP32C3
66+
// Datasheet https://www.espressif.com/sites/default/files/documentation/esp32-c3_datasheet_en.pdf,
67+
// Pinout https://docs.espressif.com/projects/esp-idf/en/latest/esp32c3/_images/esp32-c3-devkitm-1-v1-pinout.jpg
7168
return (pin >= 0 && pin <= 1) || (pin >= 3 && pin <= 7) || (pin >= 18 && pin <= 21);
72-
73-
#else
69+
#else
7470
return true;
75-
#endif
76-
71+
#endif
7772
#else
7873
return true;
7974
#endif
@@ -90,16 +85,13 @@ bool SoftwareSerial::isValidRxGPIOpin(int8_t pin) {
9085
bool SoftwareSerial::isValidTxGPIOpin(int8_t pin) {
9186
return isValidGPIOpin(pin)
9287
#if defined(ESP32)
93-
#ifdef CONFIG_IDF_TARGET_ESP32
94-
&& (pin < 34) // GPIO34 and above are input only, so cannot transmit
95-
96-
#elif CONFIG_IDF_TARGET_ESP32S2
97-
&& (pin < 46) // GPIO46 is an input only, so cannot transmit
98-
99-
#elif CONFIG_IDF_TARGET_ESP32C3
100-
// Nothing to do
101-
#endif
102-
88+
#ifdef CONFIG_IDF_TARGET_ESP32
89+
&& (pin < 34) // GPIO34 and above are input only
90+
#elif CONFIG_IDF_TARGET_ESP32S2
91+
&& (pin <= 45) // GPIO46 is input only
92+
#elif CONFIG_IDF_TARGET_ESP32C3
93+
// they are all input and output
94+
#endif
10395
#endif
10496
;
10597
}

0 commit comments

Comments
 (0)