Added support for banked registers
Dependents: Component_Test_Interface FalconWing MX_Spoile_Test Simple_Power_Distribution ... more
Diff: MCP23017.h
- Revision:
- 2:2d4ee919e8a7
- Parent:
- 1:e2edbd61f4d0
- Child:
- 3:72da9cd002bd
--- a/MCP23017.h Mon Dec 20 15:53:38 2010 +0000 +++ b/MCP23017.h Mon Dec 20 16:04:04 2010 +0000 @@ -50,24 +50,71 @@ class MCP23017 { public: + /** Create an MCP23017 object connected to the specified I2C object and using the specified deviceAddress + * + * @param I2C &i2c the I2C port to connect to + * @param char deviceAddress the address of the MSC23017 + */ MCP23017(I2C &i2c, char deviceAddress); + + /** Set I/O direction of specified MCP23017 Port + * + * @param Port Port address (Port_A or Port_B) + * @param char direction pin direction (0 = output, 1 = input) + */ void direction(Port port, char direction); + + /** Set Pull-Up Resistors on specified MCP23017 Port + * + * @param Port Port address (Port_A or Port_B) + * @param char offOrOn per pin (0 = off, 1 = on) + */ void configurePullUps(Port port, char offOrOn); + void interruptEnable(Port port, char interruptsEnabledMask); void interruptPolarity(Polarity polarity); void mirrorInterrupts(bool mirror); void defaultValue(Port port, char valuesToCompare); void interruptControl(Port port, char interruptControlBits); + + /** Read from specified MCP23017 Port + * + * @param Port Port address (Port_A or Port_B) + * @returns data from Port + */ char read(Port port); + + /** Write to specified MCP23017 Port + * + * @param Port Port address (Port_A or Port_B) + * @param char byte data to write + */ void write(Port port, char byte); protected: I2C &_i2c; - void _init(); - void _write(char address, char byte); - char _read(char address); char _readOpcode; char _writeOpcode; + + /** Init MCP23017 + * + * @param + * @returns + */ + void _init(); + + /** Write to specified MCP23017 register + * + * @param char address the internal registeraddress of the MSC23017 + */ + void _write(char address, char byte); + + /** Read from specified MCP23017 register + * + * @param char address the internal registeraddress of the MSC23017 + * @returns data from register + */ + char _read(char address); }; #endif \ No newline at end of file