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
Diff: mcp23009.h
- Revision:
- 1:9146d773a5a3
- Parent:
- 0:d829b4edd564
--- a/mcp23009.h Fri Jun 03 12:40:49 2016 +0000 +++ b/mcp23009.h Fri Jun 03 16:01:45 2016 +0000 @@ -9,7 +9,7 @@ #include "I2CInterface.h" #include "DACInterface.h" -#define VERSION_MCP23009_HDR "0.1" +#define VERSION_MCP23009_HDR "0.20" /** MCP23009 class. * Used for interfacing with a mcp23009 8 bit io expander @@ -18,7 +18,8 @@ * This includes the "virtual" I2CInterface class that is the interface to the I2C device * An implementation of the I2Cinterface class for the MBED can be found at * interrupt is not supported (yet ) - * + * V 0.10 initial version + * V 0.20 added outp_status , tested with hardware. * (C) Wim Beaumont Universiteit Antwerpen 2016 * */ @@ -53,8 +54,22 @@ * @return none zero in case of error */ int set_as_output(int pinnr ,int pullup,int polarity=-1 ); - + + /** read the status of all IO pins and indicate if the pin, with pinnr is 1 or 0 + * if pinnr= 8 the status of all pins is returned + * the status is the level of the port not the "output status" ( open drain so output status can be different) + * @param pinnr : range 0 .. 8 , if 8 the return value is the status of all pins ,if 0 ..7 it returns 0 or 1 + * @return 0 or 1 if pinnr 0..7 , byte ( 0 ..255 ) if pinnr =8 neg value in case of I2C error + */ int status( int pinnr=8); + /** read the status of output register all IO pins and indicate if the pin, with pinnr is 1 or 0 + * if pinnr= 8 the status of all pins is returned + * the outp_status is the status of the output latch!! not the actual levels on the IO lines + * @param pinnr : range 0 .. 8 , if 8 the return value is the status of all pins ,if 0 ..7 it returns 0 or 1 + * @return 0 or 1 if pinnr 0..7 , byte ( 0 ..255 ) if pinnr =8 neg value in case of I2C error + */ + int outp_status( int pinnr=8); + int set( int pinnr , int value); protected: /** pointer to the I2C interface driver. */ @@ -65,6 +80,7 @@ char data[5]; int set_io_pin(bool input ,int pinnr,int pullup, int polarity ); int pinmanipulation ( bool active , int pinnr ); + int status_gen( int pinnr , char reg); }; -#endif \ No newline at end of file +#endif