From 2e37add109e445675eaba91a35f3b422b703bb31 Mon Sep 17 00:00:00 2001 From: MrKevinWeiss Date: Mon, 25 Mar 2019 12:19:31 +0100 Subject: [PATCH] cpu/stm32_common: Fix i2c_2 NACK stopping twice There is an error when the start byte NACKs The nack sets the stop bit twice which keeps the stop bit high the next time When the stop bit is high it creates a timeout when trying to use This commit fixes so when a NACK occures on the address it doesn't stop twice --- cpu/stm32_common/periph/i2c_2.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cpu/stm32_common/periph/i2c_2.c b/cpu/stm32_common/periph/i2c_2.c index b3c7a37c06b0..196d4922252a 100644 --- a/cpu/stm32_common/periph/i2c_2.c +++ b/cpu/stm32_common/periph/i2c_2.c @@ -329,7 +329,7 @@ static int _start(I2C_TypeDef *i2c, uint8_t address_byte, uint8_t flags, ret = _is_sr1_mask_set(i2c, I2C_SR1_ADDR, flags & ~I2C_NOSTOP); if (ret == -EIO){ /* Since NACK happened during start it means no device connected */ - ret = -ENXIO; + return -ENXIO; } /* Needed to clear address bit */ i2c->SR2;