Merge pull request #1869 from kevin-pololu/due-wire-available

SAM Wire: fixed NACK/timeout behavior of requestFrom() and available()
This commit is contained in:
Martino Facchin 2015-07-01 12:43:44 +00:00
commit 98d0a72fdd
1 changed files with 4 additions and 2 deletions

View File

@ -143,8 +143,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);