pasko-zh / brzo_i2c

Brzo I2C is a fast I2C Implementation written in Assembly for the esp8266
GNU General Public License v3.0
244 stars 47 forks source link

Clock stretch logic #43

Open beefeater94 opened 4 years ago

beefeater94 commented 4 years ago

It seems (correct me if I'm wrong) that BRZO uses the following clock stretch logic:

  1. Release SCL (i.e., set SCL HIGH).
  2. Wait time T equal to one half clock cycle.
  3. Read SCL. A. If SCL is still LOW, assume the slave is stretching clock. Wait for SCL to go HIGH, then let it stay HIGH for half-cycle time T, then bring it LOW to read/write the next bit. B. If SCL is HIGH, assume the slave is not stretching clock. Bring SCL LOW immediately to read/write the next bit.

The consequence is that if the slave stretches clock by an amount less than T, BRZO will not notice, will bring SCL LOW, and the SCL pulse could end up being very short. But I'm puzzled because BRZO seems to be deliberately coded in this way. Why? Am I missing something?