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
impl StoppedTimer
Sourcepub fn new() -> Self
pub fn new() -> Self
Construct a new timer.
Allocates a dynamically allocate timer. The time will not be running.
Sourcepub fn start_simple(
self,
delay: impl Into<Timeout>,
period: impl Into<Timeout>,
) -> SimpleTimer
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
Sourcepub fn start_callback<T>(
self,
callback: Callback<T>,
delay: impl Into<Timeout>,
period: impl Into<Timeout>,
) -> Pin<Box<CallbackTimer<T>>>
pub fn start_callback<T>( self, callback: Callback<T>, delay: impl Into<Timeout>, period: impl Into<Timeout>, ) -> Pin<Box<CallbackTimer<T>>>
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.