@@ -49,31 +49,26 @@ SoftwareSerial::~SoftwareSerial() {
49
49
bool SoftwareSerial::isValidGPIOpin (int8_t pin) {
50
50
#if defined(ESP8266)
51
51
return (pin >= 0 && pin <= 16 ) && !isFlashInterfacePin (pin);
52
-
53
52
#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
57
56
// Datasheet https://www.espressif.com/sites/default/files/documentation/esp32_datasheet_en.pdf,
58
57
// 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
64
62
// Datasheet https://www.espressif.com/sites/default/files/documentation/esp32-s2_datasheet_en.pdf,
65
63
// Pinout https://docs.espressif.com/projects/esp-idf/en/latest/esp32s2/_images/esp32-s2_saola1-pinout.jpg
66
64
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
71
68
return (pin >= 0 && pin <= 1 ) || (pin >= 3 && pin <= 7 ) || (pin >= 18 && pin <= 21 );
72
-
73
- #else
69
+ #else
74
70
return true ;
75
- #endif
76
-
71
+ #endif
77
72
#else
78
73
return true ;
79
74
#endif
@@ -90,16 +85,13 @@ bool SoftwareSerial::isValidRxGPIOpin(int8_t pin) {
90
85
bool SoftwareSerial::isValidTxGPIOpin (int8_t pin) {
91
86
return isValidGPIOpin (pin)
92
87
#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
103
95
#endif
104
96
;
105
97
}
0 commit comments