Struct nrf52832_hal::Timer
source · pub struct Timer<T>(_);
Expand description
Interface to a TIMER instance
Right now, this is a very basic interface. The timer will always be hardcoded to a frequency of 1 MHz and 32 bits accuracy.
Implementations
sourceimpl<T> Timer<T>where
T: TimerExt,
impl<T> Timer<T>where
T: TimerExt,
sourcepub fn enable_interrupt(&mut self, nvic: &mut NVIC)
pub fn enable_interrupt(&mut self, nvic: &mut NVIC)
Enables the interrupt for this timer
Enables an interrupt that is fired when the timer reaches the value that
is given as an argument to start
.
sourcepub fn disable_interrupt(&mut self, nvic: &mut NVIC)
pub fn disable_interrupt(&mut self, nvic: &mut NVIC)
Disables the interrupt for this timer
Disables an interrupt that is fired when the timer reaches the value
that is given as an argument to start
.
sourcepub fn start(&mut self, cycles: u32)
pub fn start(&mut self, cycles: u32)
Start the timer
The timer will run for the given number of cycles, then it will stop and reset.
sourcepub fn wait(&mut self) -> Result<(), Error<Void>>
pub fn wait(&mut self) -> Result<(), Error<Void>>
Wait for the timer to stop
Will return Err(nb::Error::WouldBlock)
while the timer is still
running. Once the timer reached the number of cycles given in the
start
method, it will return Ok(())
.
To block until the timer has stopped, use the block!
macro from the
nb
crate. Please refer to the documentation of nb
for other options.