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.cpp
- Revision:
- 15:164d420bcbcf
- Parent:
- 14:c8d31c67ac27
- Child:
- 16:9b5a51117afe
diff -r c8d31c67ac27 -r 164d420bcbcf MCP23017.cpp --- a/MCP23017.cpp Sat Aug 02 15:00:57 2014 +0000 +++ b/MCP23017.cpp Thu Aug 07 19:59:32 2014 +0000 @@ -27,7 +27,10 @@ /*----------------------------------------------------------------------------- * */ -MCP23017::MCP23017(PinName sda, PinName scl, int i2cAddress) : _i2c(sda, scl) { +MCP23017::MCP23017(PinName sda, PinName scl, int i2cAddress, bool hispeed) : _i2c(sda, scl) { + // I2C can handle two different frequencies - switch to high speed if asked + _i2c.frequency(hispeed ? 400000 : 100000); + MCP23017_i2cAddress = i2cAddress; reset(); // initialise chip to power-on condition }