[−][src]Struct nrf9160_hal::Timer
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.
CC[0] is used for the current/most-recent delay period and CC[1] is used to grab the current value of the counter at a given instant.
Implementations
impl<T> Timer<T, OneShot> where
T: Instance,
[src]
T: Instance,
impl<T> Timer<T, Periodic> where
T: Instance,
[src]
T: Instance,
impl<T, U> Timer<T, U> where
T: Instance,
[src]
T: Instance,
pub const TICKS_PER_SECOND: u32
[src]
pub fn into_periodic(self) -> Timer<T, Periodic>
[src]
pub fn into_oneshot(self) -> Timer<T, OneShot>
[src]
pub fn free(self) -> T
[src]
Return the raw interface to the underlying timer peripheral
pub fn read(&self) -> u32
[src]
Return the current value of the counter, by capturing to CC[1].
pub fn enable_interrupt(&mut self)
[src]
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
.
Note that the interrupt also has to be unmasked in the NVIC, or the handler won't get called.
pub fn disable_interrupt(&mut self)
[src]
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
.
Note that the interrupt also has to be unmasked in the NVIC, or the handler won't get called.
pub fn delay(&mut self, cycles: u32)
[src]
Trait Implementations
impl<T, U> Cancel for Timer<T, U> where
T: Instance,
[src]
T: Instance,
type Error = ()
Error returned when a countdown can't be canceled.
fn cancel(&mut self) -> Result<(), <Timer<T, U> as Cancel>::Error>
[src]
impl<T, U> CountDown for Timer<T, U> where
T: Instance,
[src]
T: Instance,
type Time = u32
The unit of time used by this timer
fn start<Time>(&mut self, cycles: Time) where
Time: Into<<Timer<T, U> as CountDown>::Time>,
[src]
Time: Into<<Timer<T, U> as CountDown>::Time>,
Start the timer
The timer will run for the given number of cycles, then it will stop and reset.
fn wait(&mut self) -> Result<(), Error<Void>>
[src]
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.
impl<T, U> DelayMs<u16> for Timer<T, U> where
T: Instance,
[src]
T: Instance,
impl<T, U> DelayMs<u32> for Timer<T, U> where
T: Instance,
[src]
T: Instance,
impl<T, U> DelayMs<u8> for Timer<T, U> where
T: Instance,
[src]
T: Instance,
impl<T, U> DelayUs<u16> for Timer<T, U> where
T: Instance,
[src]
T: Instance,
impl<T, U> DelayUs<u32> for Timer<T, U> where
T: Instance,
[src]
T: Instance,
impl<T, U> DelayUs<u8> for Timer<T, U> where
T: Instance,
[src]
T: Instance,
impl<T> Periodic for Timer<T, Periodic> where
T: Instance,
[src]
T: Instance,
Auto Trait Implementations
impl<T, U> Send for Timer<T, U> where
T: Send,
U: Send,
T: Send,
U: Send,
impl<T, U> Sync for Timer<T, U> where
T: Sync,
U: Sync,
T: Sync,
U: Sync,
impl<T, U> Unpin for Timer<T, U> where
T: Unpin,
U: Unpin,
T: Unpin,
U: Unpin,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> Same<T> for T
type Output = T
Should always be Self
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,