Skip to content

Proposal: add async digital traits #649

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

Merged
merged 2 commits into from
Mar 25, 2025

Conversation

i509VCB
Copy link
Contributor

@i509VCB i509VCB commented Feb 12, 2025

As discussed in #647 and on the rust-embedded matrix, the digial traits mean that IO expanders currently need to block.

Also I am working on a library for turning an MCU into an IO expander (no public code yet, still very WIP), and accessing the IO behind that MCU would need to block. The amount of blocking could be significant given that my library will be usable from over SPI to Ethernet.

Currently the proposal just takes the traits in embedded_hal::digital, copies them and adds the async keyword in front of each function.

There are also some comments relating to what Poll::Ready means. The documented semantics are that when Poll::Ready is returned, whatever operation is involved has completed. So if a pin is set to a high level, when Poll::Ready is returned, the pin will be driving a high level.

The 2nd commit changes the docs of the blocking digital module in embedded_hal to mention that the traits are blocking (always have been).

I also hacked together a quick test with postcard-rpc to blink an LED over USB to show an implementation of this for at least OutputPin. There is some extra stuff I did throw in but it is unused: https://github.com/i509VCB/postcard-gpio-test/tree/master

Resolves #647

Verified

This commit was signed with the committer’s verified signature.

Verified

This commit was signed with the committer’s verified signature.
…l are blocking
@i509VCB i509VCB requested a review from a team as a code owner February 12, 2025 03:04
Copy link
Member

@Dirbaio Dirbaio left a comment

Choose a reason for hiding this comment

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

lgtm!

@Dirbaio Dirbaio added this pull request to the merge queue Mar 25, 2025
Merged via the queue into rust-embedded:master with commit 53a8b41 Mar 25, 2025
7 checks passed
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.

Add async variants of the traits in embedded_hal::digital
2 participants