Skip to content

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

@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!

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