pub struct Timer<T, U = OneShot>(_, _);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.
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
sourceimpl<T, U> Timer<T, U> where
T: Instance,
impl<T, U> Timer<T, U> where
T: Instance,
pub const TICKS_PER_SECOND: u32 = 1_000_000u32
pub fn into_periodic(self) -> Timer<T, Periodic>
pub fn into_oneshot(self) -> Timer<T, OneShot>
sourcepub fn enable_interrupt(&mut self)
pub fn enable_interrupt(&mut self)
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.
sourcepub fn disable_interrupt(&mut self)
pub fn disable_interrupt(&mut self)
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)
sourcepub fn task_start(&self) -> &Reg<TASKS_START_SPEC>
pub fn task_start(&self) -> &Reg<TASKS_START_SPEC>
Returns reference to the START task endpoint for PPI.
Starts timer.
sourcepub fn task_stop(&self) -> &Reg<TASKS_STOP_SPEC>
pub fn task_stop(&self) -> &Reg<TASKS_STOP_SPEC>
Returns reference to the STOP task endpoint for PPI.
Stops timer.
sourcepub fn task_count(&self) -> &Reg<TASKS_COUNT_SPEC>
pub fn task_count(&self) -> &Reg<TASKS_COUNT_SPEC>
Returns reference to the COUNT task endpoint for PPI.
Increments timer (counter mode only).
sourcepub fn task_clear(&self) -> &Reg<TASKS_CLEAR_SPEC>
pub fn task_clear(&self) -> &Reg<TASKS_CLEAR_SPEC>
Returns reference to the CLEAR task endpoint for PPI.
Clears timer.
sourcepub fn task_capture_cc0(&self) -> &Reg<TASKS_CAPTURE_SPEC>
pub fn task_capture_cc0(&self) -> &Reg<TASKS_CAPTURE_SPEC>
Returns reference to the CC[0] CAPTURE task endpoint for PPI.
Captures timer value to the CC[0] register.
sourcepub fn task_capture_cc1(&self) -> &Reg<TASKS_CAPTURE_SPEC>
pub fn task_capture_cc1(&self) -> &Reg<TASKS_CAPTURE_SPEC>
Returns reference to the CC[1] CAPTURE task endpoint for PPI.
Captures timer value to the CC[1] register.
sourcepub fn task_capture_cc2(&self) -> &Reg<TASKS_CAPTURE_SPEC>
pub fn task_capture_cc2(&self) -> &Reg<TASKS_CAPTURE_SPEC>
Returns reference to the CC[2] CAPTURE task endpoint for PPI.
Captures timer value to the CC[2] register.
sourcepub fn task_capture_cc3(&self) -> &Reg<TASKS_CAPTURE_SPEC>
pub fn task_capture_cc3(&self) -> &Reg<TASKS_CAPTURE_SPEC>
Returns reference to the CC[3] CAPTURE task endpoint for PPI.
Captures timer value to the CC[3] register.
sourcepub fn event_compare_cc0(&self) -> &Reg<EVENTS_COMPARE_SPEC>
pub fn event_compare_cc0(&self) -> &Reg<EVENTS_COMPARE_SPEC>
Returns reference to the CC[0] COMPARE event endpoint for PPI.
Generated when the counter is incremented and then matches the value
specified in the CC[0] register.
sourcepub fn event_compare_cc1(&self) -> &Reg<EVENTS_COMPARE_SPEC>
pub fn event_compare_cc1(&self) -> &Reg<EVENTS_COMPARE_SPEC>
Returns reference to the CC[1] COMPARE event endpoint for PPI.
Generated when the counter is incremented and then matches the value
specified in the CC[1] register.
sourcepub fn event_compare_cc2(&self) -> &Reg<EVENTS_COMPARE_SPEC>
pub fn event_compare_cc2(&self) -> &Reg<EVENTS_COMPARE_SPEC>
Returns reference to the CC[2] COMPARE event endpoint for PPI.
Generated when the counter is incremented and then matches the value
specified in the CC[2] register.
sourcepub fn event_compare_cc3(&self) -> &Reg<EVENTS_COMPARE_SPEC>
pub fn event_compare_cc3(&self) -> &Reg<EVENTS_COMPARE_SPEC>
Returns reference to the CC[3] COMPARE event endpoint for PPI.
Generated when the counter is incremented and then matches the value
specified in the CC[3] register.
Trait Implementations
sourceimpl<T, U> CountDown for Timer<T, U> where
T: Instance,
impl<T, U> CountDown for Timer<T, U> where
T: Instance,
sourcefn start<Time>(&mut self, cycles: Time) where
Time: Into<<Timer<T, U> as CountDown>::Time>,
fn start<Time>(&mut self, cycles: Time) where
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.
sourcefn wait(&mut self) -> Result<(), Error<Void>>
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.
sourceimpl ExtendedCCTimer for Timer<TIMER3, OneShot>
impl ExtendedCCTimer for Timer<TIMER3, OneShot>
sourcefn task_capture_cc4(&self) -> &Reg<TASKS_CAPTURE_SPEC>
fn task_capture_cc4(&self) -> &Reg<TASKS_CAPTURE_SPEC>
Returns reference to the CC[4] CAPTURE task endpoint for PPI.
sourcefn task_capture_cc5(&self) -> &Reg<TASKS_CAPTURE_SPEC>
fn task_capture_cc5(&self) -> &Reg<TASKS_CAPTURE_SPEC>
Returns reference to the CC[5] CAPTURE task endpoint for PPI.
sourcefn event_compare_cc4(&self) -> &Reg<EVENTS_COMPARE_SPEC>
fn event_compare_cc4(&self) -> &Reg<EVENTS_COMPARE_SPEC>
Returns reference to the CC[4] COMPARE event endpoint for PPI.
sourcefn event_compare_cc5(&self) -> &Reg<EVENTS_COMPARE_SPEC>
fn event_compare_cc5(&self) -> &Reg<EVENTS_COMPARE_SPEC>
Returns reference to the CC[5] COMPARE event endpoint for PPI.
sourceimpl ExtendedCCTimer for Timer<TIMER4, OneShot>
impl ExtendedCCTimer for Timer<TIMER4, OneShot>
sourcefn task_capture_cc4(&self) -> &Reg<TASKS_CAPTURE_SPEC>
fn task_capture_cc4(&self) -> &Reg<TASKS_CAPTURE_SPEC>
Returns reference to the CC[4] CAPTURE task endpoint for PPI.
sourcefn task_capture_cc5(&self) -> &Reg<TASKS_CAPTURE_SPEC>
fn task_capture_cc5(&self) -> &Reg<TASKS_CAPTURE_SPEC>
Returns reference to the CC[5] CAPTURE task endpoint for PPI.
sourcefn event_compare_cc4(&self) -> &Reg<EVENTS_COMPARE_SPEC>
fn event_compare_cc4(&self) -> &Reg<EVENTS_COMPARE_SPEC>
Returns reference to the CC[4] COMPARE event endpoint for PPI.
sourcefn event_compare_cc5(&self) -> &Reg<EVENTS_COMPARE_SPEC>
fn event_compare_cc5(&self) -> &Reg<EVENTS_COMPARE_SPEC>
Returns reference to the CC[5] COMPARE event endpoint for PPI.
impl<T> Periodic for Timer<T, Periodic> where
T: Instance,
Auto Trait Implementations
impl<T, U> RefUnwindSafe for Timer<T, U> where
T: RefUnwindSafe,
U: RefUnwindSafe,
impl<T, U> Send for Timer<T, U> where
T: Send,
U: Send,
impl<T, U> Sync for Timer<T, U> where
T: Sync,
U: Sync,
impl<T, U> Unpin for Timer<T, U> where
T: Unpin,
U: Unpin,
impl<T, U> UnwindSafe for Timer<T, U> where
T: UnwindSafe,
U: UnwindSafe,
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> CheckedAs for T
impl<T> CheckedAs for T
sourcefn checked_as<Dst>(self) -> Option<Dst> where
T: CheckedCast<Dst>,
fn checked_as<Dst>(self) -> Option<Dst> where
T: CheckedCast<Dst>,
Casts the value.
sourceimpl<Src, Dst> CheckedCastFrom<Src> for Dst where
Src: CheckedCast<Dst>,
impl<Src, Dst> CheckedCastFrom<Src> for Dst where
Src: CheckedCast<Dst>,
sourcefn checked_cast_from(src: Src) -> Option<Dst>
fn checked_cast_from(src: Src) -> Option<Dst>
Casts the value.
sourceimpl<Src, Dst> LosslessTryInto<Dst> for Src where
Dst: LosslessTryFrom<Src>,
impl<Src, Dst> LosslessTryInto<Dst> for Src where
Dst: LosslessTryFrom<Src>,
sourcefn lossless_try_into(self) -> Option<Dst>
fn lossless_try_into(self) -> Option<Dst>
Performs the conversion.
sourceimpl<Src, Dst> LossyInto<Dst> for Src where
Dst: LossyFrom<Src>,
impl<Src, Dst> LossyInto<Dst> for Src where
Dst: LossyFrom<Src>,
sourcefn lossy_into(self) -> Dst
fn lossy_into(self) -> Dst
Performs the conversion.
sourceimpl<T> OverflowingAs for T
impl<T> OverflowingAs for T
sourcefn overflowing_as<Dst>(self) -> (Dst, bool) where
T: OverflowingCast<Dst>,
fn overflowing_as<Dst>(self) -> (Dst, bool) where
T: OverflowingCast<Dst>,
Casts the value.
sourceimpl<Src, Dst> OverflowingCastFrom<Src> for Dst where
Src: OverflowingCast<Dst>,
impl<Src, Dst> OverflowingCastFrom<Src> for Dst where
Src: OverflowingCast<Dst>,
sourcefn overflowing_cast_from(src: Src) -> (Dst, bool)
fn overflowing_cast_from(src: Src) -> (Dst, bool)
OverflowingCasts the value.
sourceimpl<T> SaturatingAs for T
impl<T> SaturatingAs for T
sourcefn saturating_as<Dst>(self) -> Dst where
T: SaturatingCast<Dst>,
fn saturating_as<Dst>(self) -> Dst where
T: SaturatingCast<Dst>,
Casts the value.
sourceimpl<Src, Dst> SaturatingCastFrom<Src> for Dst where
Src: SaturatingCast<Dst>,
impl<Src, Dst> SaturatingCastFrom<Src> for Dst where
Src: SaturatingCast<Dst>,
sourcefn saturating_cast_from(src: Src) -> Dst
fn saturating_cast_from(src: Src) -> Dst
Casts the value.
sourceimpl<T> UnwrappedAs for T
impl<T> UnwrappedAs for T
sourcefn unwrapped_as<Dst>(self) -> Dst where
T: UnwrappedCast<Dst>,
fn unwrapped_as<Dst>(self) -> Dst where
T: UnwrappedCast<Dst>,
Casts the value.
sourceimpl<Src, Dst> UnwrappedCastFrom<Src> for Dst where
Src: UnwrappedCast<Dst>,
impl<Src, Dst> UnwrappedCastFrom<Src> for Dst where
Src: UnwrappedCast<Dst>,
sourcefn unwrapped_cast_from(src: Src) -> Dst
fn unwrapped_cast_from(src: Src) -> Dst
UnwrappedCasts the value.
sourceimpl<T> WrappingAs for T
impl<T> WrappingAs for T
sourcefn wrapping_as<Dst>(self) -> Dst where
T: WrappingCast<Dst>,
fn wrapping_as<Dst>(self) -> Dst where
T: WrappingCast<Dst>,
Casts the value.
sourceimpl<Src, Dst> WrappingCastFrom<Src> for Dst where
Src: WrappingCast<Dst>,
impl<Src, Dst> WrappingCastFrom<Src> for Dst where
Src: WrappingCast<Dst>,
sourcefn wrapping_cast_from(src: Src) -> Dst
fn wrapping_cast_from(src: Src) -> Dst
WrappingCasts the value.