From e638defff453102d5d0811f7b9a596682a21e9af Mon Sep 17 00:00:00 2001 From: Damien George Date: Wed, 9 May 2018 15:53:09 +1000 Subject: [PATCH] stm32/i2c: Make sure stop condition is sent after receiving addr nack. --- ports/stm32/i2c.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ports/stm32/i2c.c b/ports/stm32/i2c.c index 7421ae1bd2..63bd09ae5f 100644 --- a/ports/stm32/i2c.c +++ b/ports/stm32/i2c.c @@ -113,7 +113,8 @@ int i2c_start_addr(i2c_t *i2c, int rd_wrn, uint16_t addr, size_t len, bool stop) // Check if the slave responded or not if (i2c->ISR & I2C_ISR_NACKF) { - // If we get a NACK then I2C periph releases the bus, so don't send STOP + // If we get a NACK then I2C periph unconditionally sends a STOP + i2c_wait_isr_set(i2c, I2C_ISR_STOPF); // Don't leak errors from this call i2c->CR1 &= ~I2C_CR1_PE; return -MP_ENODEV; }