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
impl SimpleTimer
Sourcepub fn read_count(&mut self) -> u32
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.
Sourcepub fn read_count_wait(&mut self) -> u32
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.
Sourcepub fn restart(&mut self, delay: impl Into<Timeout>, period: impl Into<Timeout>)
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.
Sourcepub fn stop(self) -> StoppedTimer
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.