fix off by one error for twi reads with len != 1.

STOP must be requested before the last byte is received.
This commit is contained in:
Bernd Walter 2010-09-27 15:55:30 +00:00
parent da4dad492d
commit cd93636f3e

View File

@ -348,7 +348,7 @@ at91_twi_transfer(device_t dev, struct iic_msg *msgs, uint32_t nmsgs)
if ((sr = RD4(sc, TWI_SR)) & TWI_SR_RXRDY) {
len--;
*buf++ = RD4(sc, TWI_RHR) & 0xff;
if (len == 0 && msgs[i].len != 1)
if (len == 1)
WR4(sc, TWI_CR, TWI_CR_STOP);
}
}