Skip to content

fix bug #1354: I2C/TWI Library: Buffer Overflow #1363

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
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
10 changes: 8 additions & 2 deletions libraries/Wire/utility/twi.c
Original file line number Diff line number Diff line change
Expand Up @@ -475,8 +475,14 @@ ISR(TWI_vect)
break;
case TW_SR_DATA_NACK: // data received, returned nack
case TW_SR_GCALL_DATA_NACK: // data received generally, returned nack
// nack back at master
twi_reply(0);
// We replied a nack, this happens when the buffer overflows.
// After this interrupt we don't get a TW_SR_STOP interrupt, so
// clean up now

// Discard the data, it is incomplete
twi_rxBufferIndex = 0;
// ack future responses and leave slave receiver state
twi_releaseBus();
break;

// Slave Transmitter
Expand Down