pub struct Timer<T, U = OneShot>(/* private fields */);
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§
Source§impl<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>
Sourcepub fn reset_event(&self)
pub fn reset_event(&self)
Reset the interrupt event flag
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.
Sourcepub fn start(&mut self, cycles: u32)
pub fn start(&mut self, cycles: u32)
Starts the timer.
The timer will run for the given number of cycles, then it will stop and reset.
Sourcepub fn reset_if_finished(&mut self) -> bool
pub fn reset_if_finished(&mut self) -> bool
If the timer has finished, resets it and returns true.
Returns false if the timer is still running.
Sourcepub fn delay(&mut self, cycles: u32)
pub fn delay(&mut self, cycles: u32)
Starts the timer for the given number of cycles and waits for it to finish.
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§
Source§impl<T, U> DelayNs for Timer<T, U>where
T: Instance,
impl<T, U> DelayNs for Timer<T, U>where
T: Instance,
Source§fn delay_ns(&mut self, ns: u32)
fn delay_ns(&mut self, ns: u32)
ns
nanoseconds. Pause can be longer
if the implementation requires it due to precision/timing issues.Source§impl ExtendedCCTimer for Timer<TIMER3>
impl ExtendedCCTimer for Timer<TIMER3>
Source§fn 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.
Source§fn 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.
Source§fn 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.
Source§fn 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.
Source§impl ExtendedCCTimer for Timer<TIMER4>
impl ExtendedCCTimer for Timer<TIMER4>
Source§fn 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.
Source§fn 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.
Source§fn 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.
Source§fn 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.