aboutsummaryrefslogtreecommitdiff
path: root/embassy-nrf/src/timer.rs
diff options
context:
space:
mode:
Diffstat (limited to 'embassy-nrf/src/timer.rs')
-rw-r--r--embassy-nrf/src/timer.rs17
1 files changed, 14 insertions, 3 deletions
diff --git a/embassy-nrf/src/timer.rs b/embassy-nrf/src/timer.rs
index 5d6afe49b..1d1f77ea8 100644
--- a/embassy-nrf/src/timer.rs
+++ b/embassy-nrf/src/timer.rs
@@ -81,8 +81,6 @@ pub enum Frequency {
81/// 81///
82/// It has either 4 or 6 Capture/Compare registers, which can be used to capture the current state of the counter 82/// It has either 4 or 6 Capture/Compare registers, which can be used to capture the current state of the counter
83/// or trigger an event when the counter reaches a certain value. 83/// or trigger an event when the counter reaches a certain value.
84
85/// Timer driver.
86pub struct Timer<'d, T: Instance> { 84pub struct Timer<'d, T: Instance> {
87 _p: Peri<'d, T>, 85 _p: Peri<'d, T>,
88} 86}
@@ -145,6 +143,13 @@ impl<'d, T: Instance> Timer<'d, T> {
145 this 143 this
146 } 144 }
147 145
146 /// Direct access to the register block.
147 #[cfg(feature = "unstable-pac")]
148 #[inline]
149 pub fn regs(&mut self) -> pac::timer::Timer {
150 T::regs()
151 }
152
148 /// Starts the timer. 153 /// Starts the timer.
149 pub fn start(&self) { 154 pub fn start(&self) {
150 T::regs().tasks_start().write_value(1) 155 T::regs().tasks_start().write_value(1)
@@ -248,7 +253,7 @@ pub struct Cc<'d, T: Instance> {
248impl<'d, T: Instance> Cc<'d, T> { 253impl<'d, T: Instance> Cc<'d, T> {
249 /// Get the current value stored in the register. 254 /// Get the current value stored in the register.
250 pub fn read(&self) -> u32 { 255 pub fn read(&self) -> u32 {
251 return T::regs().cc(self.n).read(); 256 T::regs().cc(self.n).read()
252 } 257 }
253 258
254 /// Set the value stored in the register. 259 /// Set the value stored in the register.
@@ -278,6 +283,12 @@ impl<'d, T: Instance> Cc<'d, T> {
278 Event::from_reg(T::regs().events_compare(self.n)) 283 Event::from_reg(T::regs().events_compare(self.n))
279 } 284 }
280 285
286 /// Clear the COMPARE event for this CC register.
287 #[inline]
288 pub fn clear_events(&self) {
289 T::regs().events_compare(self.n).write_value(0);
290 }
291
281 /// Enable the shortcut between this CC register's COMPARE event and the timer's CLEAR task. 292 /// Enable the shortcut between this CC register's COMPARE event and the timer's CLEAR task.
282 /// 293 ///
283 /// This means that when the COMPARE event is fired, the CLEAR task will be triggered. 294 /// This means that when the COMPARE event is fired, the CLEAR task will be triggered.