Basic library of routines to interface to a Microchip MCP23017 16-bit I/O expander using an I2C interface.
Dependents: AdaFruit_RGBLCD SX1276_GPS
Fork of MCP23017 by
Diff: MCP23017.h
- Revision:
- 3:f00ee94327c6
- Parent:
- 1:d54d7002bae2
- Child:
- 4:32fd6ee97dff
--- a/MCP23017.h Sun Nov 28 21:10:15 2010 +0000 +++ b/MCP23017.h Sun Nov 28 21:21:17 2010 +0000 @@ -100,31 +100,55 @@ * pinmode * Set units to sequential, bank0 mode */ - + /** + */ void pinMode(int pin, int mode); + /** + */ void digitalWrite(int pin, int val); + /** + */ int digitalRead(int pin); // These provide a more advanced mapping of the chip functionality // See the data sheet for more information on what they do //Returns a word with the current pin states (ie contents of the GPIO register) + /** + */ unsigned short digitalWordRead(); // Allows you to write a word to the GPIO register + /** + */ void digitalWordWrite(unsigned short w); // Sets up the polarity mask that the MCP23017 supports // if set to 1, it will flip the actual pin value. + /** + */ void inputPolarityMask(unsigned short mask); //Sets which pins are inputs or outputs (1 = input, 0 = output) NB Opposite to arduino's //definition for these + /** + */ void inputOutputMask(unsigned short mask); // Allows enabling of the internal 100k pullup resisters (1 = enabled, 0 = disabled) + /** + */ void internalPullupMask(unsigned short mask); - + /** + */ int read(void); + /** + */ void write(int data); + /** + */ void writeRegister(int regAddress, unsigned char val); + /** + */ void writeRegister(int regAddress, unsigned short val); + /** + */ int readRegister(int regAddress); protected: