embedded-runtime
This crate provides a tiny async runtime, targeted at embedded devices. Therefore, it provides a single-threaded executor as well as a stack-allocated box to box futures.
Runtime setup
This crate is hardware-independent, and needs some dependency-injection to perform signal/wait on your target hardware.
To provide these dependencies, you need to define the following two extern "Rust"
functions:
_runtime_waitforevent_TBFzxdKN
: Blocks until an event occurs (may wake spuriously). Important: Events must not be lost. If an event has occurred between the last invocation and this invocation, this function must not block._runtime_sendevent_3YSaPmB7
: Raises an event. Important: Events must not be lost. If an event is sent, but the receiver is not currently waiting, it must be retained until the receiver tries to wait again.
For an example on how to inject your implementation, see also embedded-runtime-rp2040
, which is basically this crate
with wfe
/sev
-based runtime functions for rp2040
boards.
Example
# use ;
#
# /// Blocks until an event occurs (may wake spuriously)
#
#
#
#
# /// Raises an event
#
#
#
use run;
/// A countdown future that resolves to pending until the poll-countdown becomes zero
// This creates a new runtime and executes the given futures in an async context
run!.expect;