pub trait Timer {
type Duration: Clone;
type Instant: Clone + Ord + AddAssign<Self::Duration>;
const DELTA: Self::Duration;
// Required methods
fn reset(&mut self);
fn interrupt_free<F: FnOnce(&CriticalSection) -> R, R>(f: F) -> R;
fn now(&self) -> Self::Instant;
fn disarm(&mut self);
fn arm(&mut self, deadline: &Self::Instant);
}
Expand description
A clock device that supports throwing alarm interrupts at given instant.
This trait assumes that the clock is not (re)set after initial configuration.
Required Associated Constants§
Required Associated Types§
Required Methods§
Sourcefn reset(&mut self)
fn reset(&mut self)
Initialize the clock and start counting.
You will need to run this sometime after initializing the static memory in which the timer lives, such that the interrupt handler can access the timer.
Sourcefn interrupt_free<F: FnOnce(&CriticalSection) -> R, R>(f: F) -> R
fn interrupt_free<F: FnOnce(&CriticalSection) -> R, R>(f: F) -> R
Execute the function in an interrupt free critical section.
Probably you want to directly feed through cortex_m::interrupt::free
or similar.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.