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 proper support for PCF8574 port expander #211

Open
dl1com opened this issue Nov 6, 2024 · 2 comments
Open

Add proper support for PCF8574 port expander #211

dl1com opened this issue Nov 6, 2024 · 2 comments

Comments

@dl1com
Copy link
Contributor

dl1com commented Nov 6, 2024

As discussion on Discord revealed, we are using to different types of I2C port expanders on shield and interface.
Currently, we are only supporting the MCP23008 type properly.
They are somewhat compatible in terms of their protocol, so this is not a breaking issue and may have not been an issue in the field so far, but should be fixed to avoid sporadical issues/unwanted behavior.

Support for the PCF part had been added in the past, but was removed accidentially (research done by @jonathanperret):

Ah, I just did a bit of Git archaeology on that MCP23008/PCF8574 issue and the results are… interesting.
The issue with driving a PCF8574 with code intended for the MCP23008 was very clearly identified and solved (with a patch to the MCP23008 library) by Windell in #11 !

"With this new version, the I/O signals on PCF8574-based boards are vastly improved (clean steps, no longer a forest of spikes), as seen on the logic analyzer. This may help to cut down on occasional glitches on PCF8574 based boards."

This is the code that shipped in the 0.95 firmware.
Unfortunately, this customization of the MCP23008 library was overlooked as the code for the libraries was removed from the repository, in #27 .

@jpcornil-git
Copy link
Contributor

Detection between both devices can be implemented using bit 0 of IOCON register; write 1 -> read 1 on PCF8574 but 0 on MCP23008. Based on that, the device configuration and writes to the address register can be skipped.

@jonathanperret jonathanperret pinned this issue Nov 7, 2024
@jonathanperret jonathanperret unpinned this issue Nov 7, 2024
@jonathanperret
Copy link
Contributor

Detection between both devices can be implemented using bit 0 of IOCON register; write 1 -> read 1 on PCF8574 but 0 on MCP23008. Based on that, the device configuration and writes to the address register can be skipped.

Yes, and the code in #11 can be used as a reference for this approach.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants