mirror of
https://github.com/arduino/Arduino.git
synced 2025-03-14 11:29:26 +01:00
release TWI bus right after stop or repeated start is condition
this resolves timing issues seen in #1477
This commit is contained in:
parent
589b411be7
commit
48ff3a10ad
@ -476,6 +476,8 @@ ISR(TWI_vect)
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case TW_SR_STOP: // stop or repeated start condition received
|
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
|
// put a null char after data if there's room
|
||||||
if(twi_rxBufferIndex < TWI_BUFFER_LENGTH){
|
if(twi_rxBufferIndex < TWI_BUFFER_LENGTH){
|
||||||
twi_rxBuffer[twi_rxBufferIndex] = '\0';
|
twi_rxBuffer[twi_rxBufferIndex] = '\0';
|
||||||
@ -484,8 +486,6 @@ ISR(TWI_vect)
|
|||||||
twi_onSlaveReceive(twi_rxBuffer, twi_rxBufferIndex);
|
twi_onSlaveReceive(twi_rxBuffer, twi_rxBufferIndex);
|
||||||
// since we submit rx buffer to "wire" library, we can reset it
|
// since we submit rx buffer to "wire" library, we can reset it
|
||||||
twi_rxBufferIndex = 0;
|
twi_rxBufferIndex = 0;
|
||||||
// ack future responses and leave slave receiver state
|
|
||||||
twi_releaseBus();
|
|
||||||
break;
|
break;
|
||||||
case TW_SR_DATA_NACK: // data received, returned nack
|
case TW_SR_DATA_NACK: // data received, returned nack
|
||||||
case TW_SR_GCALL_DATA_NACK: // data received generally, returned nack
|
case TW_SR_GCALL_DATA_NACK: // data received generally, returned nack
|
||||||
|
Loading…
x
Reference in New Issue
Block a user