10000 esp8266/esp_mphal.h: Fix I2C glitching by using input mode for od_high. · micropython/micropython@033c32e · GitHub
[go: up one dir, main page]

Skip to content

Commit 033c32e

Browse files
committed
esp8266/esp_mphal.h: Fix I2C glitching by using input mode for od_high.
Certain pins (eg 4 and 5) seem to behave differently at the hardware level when in open-drain mode: they glitch when set "high" and drive the pin active high for a brief period before disabling the output driver. To work around this make the pin an input to let it float high.
1 parent 4d3a92c commit 033c32e

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

ports/esp8266/esp_mphal.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ void mp_hal_pin_open_drain(mp_hal_pin_obj_t pin);
8686
} while (0)
8787
#define mp_hal_pin_od_high(p) do { \
8888
if ((p) == 16) { WRITE_PERI_REG(RTC_GPIO_ENABLE, (READ_PERI_REG(RTC_GPIO_ENABLE) & ~1)); } \
89-
else { gpio_output_set(1 << (p), 0, 1 << (p), 0); } \
89+
else { gpio_output_set(0, 0, 0, 1 << (p)); /* set as input to avoid glitches */ } \
9090
} while (0)
9191
#define mp_hal_pin_read(p) pin_get(p)
9292
#define mp_hal_pin_write(p, v) pin_set((p), (v))

0 commit comments

Comments
 (0)
0