# Understand an I2C clock line implementation

I am trying to understand a C function from a legacy project which is supposed to manage the clock line for an I2C interface. It basically does as follow:

• Set pin to output: P0_1 |= 0b00000010; and then drives it low: P0_1 = 0;.
• Or set as input: P0_1 &= 0b11111101; and wait for the clock line to be high: while (!P0_1) { wait(1); }.

What I don't understand is the second case, code comment says:

Set as input with pull-up to wait for the slave to be ready before driving the clock line to high.

How does this work? Is this how the master slows down its clock rate to let the slave follows it?

• Do you know how I2C works (not the code but the actual protocol)? If not, you should read the specification. – Eugene Sh. Oct 26 '20 at 15:46
• I am working on it! I just don't understand this implementation, other examples on the internet simply uses a delay for the slave to capture the falling or rising of the SCL... – Cinn Oct 26 '20 at 15:55