Skip to content

Commit

Permalink
release TWI bus right after stop or repeated start is condition
Browse files Browse the repository at this point in the history
this resolves timing issues seen in arduino#1477
  • Loading branch information
sandeepmistry committed Aug 27, 2015
1 parent ece6500 commit 72b00a6
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions hardware/arduino/avr/libraries/Wire/utility/twi.c
Expand Up @@ -476,6 +476,8 @@ ISR(TWI_vect)
}
break;
case TW_SR_STOP: // stop or repeated start condition received
// ack future responses and leave slave receiver state
twi_releaseBus();
// put a null char after data if there's room
if(twi_rxBufferIndex < TWI_BUFFER_LENGTH){
twi_rxBuffer[twi_rxBufferIndex] = '\0';
Expand All @@ -484,8 +486,6 @@ ISR(TWI_vect)
twi_onSlaveReceive(twi_rxBuffer, twi_rxBufferIndex);
// 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
Expand Down

0 comments on commit 72b00a6

Please sign in to comment.