We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent b34be47 commit 97d78bcCopy full SHA for 97d78bc
cores/esp32/esp32-hal-gpio.c
@@ -182,11 +182,10 @@ extern int ARDUINO_ISR_ATTR __digitalRead(uint8_t pin) {
182
if (pin == RGB_BUILTIN) {
183
return RGB_BUILTIN_storage;
184
}
185
-#endif
186
-
187
- // if the pin is not in GPIO mode, make it happen
188
- if (perimanGetPinBus(pin, ESP32_BUS_TYPE_GPIO) == NULL) {
189
- __pinMode(pin, INPUT);
+#endif // RGB_BUILTIN
+ // This work when the pin is set as GPIO and in INPUT mode. For all other pin functions, it may return inconsistent response
+ if (perimanGetPinBus(pin, ESP32_BUS_TYPE_GPIO) != NULL) {
+ log_w("IO %i is not set as GPIO. digitalRead() may return an inconsistent value.");
190
191
return gpio_get_level((gpio_num_t)pin);
192
0 commit comments