Add async gpio support #64
Merged
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.
This adds a cargo feature to the
zephyr
crateasync-drivers
, which enables support for async driver calls. These are built around standard Rust async, and should work with any executor (except for the kio one which is non-standard).Currently, this adds
wait_for_high
andwait_for_low
to the gpio driver (currently, only level triggering, not edge). The implementation both tries to avoid races as well as avoid excessive interrupts. However, as the Zephyr gpio API does not provide a way to read an individual interrupt status, this does require the IRQ to always fire. In the case where the pin is already at the desired level, the IRQ callback will happen between the enable, and the status check, which means the async task will not pend, but simply return, just with the overhead of an irq and the callback.There is a single callback per gpio controller.
This includes a new mechanism in the devicetree mapping that allows static data to be associated with each instance. Static data is needed as the callback and the state cannot be moved.