The TWI controller automatically stops if we don't fill up with new data in

time.
This commit is contained in:
Bernd Walter 2010-09-27 15:58:19 +00:00
parent 8f3ec30476
commit 974dd68e5c

View File

@ -338,7 +338,7 @@ at91_twi_transfer(device_t dev, struct iic_msg *msgs, uint32_t nmsgs)
err = EINVAL;
goto out;
}
if (len == 1)
if (len == 1 && msgs[i].flags & IIC_M_RD)
WR4(sc, TWI_CR, TWI_CR_START | TWI_CR_STOP);
else
WR4(sc, TWI_CR, TWI_CR_START);
@ -358,8 +358,6 @@ at91_twi_transfer(device_t dev, struct iic_msg *msgs, uint32_t nmsgs)
}
} else {
while (len--) {
if (len == 0 && msgs[i].len != 1)
WR4(sc, TWI_CR, TWI_CR_STOP);
if ((err = at91_twi_wait(sc, TWI_SR_TXRDY)))
goto out;
WR4(sc, TWI_THR, *buf++);