Proposal: add async digital traits #649
Merged
+136
−2
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 theasync
keyword in front of each function.There are also some comments relating to what
Poll::Ready
means. The documented semantics are that whenPoll::Ready
is returned, whatever operation is involved has completed. So if a pin is set to a high level, whenPoll::Ready
is returned, the pin will be driving a high level.The 2nd commit changes the docs of the blocking
digital
module inembedded_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 leastOutputPin
. There is some extra stuff I did throw in but it is unused: https://github.com/i509VCB/postcard-gpio-test/tree/masterResolves #647