From 0ec1fa5c48158edd61986b6ead7d5a28bf32ef22 Mon Sep 17 00:00:00 2001 From: Gijs Noorlander Date: Tue, 1 Oct 2019 23:16:38 +0200 Subject: [PATCH] Double I2C read in one transaction skips a clock pulse (#5528) See https://github.com/esp8266/Arduino/issues/5528 and the more elaborate [description](https://github.com/maarten-pennings/I2C-tool/blob/master/I2Ctest8266/README.md#how-to-fix) where @maarten-pennings did all the hard work, but as far as I could see, no PR was made. --- cores/esp8266/core_esp8266_si2c.cpp | 42 +++++++++++++++++++---------- 1 file changed, 28 insertions(+), 14 deletions(-) diff --git a/cores/esp8266/core_esp8266_si2c.cpp b/cores/esp8266/core_esp8266_si2c.cpp index 6f6cd58971..631e4b1493 100644 --- a/cores/esp8266/core_esp8266_si2c.cpp +++ b/cores/esp8266/core_esp8266_si2c.cpp @@ -197,13 +197,16 @@ static bool twi_write_start(void) { return true; } +static void ICACHE_RAM_ATTR twi_wait_clockStretchLimit() { + uint32_t t=0; while(SCL_READ()==0 && (t++)