summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDamien George <damien.p.george@gmail.com>2018-03-12 12:45:09 +1100
committerDamien George <damien.p.george@gmail.com>2018-03-12 12:45:09 +1100
commit033c32e694199bbb68816883a857a77711d68a13 (patch)
tree50dfa8dffad56ffd6c1663e881558c7d3f1f92dc
parent4d3a92c67c9b1550eaf07d06ed74de996ee8fa3b (diff)
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.
-rw-r--r--ports/esp8266/esp_mphal.h2
1 files changed, 1 insertions, 1 deletions
diff --git a/ports/esp8266/esp_mphal.h b/ports/esp8266/esp_mphal.h
index 194e56f64..940ca4727 100644
--- a/ports/esp8266/esp_mphal.h
+++ b/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))