Skip to content

Commit 48ff3a1

Browse files
sandeepmistrycmaglie
authored andcommitted
release TWI bus right after stop or repeated start is condition
this resolves timing issues seen in #1477
1 parent 589b411 commit 48ff3a1

File tree

1 file changed

+2
-2
lines changed
  • hardware/arduino/avr/libraries/Wire/utility

1 file changed

+2
-2
lines changed

Diff for: hardware/arduino/avr/libraries/Wire/utility/twi.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -476,6 +476,8 @@ ISR(TWI_vect)
476476
}
477477
break;
478478
case TW_SR_STOP: // stop or repeated start condition received
479+
// ack future responses and leave slave receiver state
480+
twi_releaseBus();
479481
// put a null char after data if there's room
480482
if(twi_rxBufferIndex < TWI_BUFFER_LENGTH){
481483
twi_rxBuffer[twi_rxBufferIndex] = '\0';
@@ -484,8 +486,6 @@ ISR(TWI_vect)
484486
twi_onSlaveReceive(twi_rxBuffer, twi_rxBufferIndex);
485487
// since we submit rx buffer to "wire" library, we can reset it
486488
twi_rxBufferIndex = 0;
487-
// ack future responses and leave slave receiver state
488-
twi_releaseBus();
489489
break;
490490
case TW_SR_DATA_NACK: // data received, returned nack
491491
case TW_SR_GCALL_DATA_NACK: // data received generally, returned nack

0 commit comments

Comments
 (0)