Trait rtic_time::Monotonic

source ·
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§

source

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.

source

type Duration

The type for duration, defining an duration of time.

Note: In all APIs in RTIC that use duration from this monotonic, this type will be used.

Required Associated Constants§

source

const ZERO: Self::Instant

The time at time zero.

source

const TICK_PERIOD: Self::Duration

The duration between two timer ticks.

Required Methods§

source

fn now() -> Self::Instant

Get the current time.

source

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.

source

fn clear_compare_flag()

Clear the compare interrupt flag.

source

fn pend_interrupt()

Pend the timer’s interrupt.

Provided Methods§

source

fn should_dequeue_check(_: Self::Instant) -> bool

👎Deprecated since 1.2.0: this method is erroneous and has been disabled

This method used to be required by an errata workaround for the nrf52 family, but it has been disabled as the workaround was erroneous.

source

fn on_interrupt()

Optional. Runs on interrupt before any timer queue handling.

source

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.

source

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.

Object Safety§

This trait is not object safe.

Implementors§