rau cha / mbed-src-I2CWaitFix

Fork of mbed-src by mbed official

Revision:
13:bd9ff402dd42
Parent:
10:3bc89ef62ce7
--- a/vendor/NXP/LPC812/hal/i2c_api.c	Wed Jul 24 11:11:21 2013 +0100
+++ b/vendor/NXP/LPC812/hal/i2c_api.c	Mon Aug 05 02:27:27 2013 +0000
@@ -87,9 +87,13 @@
     return status;
 }
 
-inline void i2c_stop(i2c_t *obj) {
+inline int i2c_stop(i2c_t *obj) {
     obj->i2c->MSTCTL = (1 << 2) | (1 << 0);
-    while ((obj->i2c->STAT & ((1 << 0) | (7 << 1))) != ((1 << 0) | (0 << 1)));
+    while ((obj->i2c->STAT & ((1 << 0) | (7 << 1))) != ((1 << 0) | (0 << 1))){
+        timeout++;
+        if(timeout > 10000) return -1;
+    }
+    return 0;
 }