pub trait Monotonic {
type Instant: Ord + Copy + Add<Self::Duration, Output = Self::Instant> + Sub<Self::Duration, Output = Self::Instant> + Sub<Self::Instant, Output = Self::Duration>;
type Duration;
const ZERO: Self::Instant;
const TICK_PERIOD: Self::Duration;
// Required methods
fn now() -> Self::Instant;
fn set_compare(instant: Self::Instant);
fn clear_compare_flag();
fn pend_interrupt();
// Provided methods
fn should_dequeue_check(_: Self::Instant) -> bool { ... }
fn on_interrupt() { ... }
fn enable_timer() { ... }
fn disable_timer() { ... }
}
Expand description
A monotonic clock / counter definition.
Correctness
The trait enforces that proper time-math is implemented between Instant
and Duration
. This
is a requirement on the time library that the user chooses to use.
Required Associated Types§
sourcetype Instant: Ord + Copy + Add<Self::Duration, Output = Self::Instant> + Sub<Self::Duration, Output = Self::Instant> + Sub<Self::Instant, Output = Self::Duration>
type Instant: Ord + Copy + Add<Self::Duration, Output = Self::Instant> + Sub<Self::Duration, Output = Self::Instant> + Sub<Self::Instant, Output = Self::Duration>
The type for instant, defining an instant in time.
Note: In all APIs in RTIC that use instants from this monotonic, this type will be used.
Required Associated Constants§
sourceconst TICK_PERIOD: Self::Duration
const TICK_PERIOD: Self::Duration
The duration between two timer ticks.
Required Methods§
sourcefn set_compare(instant: Self::Instant)
fn set_compare(instant: Self::Instant)
Set the compare value of the timer interrupt.
Note: This method does not need to handle race conditions of the monotonic, the timer queue in RTIC checks this.
sourcefn clear_compare_flag()
fn clear_compare_flag()
Clear the compare interrupt flag.
sourcefn pend_interrupt()
fn pend_interrupt()
Pend the timer’s interrupt.
Provided Methods§
sourcefn should_dequeue_check(_: Self::Instant) -> bool
fn should_dequeue_check(_: Self::Instant) -> bool
This method used to be required by an errata workaround for the nrf52 family, but it has been disabled as the workaround was erroneous.
sourcefn on_interrupt()
fn on_interrupt()
Optional. Runs on interrupt before any timer queue handling.
sourcefn enable_timer()
fn enable_timer()
Optional. This is used to save power, this is called when the timer queue is not empty.
Enabling and disabling the monotonic needs to propagate to now
so that an instant
based of now()
is still valid.
NOTE: This may be called more than once.
sourcefn disable_timer()
fn disable_timer()
Optional. This is used to save power, this is called when the timer queue is empty.
Enabling and disabling the monotonic needs to propagate to now
so that an instant
based of now()
is still valid.
NOTE: This may be called more than once.