Expand description
A basic asynchronous timer implementation that uses the cortex-m SysTick
peripheral.
§Usage
Construct a new Timer
instance using the
SysTick
peripheral. The timer can then be
used to create timeouts, tickers, and trackers.
Enable the defmt
feature to automatically implement the defmt
timestamp
feature, as well as derive defmt::Format
for all relevant types.
Useful traits from fugit
are re-exported for convenience.
§Important Notes
- This crate does not implement or manage wakers at all.
Timer
is designed to be used in conjunction with an executor likecassette
, that is, a simple polling-based loop. - The
SysTick
exception is implemented within this crate to catch timer overflows and should not be used elsewhere. - PRs are welcome to add more functionality (or fix bugs!), but the goal is to keep this crate as simple as possible for easy plug-and-play time functionality.
Structs§
- Ticker
- A ticker that fires at regular intervals.
- Timeout
- A timeout that expires at a specific instant in time. This
can be
await
ed to pause execution until the timeout expires. - Timeout
Error - A timeout error indicates that a timeout has expired.
- Timer
- A timer that can measure time, allowing you to create timeouts and tickers.
The timer instance implements
Clone
andCopy
, so once a timer has been constructed with a validSysTick
peripheral, it can be cloned and passed around freely. The timer can then be used to create timeouts, tickers, and trackers. - Tracker
- A tracker that keeps track of the time since the last update.
Traits§
- Float
Seconds - A trait for converting between
Duration
and floating-point seconds. - RateExt
- Extension trait for simple short-hands for u64 Rate
- TimeExt
- Extension trait for simple short-hands for u64 Durations
- With
Timeout - An extension trait that adds timeout functionality to futures.