Skip to content

I2C/Wire library: changes for issue #42 #107

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 17 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
don't forget operating slave address or the bitrate when we reset bec…
…ause of a timeout
  • Loading branch information
greyltc committed Sep 16, 2019
commit bc0e699d8df8af26b943ff06fade20aacd2c0d69
11 changes: 11 additions & 0 deletions libraries/Wire/src/utility/twi.c
Original file line number Diff line number Diff line change
Expand Up @@ -443,8 +443,19 @@ void twi_setTimeoutInMicros(uint16_t timeout)
*/
void twi_handleTimeout(void)
{
// remember the bitrate register value
uint8_t previous_TWBR = TWBR;

// remember the address register value
uint8_t previous_TWAR = TWBR;

// reset the interface
twi_disable();
twi_init();

// reapply the previous register values
TWAR = previous_TWAR;
TWBR = previous_TWAR;
}

ISR(TWI_vect)
Expand Down