zephyr::timer

Struct StoppedTimer

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

A Zephyr timer that is not running.

A basic timer, allocated, but not running.

Implementations§

Source§

impl StoppedTimer

Source

pub fn new() -> Self

Construct a new timer.

Allocates a dynamically allocate timer. The time will not be running.

Source

pub fn start_simple( self, delay: impl Into<Timeout>, period: impl Into<Timeout>, ) -> SimpleTimer

Start the timer, in “simple” mode.

Returns the SimpleTimer representing the running timer. The delay specifies the amount of time before the first expiration happens. period gives the time of subsequent timer expirations. If period is NoWait or Forever, then the timer will be one-shot

Source

pub fn start_callback<T>( self, callback: Callback<T>, delay: impl Into<Timeout>, period: impl Into<Timeout>, ) -> Pin<Box<CallbackTimer<T>>>
where T: Send + Sync,

Start the timer in “callback” mode.

Returns the CallbackTimer representing the running timer. The delay specifies the amount of time before the first expiration happens. period gives the time of subsequent timer expirations. If period is NoWait or Forever, then the timer will be one shot.

Each time the timer expires, The callback function given by the Callback will be called from IRQ context. Much of Zephyr’s API is unavailable from within IRQ context. Some useful things to use are data that is wrapped in a SpinMutex, a channel Sender from a bounded channel, or a Semaphore, which can has it’s give method available from IRQ context.

Because the callback is registered with Zephyr, the resulting CallbackTimer must be pinned.

Trait Implementations§

Source§

impl Debug for StoppedTimer

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for StoppedTimer

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl Send for StoppedTimer

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.