Skip to content
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

Add support for MCP23017 and MCP23S17 #27

Merged
merged 5 commits into from
Mar 30, 2024
Merged

Conversation

markus-k
Copy link
Contributor

This PR is based on the work from #2. I have updated the driver to reflect changes made to the codebase since that PR was created, and extended it to work with both the MCP23017 (I2C version) and MCP23S17 (SPI version).

To support both I2C and SPI, I have created an "intermediate" trait and newtypes for the SPI and I2C busses. I didn't implement something like SpiBusExt (analog to I2cBusExt) since the register reading/writing on this chip is a bit weird and probably shouldn't be generalized. Any feedback on this kind of multi-interface support for a single driver is welcome, as I'm not sure whether this is the best way to do it.

The driver has not been tested on real hardware yet, but implements tests and realworld testing should happen in the coming week or two.

Copy link
Owner

@Rahix Rahix left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very nice work, thanks a lot for the contribution :)

I got quite scared when I read that you attempted a driver that supports both SPI and I2C at the same time, but I have to say - you're implementation looks really really good. I'm surprised the design of port-expander didn't get in the way of this. When I originally envisioned it, I only considered I2C support...

Anyway, LGTM 👍

@Rahix Rahix merged commit 8af2559 into Rahix:main Mar 30, 2024
2 checks passed
@Rahix Rahix mentioned this pull request Mar 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants