MCP23009 is a general IO I2C chip . This lib provide higher level interface ( set pin value, set io modes etc ) without need to have knowledge of the I2C registers

Dependents:   MCP23009tst

Revision:
1:9146d773a5a3
Parent:
0:d829b4edd564
--- a/mcp23009.cpp	Fri Jun 03 12:40:49 2016 +0000
+++ b/mcp23009.cpp	Fri Jun 03 16:01:45 2016 +0000
@@ -2,7 +2,7 @@
 //#include "mbed.h"  // should not be in only for printf debug ?
 
 
-#define VERSION_MCP23009_SRC  "0.10"  
+#define VERSION_MCP23009_SRC  "0.20"  
 
 // definition registers 
 
@@ -29,12 +29,20 @@
     _i2c_interface->write(_device_address, data,2);     
 }
 
+int MCP23009::outp_status( int pinnr){
+    return status_gen(pinnr,OLAT);
+}
+
 int MCP23009::status( int pinnr){
+    return status_gen(pinnr,GPIO);
+}    
+
+int MCP23009::status_gen( int pinnr , char reg){
     int result=0;
-    data[0]=GPIO;
+    data[0]=reg;
     result= _i2c_interface->write(_device_address, data,1); // set reg
     if ( result ) return -1;
-    char rb[0];
+    char rb[1];
     result = _i2c_interface->read(_device_address,rb,1); // read the current status 
     if ( result ) return -2;
     if ( pinnr != 8) {
@@ -96,7 +104,7 @@
     if (pinnr < 8 ) {
         result= _i2c_interface->write(_device_address, data,1); // set to ioreg
         if ( result ) return -1;
-        char rb[0];
+        char rb[1];
         result = _i2c_interface->read(_device_address, rb,1); // read the current status 
         if ( result ) return -2;
         data[1]= 1<<pinnr;