I am using a MCP2221 to talk I2C to a MCP23017. Using python3 to interface.
I had some trouble with the adafruit libraries, so have resorted to using the PyMCP2221A library. It works great for writing to the MCP23017. However, I don't know how to ensure I am reading the correct position of the MCP23017 registers.
For example in the MCP2221 I2C Terminal software I ran the following series of commands. If I read just one bit (say that is a bus error, emf issue, or other) then the buffer in the MCP23017 does not reset itself and the data becomes shifted and I will read the data in the incorrect register.
Looking at the adafruit mcp23017 code it looks like they reset the transmission just before reading. This makes sense, but not sure how to do that in python or how to access this I2C stop function from the PyMCP2221A library or the upstream cython-hidapi library. Also not 100% sure it just requires a stop signal or something more.
/**
* Reads a given register
*/
uint8_t Adafruit_MCP23017::readRegister(uint8_t addr) {
//read the current GPINTEN
_wire->beginTransmission(MCP23017_ADDRESS | i2caddr);
wiresend(addr, _wire);
_wire->endTransmission();
_wire->requestFrom(MCP23017_ADDRESS | i2caddr, 1);
return wirerecv(_wire);
}
Any guidance is greatly appreciated!