mirror of
https://github.com/arduino/Arduino.git
synced 2025-03-13 10:29:35 +01:00
SAM Wire: fixed NACK/timeout behavior of requestFrom() and available()
"readed" is no longer incremented in requestFrom() if TWI_WaitByteReceived() gets a NACK or times out. This corrects the behavior (return values) of requestFrom() and available() to match the Arduino reference. Fixes arduino/Arduino#1311
This commit is contained in:
parent
4e334b2e96
commit
c92206909d
@ -125,8 +125,10 @@ uint8_t TwoWire::requestFrom(uint8_t address, uint8_t quantity, uint8_t sendStop
|
||||
if (readed + 1 == quantity)
|
||||
TWI_SendSTOPCondition( twi);
|
||||
|
||||
TWI_WaitByteReceived(twi, RECV_TIMEOUT);
|
||||
rxBuffer[readed++] = TWI_ReadByte(twi);
|
||||
if (TWI_WaitByteReceived(twi, RECV_TIMEOUT))
|
||||
rxBuffer[readed++] = TWI_ReadByte(twi);
|
||||
else
|
||||
break;
|
||||
} while (readed < quantity);
|
||||
TWI_WaitTransferComplete(twi, RECV_TIMEOUT);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user