diff --git a/sys/arm/at91/at91_twi.c b/sys/arm/at91/at91_twi.c index 6442d07315b4..b101772ede20 100644 --- a/sys/arm/at91/at91_twi.c +++ b/sys/arm/at91/at91_twi.c @@ -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++);