I've got a 12-bit binary ripple counter whose outputs are feeding an MCP23017 16-bit I2C port expander chip (bits 0-7 on port A, bits 8-11 on the first 4 bits of port B). So far, I've got it all up and working, counting away in the background, and letting me see what the count is on demand via I2C (hooray!).
Having worked through the examples supplied in the library, I know how to read and write a single pin at a time, and I have successfully used this to assemble the bits into meaningful data one bit at a time. It seems a bit wasteful and redundant, however, to be pulling the data in as bytes via I2C and breaking them up into individual pin readings with mcp.digitalRead(x), only to turn right around and spend several additional lines of code to reassemble them into bytes again in order to use the data.
Ideally, I would like to be able to read both A and half of the B ports as a 12-bit value, while still retaining one I/O line as an output for resetting the counter.
Alternately, I could read A and the lower nibble of B as bytes and assemble them, which would still be fewer operations than my current method of reading 12 digital lines sequentially.
I have been through the files in the Adafruit MCP23017 library, and have not yet been able to figure out how to read the Port A and B values as bytes in a single shot, if it is in fact possible.
Any assistance in this matter would be greatly appreciated.


