SX1509 16 Output I/O Expander / LED Driver Library
Diff: SX1509.h
- Revision:
- 3:ba95b8e850f1
- Parent:
- 2:330355f546b0
- Child:
- 5:c64016ec73d3
--- a/SX1509.h Tue Oct 21 14:01:05 2014 +0000 +++ b/SX1509.h Tue Oct 21 14:10:35 2014 +0000 @@ -183,6 +183,8 @@ // CLASS DEFINITION // ==================================================== +/** Class definition for the SX1509 I/O expander IC + */ class SX1509 { private: @@ -198,6 +200,14 @@ void init(PinName, PinName, PinName, PinName); void direction(Direction_t, Side_t); int transfer_data(char const, char const, Transfer_t); + void write_register(char const, char const); + int read_register(char const); + void setBuffer(Side_t, State_t); + void setPull(Side_t, Pull_t, State_t); + void setOpenDrain(Side_t, State_t); + void setClock(State_t); + void setFreq(Freq_t); + void setLedDrive(Side_t, State_t); public: @@ -209,27 +219,46 @@ */ SX1509(PinName sda, PinName scl, PinName intN = NC, PinName resetN = NC); + /// Set the direction for pins 0 to 7 void directionA(Direction_t dir); + + /// Set the direction for pins 8 to 15 void directionB(Direction_t dir); - void write_register(char const, char const); - int read_register(char const); + + /// Write an 8-bit value to the pins corresponding to 0 to 7 void setA(char const); + + /// Write an 8-bit value to the pins corresponding to 8 to 15 void setB(char const); + + /// Read the 8-bit value for pins corresponding to 0 to 7 int readA(); + + /// Read the 8-bit value for pins corresponding to 0 to 7 int readB(); + + /// Read a single bit from a pin's state bool get(int const); + + /// Set a single bit for a pin's state void set(int const); + + /// Clear a single bit for a pin's state void clear(int const); + + /// Toggle the state of a pin void toggle(int const); + + /// Returns the direction that the pins for A or B are set to (if unamious) Direction_t getDirection(Side_t); - void setBuffer(Side_t, State_t); - void setPull(Side_t, Pull_t, State_t); - void setOpenDrain(Side_t, State_t); - void setClock(State_t); - void setFreq(Freq_t); - void setLedDrive(Side_t, State_t); + + /// Set the state for the pins for A or B to off void clearAll(Side_t); + + /// Used for configuring outputs for driving LEDs on pins for A or B void enableLED(Side_t); + + /// The method used for controlling how an LED is controlled by the SX1509 void setupLED(LED_t); };