I2CRTOS Driver by Helmut Schmücker. Removed included mbed-rtos library to prevent multiple definition. Make sure to include mbed-rtos library in your program!

Fork of I2cRtosDriver by Helmut Schmücker

Revision:
13:530968937ccb
Parent:
7:04824382eafb
Child:
16:2c6432b37cce
diff -r 6ddadcbbdca2 -r 530968937ccb I2CMasterRtos.h
--- a/I2CMasterRtos.h	Fri May 10 07:34:24 2013 +0000
+++ b/I2CMasterRtos.h	Fri May 10 20:38:35 2013 +0000
@@ -112,14 +112,29 @@
     /** Creates a start condition on the I2C bus
      */
 
-    void startMaster(void) {
+    void start(void) {
         m_drv.startMaster();
     }
 
-    /** Creates a stop condition on the I2C bus
-     */
-    void stop(void) {
-        m_drv.stopMaster();
+    /// Creates a stop condition on the I2C bus
+    /// If unsccessful because someone on the bus holds the scl line down it returns "false" after 23µs 
+    /// In normal operation the stop shouldn't take longer than 12µs @ 100kHz and 3-4µs @ 400kHz. 
+    bool stop(void) {
+        return m_drv.stopMaster();
+    }
+
+    /// Wait until the interface becomes available.
+    ///
+    /// Useful if you want to run a sequence of command without interrution by another thread.
+    /// There's no need to call this function for running single request, because all driver functions
+    /// will lock the device for exclusive access automatically.
+    void lock() {
+        m_drv.lock();
+    }
+
+    /// Unlock the interface that has previously been locked by the same thread.
+    void unlock() {
+        m_drv.unlock();
     }
 
 };