#delay #async-await #runtimes #waker #alarm #hardware #future

embedded-asyncdelay-rp2040

A hardware-based, asynchronous delay that can be used with async/await runtimes

3 releases

new 0.1.2 Feb 9, 2025
0.1.1 Feb 8, 2025
0.1.0 Nov 12, 2024

#391 in Hardware support

Download history 101/week @ 2024-11-09 18/week @ 2024-11-16 3/week @ 2024-11-23 6/week @ 2024-12-07 253/week @ 2025-02-08

253 downloads per month

BSD-2-Clause OR MIT

19KB
269 lines

License BSD-2-Clause License MIT AppVeyor CI docs.rs crates.io Download numbers dependency status

embedded-asyncdelay-rp2040

A hardware-based, asynchronous delay that can be used with async/await runtimes. The implementation uses one of the underlying hardware alarms (Alarm0 to Alarm3) to trigger an interrupt, which in turn wakes the future's associated waker.

Configure Hardware Alarm

To use this crate, you must specify which hardware alarm to use for the underlying interrupt scheduler. This is done by setting the appropriate alarm feature. By default, alarm0 is selected.

Waker Slots and Initialization

Since we need to wake the async wakers from the interrupt callback, we need some stack-allocated shared storage. By default, this crate automatically allocates enough space for 16 slots by default. To override this, you must disable the init16 feature, and call the setup_waker_slots! macro once with your desired number of slots manually.

IMPORTANT: If you disable the init16 feature, but don't call setup_waker_slots!, this will yield a rather cryptic linker error and compilation will fail.

Dependencies

~8MB
~159K SLoC