Closed lmamakos closed 4 years ago
Can you help me use this library with 2 or more MCP23017? I tried some ways but without succeed, only with a single MCP23017, according to the tutorial: https://cdn-learn.adafruit.com/downloads/pdf/mcp230xx-gpio-expander-on-the-raspberry-pi.pdf
Thank you for the Issue! This library has been deprecated in favor of our python3 Blinka library. We have replaced all of the libraries that use this repo with CircuitPython libraries that are Python3 compatible, and support a wide variety of single board/linux computers!
Visit https://circuitpython.org/blinka for more information
CircuitPython has support for almost 200 different drivers, and a as well as FT232H support for Mac/Win/Linux!
I had problem using this library with an MCP23017 device, and made some bugfix changes and I think some robustness improvements.
I think the design of the library needs to change a bit; this notion of using the number of GPIOs to select between two different devices rather than explicit selection between an MCP23008 vs an MCP23017 is a bit confusing. I don't think it useful to have anything other than 8 or 16 as values for
num_gpios
..If, for example, someone is only using a 2 GPIO pins on port A but they have an MCP23017 device, the library will malfunction because the register addresses will be wrong. This could be mitigated by changing the
IOCON.BANK
bit in theIOCON
configuration register to 1 so that the register address for both devices match..In any case, here are the changes I made if there's interest. I was attempting to use the
write8
andreadU16
methods, without success. In thewrite8
case, there seems to be an implicit assumption that the use will only use this with an MCP23008 device since that register address is hardcoded.In the case of doing a
readU16
orreadS16
call, that code was just broken, apparently due to a cut-n-paste error and was referencing the wrong register entirely.I also attempted to initialize the chip into a deterministic state (resetting input polarity registers), and set the interrupt output to open-drain to minimize damage if the outputs are connected together in whatever circuit the device might happened to be installed in.