Skip to content

Async functionality#38

Open
mbrieske wants to merge 14 commits intoRahix:mainfrom
swobbee-dev:async_pins
Open

Async functionality#38
mbrieske wants to merge 14 commits intoRahix:mainfrom
swobbee-dev:async_pins

Conversation

@mbrieske
Copy link
Contributor

@mbrieske mbrieske commented Jan 29, 2025

This pull request adds asynchronous pin-waiting support using embedded-hal-async to the port-expander crate. It introduces a new PinAsync type that implements digital::Wait, along with a shared AsyncPortState and an InterruptHandler to be invoked from a hardware ISR.

Its a WIP and in its current state works for my specific use-case - So far, I've only provided async support for the PCA9702 driver. I plan to extend this to other drivers (e.g., PCA9554A and MCP23S17) which I am actively using in my own projects.

@Rahix previously mentioned not wanting to force embedded-hal-async on users. My intention is not to force an async model on all users, but rather to provide an additional optional layer for those who do want to rely on embedded-hal-async for pin interrupt handling. The current approach still keeps the “wait for interrupt” part separate from the actual hardware ISR. Instead, the crate user can call into the InterruptHandler via their own ISR or background task, whichever pattern they choose. The interrupt handling logic remains in their domain.

I look forward to feedback and any suggestions on how to better integrate or scope this functionality. Even if this PR ends up serving only as a reference implementation or a starting point for future work, I hope it can be useful as an example of how embedded-hal-async might be integrated in this crate. Let me know what you think—happy to discuss other design approaches as well!

@mbrieske
Copy link
Contributor Author

Update: PCA9554 async functionality added

@swobbee-dev
Copy link

Not really a WIP anymore, I have been testing this for the past 6 months and it works great. Any feedback would be greatly appreciated

@Rahix Rahix self-requested a review July 31, 2025 19:36
@mbrieske mbrieske changed the title [WIP] Async functionality Async functionality Oct 30, 2025
@erzoe
Copy link

erzoe commented Oct 30, 2025

Hi, what's the status of this? This sounds very useful and I would like to use it. Thank you.

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