aboutsummaryrefslogtreecommitdiff
path: root/embassy-nrf/src/timer.rs
diff options
context:
space:
mode:
authorDion Dokter <[email protected]>2021-10-18 16:23:39 +0200
committerDario Nieuwenhuis <[email protected]>2021-10-26 14:47:12 +0200
commit11655af034538b463ff8220714e9b97cf53f8f56 (patch)
treeb22cd986313293328f472bb8c9637c59b654af65 /embassy-nrf/src/timer.rs
parente6ec81b999541cca847b50075ac0d5d826f97dcd (diff)
Another redo using the feedback.
PPI is now split up into PPI and DPPI under the name 'interconnect'. The tasks and events are tracked and reset in the drop function.
Diffstat (limited to 'embassy-nrf/src/timer.rs')
-rw-r--r--embassy-nrf/src/timer.rs38
1 files changed, 6 insertions, 32 deletions
diff --git a/embassy-nrf/src/timer.rs b/embassy-nrf/src/timer.rs
index e62120aef..27f8e715e 100644
--- a/embassy-nrf/src/timer.rs
+++ b/embassy-nrf/src/timer.rs
@@ -11,9 +11,8 @@ use embassy_hal_common::drop::OnDrop;
11use embassy_hal_common::unborrow; 11use embassy_hal_common::unborrow;
12use futures::future::poll_fn; 12use futures::future::poll_fn;
13 13
14use crate::interconnect::{Event, Task};
14use crate::pac; 15use crate::pac;
15use crate::ppi::Event;
16use crate::ppi::Task;
17 16
18pub(crate) mod sealed { 17pub(crate) mod sealed {
19 18
@@ -184,36 +183,21 @@ impl<'d, T: Instance, I: TimerType> Timer<'d, T, I> {
184 /// 183 ///
185 /// When triggered, this task starts the timer. 184 /// When triggered, this task starts the timer.
186 pub fn task_start(&self) -> Task { 185 pub fn task_start(&self) -> Task {
187 #[cfg(feature = "_ppi")] 186 Task::from_reg(&T::regs().tasks_start)
188 let reg = &T::regs().tasks_start;
189 #[cfg(feature = "_dppi")]
190 let reg = &T::regs().subscribe_start;
191
192 Task::from_reg(reg)
193 } 187 }
194 188
195 /// Returns the STOP task, for use with PPI. 189 /// Returns the STOP task, for use with PPI.
196 /// 190 ///
197 /// When triggered, this task stops the timer. 191 /// When triggered, this task stops the timer.
198 pub fn task_stop(&self) -> Task { 192 pub fn task_stop(&self) -> Task {
199 #[cfg(feature = "_ppi")] 193 Task::from_reg(&T::regs().tasks_stop)
200 let reg = &T::regs().tasks_stop;
201 #[cfg(feature = "_dppi")]
202 let reg = &T::regs().subscribe_stop;
203
204 Task::from_reg(reg)
205 } 194 }
206 195
207 /// Returns the CLEAR task, for use with PPI. 196 /// Returns the CLEAR task, for use with PPI.
208 /// 197 ///
209 /// When triggered, this task resets the timer's counter to 0. 198 /// When triggered, this task resets the timer's counter to 0.
210 pub fn task_clear(&self) -> Task { 199 pub fn task_clear(&self) -> Task {
211 #[cfg(feature = "_ppi")] 200 Task::from_reg(&T::regs().tasks_clear)
212 let reg = &T::regs().tasks_clear;
213 #[cfg(feature = "_dppi")]
214 let reg = &T::regs().subscribe_clear;
215
216 Task::from_reg(reg)
217 } 201 }
218 202
219 /// Change the timer's frequency. 203 /// Change the timer's frequency.
@@ -334,24 +318,14 @@ impl<'a, T: Instance, I: TimerType> Cc<'a, T, I> {
334 /// 318 ///
335 /// When triggered, this task will capture the current value of the timer's counter in this register. 319 /// When triggered, this task will capture the current value of the timer's counter in this register.
336 pub fn task_capture(&self) -> Task { 320 pub fn task_capture(&self) -> Task {
337 #[cfg(feature = "_ppi")] 321 Task::from_reg(&T::regs().tasks_capture)
338 let reg = &T::regs().tasks_capture;
339 #[cfg(feature = "_dppi")]
340 let reg = &T::regs().subscribe_capture;
341
342 Task::from_reg(reg)
343 } 322 }
344 323
345 /// Returns this CC register's COMPARE event, for use with PPI. 324 /// Returns this CC register's COMPARE event, for use with PPI.
346 /// 325 ///
347 /// This event will fire when the timer's counter reaches the value in this CC register. 326 /// This event will fire when the timer's counter reaches the value in this CC register.
348 pub fn event_compare(&self) -> Event { 327 pub fn event_compare(&self) -> Event {
349 #[cfg(feature = "_ppi")] 328 Event::from_reg(&T::regs().events_compare[self.n])
350 let reg = &T::regs().events_compare[self.n];
351 #[cfg(feature = "_dppi")]
352 let reg = &T::regs().publish_compare[self.n];
353
354 Event::from_reg(reg)
355 } 329 }
356 330
357 /// Enable the shortcut between this CC register's COMPARE event and the timer's CLEAR task. 331 /// Enable the shortcut between this CC register's COMPARE event and the timer's CLEAR task.