[−][src]Trait stm32l0xx_hal::prelude::_embedded_hal_timer_CountDown
A count down timer
Contract
self.start(count); block!(self.wait());
MUST block for AT LEAST the time specified bycount
.
Note that the implementer doesn't necessarily have to be a downcounting timer; it could also be an upcounting timer as long as the above contract is upheld.
Examples
You can use this timer to create delays
extern crate embedded_hal as hal; #[macro_use(block)] extern crate nb; use hal::prelude::*; fn main() { let mut led: Led = { // .. }; let mut timer: Timer6 = { // .. }; Led.on(); timer.start(1.s()); block!(timer.wait()); // blocks for 1 second Led.off(); }
Associated Types
type Time
The unit of time used by this timer
Required methods
fn start<T>(&mut self, count: T) where
T: Into<Self::Time>,
T: Into<Self::Time>,
Starts a new count down
fn wait(&mut self) -> Result<(), Error<Void>>
Non-blockingly "waits" until the count down finishes
Contract
- If
Self: Periodic
, the timer will start a new count down right after the last one finishes. - Otherwise the behavior of calling
wait
after the last call returnedOk
is UNSPECIFIED. Implementers are suggested to panic on this scenario to signal a programmer error.
Implementors
impl CountDown for LpTimer<OneShot>
[src]
type Time = MicroSeconds
fn start<T>(&mut self, period: T) where
T: Into<MicroSeconds>,
[src]
T: Into<MicroSeconds>,
fn wait(&mut self) -> Result<(), Void>
[src]
impl CountDown for LpTimer<Periodic>
[src]
type Time = Hertz
fn start<T>(&mut self, freq: T) where
T: Into<Hertz>,
[src]
T: Into<Hertz>,
fn wait(&mut self) -> Result<(), Void>
[src]
impl CountDown for Timer<SYST>
[src]
type Time = Hertz
fn start<T>(&mut self, timeout: T) where
T: Into<Hertz>,
[src]
T: Into<Hertz>,
fn wait(&mut self) -> Result<(), Void>
[src]
impl CountDown for Timer<TIM2>
[src]
type Time = Hertz
fn start<T>(&mut self, timeout: T) where
T: Into<Hertz>,
[src]
T: Into<Hertz>,
fn wait(&mut self) -> Result<(), Void>
[src]
impl CountDown for Timer<TIM21>
[src]
type Time = Hertz
fn start<T>(&mut self, timeout: T) where
T: Into<Hertz>,
[src]
T: Into<Hertz>,
fn wait(&mut self) -> Result<(), Void>
[src]
impl CountDown for Timer<TIM22>
[src]
type Time = Hertz
fn start<T>(&mut self, timeout: T) where
T: Into<Hertz>,
[src]
T: Into<Hertz>,
fn wait(&mut self) -> Result<(), Void>
[src]
impl CountDown for Timer<TIM3>
[src]
type Time = Hertz
fn start<T>(&mut self, timeout: T) where
T: Into<Hertz>,
[src]
T: Into<Hertz>,
fn wait(&mut self) -> Result<(), Void>
[src]
impl<'_> CountDown for WakeupTimer<'_>
[src]
type Time = u32
fn start<T>(&mut self, delay: T) where
T: Into<Self::Time>,
[src]
T: Into<Self::Time>,
Starts the wakeup timer
The delay
argument specifies the timer delay in seconds. Up to 17 bits
of delay are supported, giving us a range of over 36 hours.
Panics
The delay
argument must be in the range 1 <= delay <= 2^17
.
Panics, if delay
is outside of that range.