Fix to drop packets in Wire library (issue #335).

This commit is contained in:
David A. Mellis 2010-09-16 01:22:36 +00:00
parent ea8a1182b8
commit 7392f8514d
1 changed files with 6 additions and 4 deletions

View File

@ -413,12 +413,14 @@ SIGNAL(TWI_vect)
if(twi_rxBufferIndex < TWI_BUFFER_LENGTH){
twi_rxBuffer[twi_rxBufferIndex] = '\0';
}
// sends ack and stops interface for clock stretching
twi_stop();
// callback to user defined callback
twi_onSlaveReceive(twi_rxBuffer, twi_rxBufferIndex);
// ack future responses
twi_reply(1);
// leave slave receiver state
twi_state = TWI_READY;
// since we submit rx buffer to "wire" library, we can reset it
twi_rxBufferIndex = 0;
// ack future responses and leave slave receiver state
twi_releaseBus();
break;
case TW_SR_DATA_NACK: // data received, returned nack
case TW_SR_GCALL_DATA_NACK: // data received generally, returned nack