Johannes Stratmann / mbed-dev

Fork of mbed-dev by mbed official

Revision:
34:bb6061527455
Parent:
0:9b334a45a8ff
Child:
74:9322579e4309
--- a/targets/hal/TARGET_STM/TARGET_STM32F7/i2c_api.c	Thu Dec 03 15:15:11 2015 +0000
+++ b/targets/hal/TARGET_STM/TARGET_STM32F7/i2c_api.c	Mon Dec 07 08:00:11 2015 +0000
@@ -183,6 +183,14 @@
     // Clear Acknowledge failure flag
     __HAL_I2C_CLEAR_FLAG(&I2cHandle, I2C_FLAG_AF);
 
+    // Wait the STOP condition has been previously correctly sent
+    timeout = FLAG_TIMEOUT;
+    while ((i2c->CR2 & I2C_CR2_STOP) == I2C_CR2_STOP){
+        if ((timeout--) == 0) {
+            return 1;
+        }
+    }
+
     // Generate the START condition
     i2c->CR2 |= I2C_CR2_START;