mirror of
https://github.com/esp8266/Arduino.git
synced 2025-04-19 23:22:16 +03:00
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
This commit is contained in:
parent
076a4edf1e
commit
d5444c4aa3
@ -247,8 +247,12 @@ bool Twi::write_start(void)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
busywait(twi_dcount);
|
busywait(twi_dcount);
|
||||||
|
// A high-to-low transition on the SDA line while the SCL is high defines a START condition.
|
||||||
SDA_LOW(twi_sda);
|
SDA_LOW(twi_sda);
|
||||||
busywait(twi_dcount);
|
busywait(twi_dcount);
|
||||||
|
// An additional delay between the SCL line high-to-low transition and setting up the SDA line to prevent a STOP condition execute.
|
||||||
|
SCL_LOW(twi_scl);
|
||||||
|
busywait(twi_dcount);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -260,6 +264,7 @@ bool Twi::write_stop(void)
|
|||||||
SCL_HIGH(twi_scl);
|
SCL_HIGH(twi_scl);
|
||||||
WAIT_CLOCK_STRETCH();
|
WAIT_CLOCK_STRETCH();
|
||||||
busywait(twi_dcount);
|
busywait(twi_dcount);
|
||||||
|
// A low-to-high transition on the SDA line while the SCL is high defines a STOP condition.
|
||||||
SDA_HIGH(twi_sda);
|
SDA_HIGH(twi_sda);
|
||||||
busywait(twi_dcount);
|
busywait(twi_dcount);
|
||||||
return true;
|
return true;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user