Skip to content

Conversation

@lonerzzz
Copy link
Contributor

Because of two situations, reboot and bus error, in which the ESP32 I2C state machine can get into a non-recoverable state where the busy flag remains set, potentially causing lockup or preventing I2C from running, the reset function has been added at the HAL layer and made available from Wire.

An attempt was made to time out operations and have i2cReset called internally, but that ended up creating more problems than it solved because the slave may need to release the line(s) first. At this point anyone who runs into bus errors that leave the I2C unusable after SDA and SCL go high can call the reset() function to reset the hardware I2C elements.

if (i2c->dev->status_reg.bus_busy) // If this condition is true, the while loop will timeout as done will not be set
{
//log_e("Busy at initialization!");
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe leave the error uncommented? otherwise what is the point of the check? :P

Copy link
Contributor Author

@lonerzzz lonerzzz Sep 29, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The fact that you commented means it served its point. :) I left it commented out since I wanted to highlight where the error comes into play and because of the fact most errors don't have error logging enabled in the read and write methods so was unsure when we want to show and not show.

I can certainly add it with any others we think should be there.

Any other concerns?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can uncomment the logs, since when I wrote it there was no way to control the log level :P now there is :)

@me-no-dev me-no-dev merged commit 0cd6285 into master Sep 29, 2017
@me-no-dev me-no-dev deleted the i2cReset branch September 29, 2017 13:17
@lonerzzz
Copy link
Contributor Author

Perfect, thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants