Skip to content

Commit 7392f85

Browse files
committed
Fix to drop packets in Wire library (issue #335).
1 parent ea8a118 commit 7392f85

File tree

1 file changed

+6
-4
lines changed
  • libraries/Wire/utility

1 file changed

+6
-4
lines changed

Diff for: libraries/Wire/utility/twi.c

+6-4
Original file line numberDiff line numberDiff line change
@@ -413,12 +413,14 @@ SIGNAL(TWI_vect)
413413
if(twi_rxBufferIndex < TWI_BUFFER_LENGTH){
414414
twi_rxBuffer[twi_rxBufferIndex] = '\0';
415415
}
416+
// sends ack and stops interface for clock stretching
417+
twi_stop();
416418
// callback to user defined callback
417419
twi_onSlaveReceive(twi_rxBuffer, twi_rxBufferIndex);
418-
// ack future responses
419-
twi_reply(1);
420-
// leave slave receiver state
421-
twi_state = TWI_READY;
420+
// since we submit rx buffer to "wire" library, we can reset it
421+
twi_rxBufferIndex = 0;
422+
// ack future responses and leave slave receiver state
423+
twi_releaseBus();
422424
break;
423425
case TW_SR_DATA_NACK: // data received, returned nack
424426
case TW_SR_GCALL_DATA_NACK: // data received generally, returned nack

0 commit comments

Comments
 (0)