1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00

cpu/sam0/i2c: Handle read with I2C_NOSTOP flag

When using the I2C_NOSTOP flag the bus should remain in control.
The current check assumes it must go to idle when reading.
This adds a condition checks if the nostop flag is active
and expects the bus status to be the owner of the bus.
This commit is contained in:
MrKevinWeiss 2021-07-01 14:50:51 +02:00
parent c5a1012695
commit cead7a5877

View File

@ -262,8 +262,14 @@ int i2c_read_bytes(i2c_t dev, uint16_t addr,
return ret;
}
/* Ensure all bytes has been read */
while ((bus(dev)->STATUS.reg & SERCOM_I2CM_STATUS_BUSSTATE_Msk)
!= BUSSTATE_IDLE) {}
if (flags & I2C_NOSTOP) {
while ((bus(dev)->STATUS.reg & SERCOM_I2CM_STATUS_BUSSTATE_Msk)
!= BUSSTATE_OWNER) {}
}
else {
while ((bus(dev)->STATUS.reg & SERCOM_I2CM_STATUS_BUSSTATE_Msk)
!= BUSSTATE_IDLE) {}
}
/* return number of bytes sent */
return 0;
}