Helmut Schmücker / mbed-RtosI2cDriver

Dependencies:   mbed-rtos mbed-src

Files at this revision

API Documentation at this revision

Comitter:
humlet
Date:
Sat Apr 20 11:56:35 2013 +0000
Parent:
4:eafa7efcd771
Child:
6:5b98c902a659
Commit message:
pre-publish

Changed in this revision

I2CDriver.cpp Show annotated file Show diff for this revision Revisions of this file
I2CDriver.h Show annotated file Show diff for this revision Revisions of this file
I2CMasterRtos.h Show annotated file Show diff for this revision Revisions of this file
I2CSlaveRtos.h Show annotated file Show diff for this revision Revisions of this file
mbed-NXP.lib Show annotated file Show diff for this revision Revisions of this file
mbed-src.lib Show annotated file Show diff for this revision Revisions of this file
--- a/I2CDriver.cpp	Sat Apr 20 09:52:09 2013 +0000
+++ b/I2CDriver.cpp	Sat Apr 20 11:56:35 2013 +0000
@@ -5,7 +5,7 @@
 using namespace mbed;
 using namespace rtos;
 
-#define I2C_ISR_DRV_SIG (1<<7)
+//#define I2C_ISR_DRV_SIG (1<<7)
 #define DRV_USR_SIG (1<<6)
 
 const PinName I2CDriver::c_sdas[] = {p9,p28};
--- a/I2CDriver.h	Sat Apr 20 09:52:09 2013 +0000
+++ b/I2CDriver.h	Sat Apr 20 11:56:35 2013 +0000
@@ -10,11 +10,12 @@
 
 namespace mbed
 {
-/// class i2c driver
+/// I2C driver based on mbed RTOS and I2C-C-API.
+/// Supports Master and Slave mode
 class I2CDriver
 {
 public:
-
+    /// Status returned by the receiveSlave() function
     enum SlaveRxStatus {
         NoData         = 0,
         ReadAddressed  = 1,
@@ -22,10 +23,12 @@
         WriteAddressed = 3
     };
 
-    /** Create an I2C Master interface, connected to the specified pins
+    /** Create an I2C Master interface, connected to the specified pins.
      *
      *  @param sda I2C data line pin
      *  @param scl I2C clock line pin
+     *
+     *  @note Has to be created in a thread context, i.e. within the main or some other function. A global delaration does not work
      */
     I2CDriver(PinName sda, PinName scl, int hz=100000, int slaveAdr=0);
 
@@ -194,7 +197,7 @@
     }
 
 protected:
-
+    // commands sent from user to drive thread 
     enum Command {
         START,
         STOP,
@@ -207,7 +210,8 @@
         WRITE_BYTE,
         RECEIVE
     };
-
+    
+    // data transfer struct for communication between user and driver thread
     struct Transfer {
         Command cmd;
         int ret;
@@ -224,27 +228,36 @@
         osThreadId caller;
     };
 
+    // structure that holds handles/locks for accessing the I2C channels 
     struct Channel {
-        volatile osThreadId driver; // evillive: do we really need that volatile
+        osThreadId driver; 
         rtos::Mutex  mutex;
         volatile Transfer transfer;
     };
-
+    
+    // current frequency setting
     int m_freq;
+    // current slave address setting
     int m_slaveAdr;
-
+    
+    // the pin names fo the i2c channels
     static const PinName c_sdas[2];
     static const PinName c_scls[2];
 
+    // static storage for the I2C channel access objects  
     static Channel* s_channels[2];
-
+    
+    // i2c channel object of this driver interface, in fact just pointer
+    /// to one of the entries in s_channels
     Channel* m_channel;
-
+    
+    // ISRs  
     static void channel_0_ISR();
     static void channel_1_ISR();
-
+    
+    // the driver thread function
     static void threadFun(void const *args);
-
+    
     int sendNwait();
 };
 }
--- a/I2CMasterRtos.h	Sat Apr 20 09:52:09 2013 +0000
+++ b/I2CMasterRtos.h	Sat Apr 20 11:56:35 2013 +0000
@@ -8,7 +8,7 @@
 
 /// I2C master interface to the RTOS-I2CDriver.
 /// The interface is compatible to the original mbed I2C class.
-/// Provides an additonal read from register function.
+/// Provides an additonal "read from register"-function.
 class I2CMasterRtos
 {
     I2CDriver m_drv;
@@ -18,6 +18,8 @@
     *
     *  @param sda I2C data line pin
     *  @param scl I2C clock line pin
+    *
+    *  @note Has to be created in a thread context, i.e. within the main or some other function. A global delaration does not work
     */
     I2CMasterRtos(PinName sda, PinName scl, int freq=100000):m_drv(sda,scl,freq) {}
 
--- a/I2CSlaveRtos.h	Sat Apr 20 09:52:09 2013 +0000
+++ b/I2CSlaveRtos.h	Sat Apr 20 11:56:35 2013 +0000
@@ -6,14 +6,14 @@
 namespace mbed
 {
 
-/// I2C master interface to the RTOS-I2CDriver.
+/// I2C slave interface to the RTOS-I2CDriver.
 /// The interface is compatible to the original mbed I2C class.
 class I2CSlaveRtos
 {
     I2CDriver m_drv;
 
 public:
-
+    /// Status returned by the receiveSlave() function
     enum RxStatus {
         NoData         = 0,
         ReadAddressed  = 1,
@@ -25,6 +25,8 @@
      *
      *  @param sda I2C data line pin
      *  @param scl I2C clock line pin
+     *
+     *  @note Has to be created in a thread context, i.e. within the main or some other function. A global delaration does not work
      */
     I2CSlaveRtos(PinName sda, PinName scl, int freq=100000, int address=42)
         :m_drv(sda,scl,100000,address) {}
--- a/mbed-NXP.lib	Sat Apr 20 09:52:09 2013 +0000
+++ b/mbed-NXP.lib	Sat Apr 20 11:56:35 2013 +0000
@@ -1,1 +1,1 @@
-http://mbed.org/users/mbed_official/code/mbed-NXP/#bd882383c33b
+http://mbed.org/users/humlet/code/mbed-NXP/#50c599e18714
--- a/mbed-src.lib	Sat Apr 20 09:52:09 2013 +0000
+++ b/mbed-src.lib	Sat Apr 20 11:56:35 2013 +0000
@@ -1,1 +1,1 @@
-http://mbed.org/users/mbed_official/code/mbed-src/#6e50904b84e2
+http://mbed.org/users/humlet/code/mbed-src/#28ed2abfeb85