diff options
author | Sandeep Mistry <s.mistry@arduino.cc> | 2015-08-27 10:57:20 -0400 |
---|---|---|
committer | Cristian Maglie <c.maglie@arduino.cc> | 2015-10-22 16:29:43 +0200 |
commit | 48bcef5a15f1b17aee877bdb8cf77c6b45faaa6e (patch) | |
tree | 638592d393ee48c153b5262eb96377c98c9c9135 /libraries/Wire | |
parent | e8f7996e9a7027cb404b00eb0c6d5fa421c5ec06 (diff) |
release TWI bus right after stop or repeated start is condition
this resolves timing issues seen in #1477
Diffstat (limited to 'libraries/Wire')
-rw-r--r-- | libraries/Wire/utility/twi.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/libraries/Wire/utility/twi.c b/libraries/Wire/utility/twi.c index b436e69..9fb87f1 100644 --- a/libraries/Wire/utility/twi.c +++ b/libraries/Wire/utility/twi.c @@ -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'; @@ -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 |