bit I2C_Generate_Stop(void)
{
unsigned char retry; // don't want to be here for ever, this is a retry counter
[color=red]retry = 9;[/color]
I2C_DIO = 1;
while (retry--)
if (!I2C_DIO) // while the data line is low
{ // continue to pulse the clock
I2C_CLK = 1; // if DIO(SDA) = 0 then the CLK(SCL) alway running High-Low High-Low
I2C_NOP();
I2C_CLK = 0;
}
else
{ // when the data line actually is high
I2C_DIO = 0; // we can now execute a valid STOP
I2C_NOP();
I2C_CLK = 1;
I2C_NOP();
I2C_DIO = 1;
return(TRUE);
}
I2C_CLK = 1;
return (FALSE);
}