Browse Source

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.
pull/3569/merge
Damien George 7 years ago
parent
commit
033c32e694
  1. 2
      ports/esp8266/esp_mphal.h

2
ports/esp8266/esp_mphal.h

@ -86,7 +86,7 @@ void mp_hal_pin_open_drain(mp_hal_pin_obj_t pin);
} while (0)
#define mp_hal_pin_od_high(p) do { \
if ((p) == 16) { WRITE_PERI_REG(RTC_GPIO_ENABLE, (READ_PERI_REG(RTC_GPIO_ENABLE) & ~1)); } \
else { gpio_output_set(1 << (p), 0, 1 << (p), 0); } \
else { gpio_output_set(0, 0, 0, 1 << (p)); /* set as input to avoid glitches */ } \
} while (0)
#define mp_hal_pin_read(p) pin_get(p)
#define mp_hal_pin_write(p, v) pin_set((p), (v))

Loading…
Cancel
Save