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:
5:8a418c89e515
--- a/I2CSlaveRtos.h	Fri May 10 07:34:24 2013 +0000
+++ b/I2CSlaveRtos.h	Fri May 10 20:38:35 2013 +0000
@@ -60,6 +60,7 @@
      *  @returns
      *       0 on success,
      *   non-0 otherwise
+     * ... no! instead it returns number of bytes read minus one ... weird, guess its a bug in the official lib
      */
     int read(char *data, int length) {
         return m_drv.readSlave(data, length);
@@ -112,9 +113,25 @@
 
     /** Reset the I2C slave back into the known ready receiving state.
      */
-    void stop(void){
+    void stop(void) {
         m_drv.stopSlave();
     }
+
+
+    /// 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();
+    }
+
 };
 }