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.
This commit is contained in:
Dion Dokter
2021-10-18 16:23:39 +02:00
committed by Dario Nieuwenhuis
parent e6ec81b999
commit 11655af034
20 changed files with 729 additions and 880 deletions

View File

@ -11,9 +11,8 @@ use embassy_hal_common::drop::OnDrop;
use embassy_hal_common::unborrow;
use futures::future::poll_fn;
use crate::interconnect::{Event, Task};
use crate::pac;
use crate::ppi::Event;
use crate::ppi::Task;
pub(crate) mod sealed {
@ -184,36 +183,21 @@ impl<'d, T: Instance, I: TimerType> Timer<'d, T, I> {
///
/// When triggered, this task starts the timer.
pub fn task_start(&self) -> Task {
#[cfg(feature = "_ppi")]
let reg = &T::regs().tasks_start;
#[cfg(feature = "_dppi")]
let reg = &T::regs().subscribe_start;
Task::from_reg(reg)
Task::from_reg(&T::regs().tasks_start)
}
/// Returns the STOP task, for use with PPI.
///
/// When triggered, this task stops the timer.
pub fn task_stop(&self) -> Task {
#[cfg(feature = "_ppi")]
let reg = &T::regs().tasks_stop;
#[cfg(feature = "_dppi")]
let reg = &T::regs().subscribe_stop;
Task::from_reg(reg)
Task::from_reg(&T::regs().tasks_stop)
}
/// Returns the CLEAR task, for use with PPI.
///
/// When triggered, this task resets the timer's counter to 0.
pub fn task_clear(&self) -> Task {
#[cfg(feature = "_ppi")]
let reg = &T::regs().tasks_clear;
#[cfg(feature = "_dppi")]
let reg = &T::regs().subscribe_clear;
Task::from_reg(reg)
Task::from_reg(&T::regs().tasks_clear)
}
/// Change the timer's frequency.
@ -334,24 +318,14 @@ impl<'a, T: Instance, I: TimerType> Cc<'a, T, I> {
///
/// When triggered, this task will capture the current value of the timer's counter in this register.
pub fn task_capture(&self) -> Task {
#[cfg(feature = "_ppi")]
let reg = &T::regs().tasks_capture;
#[cfg(feature = "_dppi")]
let reg = &T::regs().subscribe_capture;
Task::from_reg(reg)
Task::from_reg(&T::regs().tasks_capture)
}
/// Returns this CC register's COMPARE event, for use with PPI.
///
/// This event will fire when the timer's counter reaches the value in this CC register.
pub fn event_compare(&self) -> Event {
#[cfg(feature = "_ppi")]
let reg = &T::regs().events_compare[self.n];
#[cfg(feature = "_dppi")]
let reg = &T::regs().publish_compare[self.n];
Event::from_reg(reg)
Event::from_reg(&T::regs().events_compare[self.n])
}
/// Enable the shortcut between this CC register's COMPARE event and the timer's CLEAR task.