pub struct Timer<'d, T: Instance> { /* private fields */ }
Expand description
nRF Timer driver.
The timer has an internal counter, which is incremented for every tick of the timer. The counter is 32-bit, so it wraps back to 0 when it reaches 2^32.
It has either 4 or 6 Capture/Compare registers, which can be used to capture the current state of the counter or trigger an event when the counter reaches a certain value. Timer driver.
Implementations§
Source§impl<'d, T: Instance> Timer<'d, T>
impl<'d, T: Instance> Timer<'d, T>
Sourcepub fn new(timer: impl Peripheral<P = T> + 'd) -> Self
pub fn new(timer: impl Peripheral<P = T> + 'd) -> Self
Create a new Timer
driver.
This can be useful for triggering tasks via PPI
Uarte
uses this internally.
Sourcepub fn new_counter(timer: impl Peripheral<P = T> + 'd) -> Self
pub fn new_counter(timer: impl Peripheral<P = T> + 'd) -> Self
Create a new Timer
driver in counter mode.
This can be useful for triggering tasks via PPI
Uarte
uses this internally.
Sourcepub fn task_start(&self) -> Task<'d>
pub fn task_start(&self) -> Task<'d>
Returns the START task, for use with PPI.
When triggered, this task starts the timer.
Sourcepub fn task_stop(&self) -> Task<'d>
pub fn task_stop(&self) -> Task<'d>
Returns the STOP task, for use with PPI.
When triggered, this task stops the timer.
Sourcepub fn task_clear(&self) -> Task<'d>
pub fn task_clear(&self) -> Task<'d>
Returns the CLEAR task, for use with PPI.
When triggered, this task resets the timer’s counter to 0.
Sourcepub fn task_count(&self) -> Task<'d>
pub fn task_count(&self) -> Task<'d>
Returns the COUNT task, for use with PPI.
When triggered, this task increments the timer’s counter by 1. Only works in counter mode.
Sourcepub fn set_frequency(&self, frequency: Frequency)
pub fn set_frequency(&self, frequency: Frequency)
Change the timer’s frequency.
This will stop the timer if it isn’t already stopped, because the timer may exhibit ‘unpredictable behaviour’ if it’s frequency is changed while it’s running.