From fb38cf37fdad543e11c28d48eb9f2376848f90b8 Mon Sep 17 00:00:00 2001 From: MrKevinWeiss Date: Wed, 14 Aug 2019 16:26:22 +0200 Subject: [PATCH] cpu/stm32: Fix read bytes flag for i2c_2 This commit stops a repeated start read which causes slave bus lockup When trying to do a repeaded start i2c_read_bytes it returns -EOPNOTSUPP error --- cpu/stm32_common/periph/i2c_2.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/cpu/stm32_common/periph/i2c_2.c b/cpu/stm32_common/periph/i2c_2.c index 7c1b38ddef..34fd0fd41e 100644 --- a/cpu/stm32_common/periph/i2c_2.c +++ b/cpu/stm32_common/periph/i2c_2.c @@ -218,6 +218,10 @@ 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)) { + return -EOPNOTSUPP; + } int ret = _start(i2c, (address << 1) | I2C_FLAG_READ, flags, length); if (ret < 0) { if (ret == -ETIMEDOUT) {