UPDATE: Code snippet already done below. Not sure if correct.
I implemented the routine which is found in Microchip's datasheet in order to reset the EEPROM memory (24LC512)in case it hangs up. But not sure it is correct.
Many people in the internet commented on doing this, but no code "in the wild" yet. Maybe it's about time...
http://ww1.microchip.com/downloads/en/AppNotes/01028a.pdf
I made a draft. I am asking for comments as I can't test this.
Wire1.end();
const int SDA=70;
const int SCL=71;
pinMode(SDA, OUTPUT); //70 -> SDA1
pinMode(71, OUTPUT); //71 -> SCL2.
/* Send START condition */
//A HIGH to LOW transition on the SDA line while SCL is HIGH defines a START condition.
digitalWrite(71, HIGH);
delayMicroseconds(5);
digitalWrite(SDA, HIGH);
delayMicroseconds(5);
digitalWrite(SDA, LOW);
delayMicroseconds(5);
digitalWrite(71, LOW);
digitalWrite(SDA, HIGH); //WRONG?? " while allowing the SDA line to float," https://www.microchip.com/forums/m898899.aspx
//send 9 clock pulses to reset slaves
for(int i = 0; i < 9; i++){
digitalWrite(71, HIGH);
delayMicroseconds(5);
digitalWrite(71, LOW);
}
/* Send START condition */
//A HIGH to LOW transition on the SDA line while SCL is HIGH defines a START condition.
digitalWrite(71, HIGH);
delayMicroseconds(5);
digitalWrite(SDA, HIGH);
delayMicroseconds(5);
digitalWrite(SDA, LOW);
delayMicroseconds(5);
digitalWrite(71, LOW);
/* Send STOP condition */
//A LOW to HIGH transition on the SDA line while SCL is HIGH defines a STOP condition.
digitalWrite(71, HIGH);
delayMicroseconds(5);
digitalWrite(SDA, LOW);
delayMicroseconds(5);
digitalWrite(SDA, HIGH);
delayMicroseconds(5);
digitalWrite(71, LOW);
Wire1.begin();
```