-
Notifications
You must be signed in to change notification settings - Fork 238
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
MCP23008 driver is limited to one device #12
Comments
The current implementation of A good model for the |
Thanks, I will take a look at those drivers first. Another thing I spotted: there is presently no way to control the pullup state, which I can include in my solution here. |
Yup - configuring the individual pins (pull up, etc) is needed as well. Interested to see how you do that. |
@phoddie design decisions time! When driver objects are instantiated... A. Should the chip's GPIO, GPPU and IODIR registers be reset to their "POR/RST" state?
B. Should the chip's GPIO, GPPU and IODIR registers be read into the memory for use by the instance?
C. Should the constructor accept an optional property in the dictionary arg that lets use code decide which of the above it prefers?
My vote is for C. |
Interesting questions. We've tried to implement the modules for sensors so that simple uses stay simple (e.g. after the constructor runs, the sensors are ready to be used for common situations without additional configuration). A GPIO expander requires some configuration, since there's no obvious correct initial state. That means that the caller of the code needs to configure GPIO, GPPU, and IODIR on each pin it will use (unless it can safely make assumptions about their state based on the particular application running). Therefore, there's no need to reset the expander in the constructor. I would try to avoid caching state about the expander in the instance to avoid synchronization problems should there be multiple instances. (Reset is also problematic if there are multiple instances) Speaking of design, if you haven't already considered it, bulk read and write commands would be interesting they can be considerably faster. |
I plan to preserve that—no explicit
Do you mean, for example: read or write the whole GPIO or GPPU at once? That's the way MCP23008 works by default |
Yes, exactly. The current implementation only provides access to one pin at a time. That's simple for simple cases, but eliminates some uses of the expander. |
While preparing to push a changeset that I've been working on, I pulled and rebased with the latest master, but now i2c is broken in some way that I don't understand.
The next call in the "Calls" pane shows Scanning the I2C bus confirms that the MCP23017 that I'm trying to write to is there:
Also, this is printing out in my terminal, where it previously did not:
Like I said, all of this only started when I rebased my branch with master |
The error "Break: (host): write failed!" means that the I2C protocol write failed. It is usually caused by a mismatch between the physical wiring and the sda/scl pins specified by the application. Since the scan works, it means the pins required in the scanner are correct. The processing instructions are unrelated. They are part of an extension to the serial debugging protocol we're working on. We will clean those up. |
lol @ me: I figured it out. My code was still using "clock" 🤦♀️ (yes, as in the same patch I wrote myself) |
Ha. |
The MCP23008 supports up to 8 devices on the same bus, by configuring hardware address pins,
A0
,A1
andA2
:The present driver design only supports using 1 MCP23008 device at the default address.
Proposed Solution:
If there is interest in pursuing this solution, I would like to try my hand at implementing the upgrade.
The text was updated successfully, but these errors were encountered: