1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2025-01-18 12:52:44 +01:00

Merge pull request #12571 from MrKevinWeiss/pr/fix/stm32/i2c/rreadbytes

stm32_common/i2c_2: Fix repeated read condition
This commit is contained in:
Alexandre Abadie 2019-10-25 12:20:06 +02:00 committed by GitHub
commit 60748aee5d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -218,8 +218,13 @@ int i2c_read_bytes(i2c_t dev, uint16_t address, void *data, size_t length,
I2C_TypeDef *i2c = i2c_config[dev].dev;
DEBUG("[i2c] read_bytes: Starting\n");
/* Do not support repeated start reading */
if ((i2c->SR2 & I2C_SR2_BUSY) && !(flags & I2C_NOSTART)) {
/* Do not support repeated start reading
* The repeated start read requires the bus to be busy (I2C_SR2_BUSY == 1)
* the previous R/W state to be a read (I2C_SR2_TRA == 0)
* and for the command not to be split frame (I2C_NOSTART == 0)
*/
if (((i2c->SR2 & (I2C_SR2_BUSY | I2C_SR2_TRA)) == I2C_SR2_BUSY) &&
!(flags & I2C_NOSTART)) {
return -EOPNOTSUPP;
}
int ret = _start(i2c, (address << 1) | I2C_FLAG_READ, flags, length);