Basic library of routines to interface to a Microchip MCP23017 16-bit I/O expander using an I2C interface.

Dependents:   Assignment_2_herpe Final_V1 ass2 ass2 ... more

Great library - two tweaks

Hi there,

First off, great library, really helped me port the Adafruit RGB LCD Shield to mbed. The functions mapped almost one-to-one with Arduino and was exactly what I was looking for.

However, as you can see from the changed code, I fixed a small bug where PINDIR didn't check against the function parameter. Plus a small tweak to support higher speed I2C access on the MCP.

I had to do the latter as I couldn't get access to the frequency member function of _i2c due to how you'd done the class. I therefore elected to go for a backward compatible route and add a default argument on the constructor so nothing gets broken and the change is minimal.

There seem to be two standard frequencies to cover modern I2C device responses. 100k and 400k Hz. Because I couldn't see a need to tune the frequency beyond these two standard speeds I used a bool labelled hispeed.

An alternative approach could have been to inherit from I2C and therefore the frequency member function would be accessible by any app using the MCP23017 class.

Either way, that was my thinking on the change. The pull request is entirely to notify you, in case you find it useful.

Basic library of routines to interface to a Microchip MCP23017 16-bit I/O expander using an I2C interface. I2C, MCP23017, wattbob