Skip to content

Commit d5444c4

Browse files
authored
I2C clock phase correction in START condition (#8383)
* A clock phase correction in write_start(void) Some devices require the data wire SDA to be held down at the moment while the clock wire is pulled down too to execute the start condition (e.g. devices using "TinyWires.h" library). This change follows a behaviour of Arduino Wire.h library, where the SCL signal is pulled down in half of period of start condition. * Formatting of modification restyled * Removing mathematical operations from delay * Comments added
1 parent 076a4ed commit d5444c4

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

Diff for: cores/esp8266/core_esp8266_si2c.cpp

+5
Original file line numberDiff line numberDiff line change
@@ -247,8 +247,12 @@ bool Twi::write_start(void)
247247
return false;
248248
}
249249
busywait(twi_dcount);
250+
// A high-to-low transition on the SDA line while the SCL is high defines a START condition.
250251
SDA_LOW(twi_sda);
251252
busywait(twi_dcount);
253+
// An additional delay between the SCL line high-to-low transition and setting up the SDA line to prevent a STOP condition execute.
254+
SCL_LOW(twi_scl);
255+
busywait(twi_dcount);
252256
return true;
253257
}
254258

@@ -260,6 +264,7 @@ bool Twi::write_stop(void)
260264
SCL_HIGH(twi_scl);
261265
WAIT_CLOCK_STRETCH();
262266
busywait(twi_dcount);
267+
// A low-to-high transition on the SDA line while the SCL is high defines a STOP condition.
263268
SDA_HIGH(twi_sda);
264269
busywait(twi_dcount);
265270
return true;

0 commit comments

Comments
 (0)