PCA9555
Dependents: Telliskivi2_2014 PowerManagementBoard_Rev_A_2017
Diff: PCA9555.h
- Revision:
- 2:fae93e0841f6
- Parent:
- 1:a6699cd826bb
- Child:
- 4:fe1637c9409f
- Child:
- 5:73884f49ed97
diff -r a6699cd826bb -r fae93e0841f6 PCA9555.h --- a/PCA9555.h Sat Aug 31 15:57:14 2013 +0000 +++ b/PCA9555.h Mon Sep 09 17:30:51 2013 +0000 @@ -1,10 +1,14 @@ -#include "mbed.h" - #ifndef MBED_PCA9555_H #define MBED_PCA9555_H + +#include "mbed.h" +//#include "PinDetect.h" /** Interface to the PCA9555 I2C 16 Bit IO expander */ class PCA9555 { +protected: + InterruptIn _irqpin; + FunctionPointer _callbackChange; public: /** Create an instance of the PCA9555 connected to specfied I2C pins, with the specified address. * @@ -12,7 +16,7 @@ * @param scl The I2C clock pin * @param address The I2C address for this PCA9555 */ - PCA9555(PinName sda, PinName scl, int address); + PCA9555(PinName sda, PinName scl, PinName interrupPin, int address); /** Read the IO pin level * @@ -29,13 +33,23 @@ void setPin(unsigned int pinNumber); void clearPin(unsigned int pinNumber); void togglePin(unsigned int pinNumber); + bool getPin(unsigned int pinNumber); void setDirection(int data); + + void change(void (*function)(void)); + + template<typename T> + void change(T *object, void (T::*member)(void)) { + _callbackChange.attach(object, member); + } private: I2C _i2c; int _address; - int currentWriteState; + unsigned int currentWriteState; + + void callChange(void); }; #endif \ No newline at end of file