Skip to content

Commit b34be47

Browse files
authored
feat(gpio): update the log message to tell the solution for the error.
1 parent 54895fc commit b34be47

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

Diff for: cores/esp32/esp32-hal-gpio.c

+4-4
Original file line numberDiff line numberDiff line change
@@ -170,11 +170,11 @@ extern void ARDUINO_ISR_ATTR __digitalWrite(uint8_t pin, uint8_t val) {
170170
return;
171171
}
172172
#endif // RGB_BUILTIN
173-
// if the pin is not in GPIO mode, make it happen
174-
if (perimanGetPinBus(pin, ESP32_BUS_TYPE_GPIO) == NULL) {
175-
__pinMode(pin, OUTPUT);
173+
if (perimanGetPinBus(pin, ESP32_BUS_TYPE_GPIO) != NULL) {
174+
gpio_set_level((gpio_num_t)pin, val);
175+
} else {
176+
log_e("IO %i is not set as GPIO. Execute digitalMode(pin, OUTPUT) first.", pin);
176177
}
177-
gpio_set_level((gpio_num_t)pin, val);
178178
}
179179

180180
extern int ARDUINO_ISR_ATTR __digitalRead(uint8_t pin) {

0 commit comments

Comments
 (0)