zephyr::timer

Struct SimpleTimer

Source
pub struct SimpleTimer { /* private fields */ }
Expand description

A simple timer.

A SimpleTimer represents a running Zephyr k_timer that does not have a callback registered. It can only be created by calling StoppedTimer::start_simple.

Implementations§

Source§

impl SimpleTimer

Source

pub fn read_count(&mut self) -> u32

Read the count from the timer.

Returns the number of times the timer has fired since the last time either this method or read_count_wait was called.

This works via an internal counter, that is atomically reset to zero when the current value of the counter is read.

Source

pub fn read_count_wait(&mut self) -> u32

Read the count from the timer, waiting for it to become non-zero.

Blocks the current thread until the timer has fired at least once since the last call to this method or read_count. Once it has fired, will return the count. This will return immediately if the timer has already fired once since the last time.

Source

pub fn restart(&mut self, delay: impl Into<Timeout>, period: impl Into<Timeout>)

Restart the current timer.

This resets the fired counter back to zero, and sets a new delay and period for the timer. It is mostly equivalent to self.stop().start_simple(delay, period), but saves the step of having to stop the timer.

Source

pub fn stop(self) -> StoppedTimer

Stop the timer.

Stops the timer, so that it will not fire any more, converting the timer back into a StoppedTimer.

Trait Implementations§

Source§

impl Drop for SimpleTimer

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.