From 3d35c33cb28147d9ba51b5a822a63fee606f2d63 Mon Sep 17 00:00:00 2001 From: Hauke Petersen Date: Wed, 18 Nov 2015 14:57:15 +0100 Subject: [PATCH] cpu/stm32f1: fixed i2c driver the _stop() function now blocks until the transfer is complete. Not waiting can lead to concurrent bus access and subsequent to bus errors. --- cpu/stm32f1/periph/i2c.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/cpu/stm32f1/periph/i2c.c b/cpu/stm32f1/periph/i2c.c index f91684766..a43dfa49f 100644 --- a/cpu/stm32f1/periph/i2c.c +++ b/cpu/stm32f1/periph/i2c.c @@ -451,6 +451,8 @@ static inline void _stop(I2C_TypeDef *dev) while (!(dev->SR1 & I2C_SR1_BTF)); /* send STOP condition */ dev->CR1 |= I2C_CR1_STOP; + /* wait until transmission is complete */ + while (dev->SR2 & I2C_SR2_BUSY); } #if I2C_0_EN