From c63d74720980fcf9acbf5b1d8adbb9dc2031d391 Mon Sep 17 00:00:00 2001 From: Dion Dokter Date: Tue, 26 Oct 2021 09:45:29 +0200 Subject: [PATCH] Fewer channel traits, more cfg to make the system work --- embassy-nrf/src/buffered_uarte.rs | 20 ++--- embassy-nrf/src/chips/nrf52805.rs | 44 +++++----- embassy-nrf/src/chips/nrf52810.rs | 64 +++++++------- embassy-nrf/src/chips/nrf52811.rs | 64 +++++++------- embassy-nrf/src/chips/nrf52820.rs | 64 +++++++------- embassy-nrf/src/chips/nrf52832.rs | 64 +++++++------- embassy-nrf/src/chips/nrf52833.rs | 64 +++++++------- embassy-nrf/src/chips/nrf52840.rs | 64 +++++++------- embassy-nrf/src/chips/nrf9160.rs | 32 +++---- embassy-nrf/src/ppi/mod.rs | 135 +++++++++++++++++------------- embassy-nrf/src/ppi/ppi.rs | 12 ++- embassy-nrf/src/uarte.rs | 20 ++--- 12 files changed, 335 insertions(+), 312 deletions(-) diff --git a/embassy-nrf/src/buffered_uarte.rs b/embassy-nrf/src/buffered_uarte.rs index 1dc04f4f..717ada78 100644 --- a/embassy-nrf/src/buffered_uarte.rs +++ b/embassy-nrf/src/buffered_uarte.rs @@ -15,7 +15,7 @@ use embassy_hal_common::{low_power_wait_until, unborrow}; use crate::gpio::sealed::Pin as _; use crate::gpio::{OptionalPin as GpioOptionalPin, Pin as GpioPin}; use crate::pac; -use crate::ppi::{AnyChannel, Event, OneToOneChannel, OneToTwoChannel, Ppi, Task}; +use crate::ppi::{AnyConfigurableChannel, ConfigurableChannel, Event, Ppi, Task}; use crate::timer::Instance as TimerInstance; use crate::timer::{Frequency, Timer}; use crate::uarte::{Config, Instance as UarteInstance}; @@ -45,8 +45,8 @@ impl<'d, U: UarteInstance, T: TimerInstance> State<'d, U, T> { struct StateInner<'d, U: UarteInstance, T: TimerInstance> { phantom: PhantomData<&'d mut U>, timer: Timer<'d, T>, - _ppi_ch1: Ppi<'d, AnyChannel, 1, 2>, - _ppi_ch2: Ppi<'d, AnyChannel, 1, 1>, + _ppi_ch1: Ppi<'d, AnyConfigurableChannel, 1, 2>, + _ppi_ch2: Ppi<'d, AnyConfigurableChannel, 1, 1>, rx: RingBuffer<'d>, rx_state: RxState, @@ -70,8 +70,8 @@ impl<'d, U: UarteInstance, T: TimerInstance> BufferedUarte<'d, U, T> { state: &'d mut State<'d, U, T>, _uarte: impl Unborrow + 'd, timer: impl Unborrow + 'd, - ppi_ch1: impl Unborrow + 'd, - ppi_ch2: impl Unborrow + 'd, + ppi_ch1: impl Unborrow + 'd, + ppi_ch2: impl Unborrow + 'd, irq: impl Unborrow + 'd, rxd: impl Unborrow + 'd, txd: impl Unborrow + 'd, @@ -145,20 +145,18 @@ impl<'d, U: UarteInstance, T: TimerInstance> BufferedUarte<'d, U, T> { timer.cc(0).short_compare_stop(); let mut ppi_ch1 = Ppi::new_one_to_two( - ppi_ch1, + ppi_ch1.degrade(), Event::from_reg(&r.events_rxdrdy), timer.task_clear(), timer.task_start(), - ) - .degrade(); + ); ppi_ch1.enable(); let mut ppi_ch2 = Ppi::new_one_to_one( - ppi_ch2, + ppi_ch2.degrade(), timer.cc(0).event_compare(), Task::from_reg(&r.tasks_stoprx), - ) - .degrade(); + ); ppi_ch2.enable(); Self { diff --git a/embassy-nrf/src/chips/nrf52805.rs b/embassy-nrf/src/chips/nrf52805.rs index 326f4a8b..68989648 100644 --- a/embassy-nrf/src/chips/nrf52805.rs +++ b/embassy-nrf/src/chips/nrf52805.rs @@ -167,28 +167,28 @@ impl_pin!(P0_29, 0, 29); impl_pin!(P0_30, 0, 30); impl_pin!(P0_31, 0, 31); -impl_ppi_channel!(PPI_CH0, 0, true, 1, 2); -impl_ppi_channel!(PPI_CH1, 1, true, 1, 2); -impl_ppi_channel!(PPI_CH2, 2, true, 1, 2); -impl_ppi_channel!(PPI_CH3, 3, true, 1, 2); -impl_ppi_channel!(PPI_CH4, 4, true, 1, 2); -impl_ppi_channel!(PPI_CH5, 5, true, 1, 2); -impl_ppi_channel!(PPI_CH6, 6, true, 1, 2); -impl_ppi_channel!(PPI_CH7, 7, true, 1, 2); -impl_ppi_channel!(PPI_CH8, 8, true, 1, 2); -impl_ppi_channel!(PPI_CH9, 9, true, 1, 2); -impl_ppi_channel!(PPI_CH20, 20, false, 0, 1); -impl_ppi_channel!(PPI_CH21, 21, false, 0, 1); -impl_ppi_channel!(PPI_CH22, 22, false, 0, 1); -impl_ppi_channel!(PPI_CH23, 23, false, 0, 1); -impl_ppi_channel!(PPI_CH24, 24, false, 0, 1); -impl_ppi_channel!(PPI_CH25, 25, false, 0, 1); -impl_ppi_channel!(PPI_CH26, 26, false, 0, 1); -impl_ppi_channel!(PPI_CH27, 27, false, 0, 1); -impl_ppi_channel!(PPI_CH28, 28, false, 0, 1); -impl_ppi_channel!(PPI_CH29, 29, false, 0, 1); -impl_ppi_channel!(PPI_CH30, 30, false, 0, 1); -impl_ppi_channel!(PPI_CH31, 31, false, 0, 1); +impl_ppi_channel!(PPI_CH0, 0 => configurable); +impl_ppi_channel!(PPI_CH1, 1 => configurable); +impl_ppi_channel!(PPI_CH2, 2 => configurable); +impl_ppi_channel!(PPI_CH3, 3 => configurable); +impl_ppi_channel!(PPI_CH4, 4 => configurable); +impl_ppi_channel!(PPI_CH5, 5 => configurable); +impl_ppi_channel!(PPI_CH6, 6 => configurable); +impl_ppi_channel!(PPI_CH7, 7 => configurable); +impl_ppi_channel!(PPI_CH8, 8 => configurable); +impl_ppi_channel!(PPI_CH9, 9 => configurable); +impl_ppi_channel!(PPI_CH20, 20 => static); +impl_ppi_channel!(PPI_CH21, 21 => static); +impl_ppi_channel!(PPI_CH22, 22 => static); +impl_ppi_channel!(PPI_CH23, 23 => static); +impl_ppi_channel!(PPI_CH24, 24 => static); +impl_ppi_channel!(PPI_CH25, 25 => static); +impl_ppi_channel!(PPI_CH26, 26 => static); +impl_ppi_channel!(PPI_CH27, 27 => static); +impl_ppi_channel!(PPI_CH28, 28 => static); +impl_ppi_channel!(PPI_CH29, 29 => static); +impl_ppi_channel!(PPI_CH30, 30 => static); +impl_ppi_channel!(PPI_CH31, 31 => static); impl_saadc_input!(P0_04, ANALOGINPUT2); impl_saadc_input!(P0_05, ANALOGINPUT3); diff --git a/embassy-nrf/src/chips/nrf52810.rs b/embassy-nrf/src/chips/nrf52810.rs index 4c16d51a..b3b3593b 100644 --- a/embassy-nrf/src/chips/nrf52810.rs +++ b/embassy-nrf/src/chips/nrf52810.rs @@ -172,38 +172,38 @@ impl_pin!(P0_29, 0, 29); impl_pin!(P0_30, 0, 30); impl_pin!(P0_31, 0, 31); -impl_ppi_channel!(PPI_CH0, 0, true, 1, 2); -impl_ppi_channel!(PPI_CH1, 1, true, 1, 2); -impl_ppi_channel!(PPI_CH2, 2, true, 1, 2); -impl_ppi_channel!(PPI_CH3, 3, true, 1, 2); -impl_ppi_channel!(PPI_CH4, 4, true, 1, 2); -impl_ppi_channel!(PPI_CH5, 5, true, 1, 2); -impl_ppi_channel!(PPI_CH6, 6, true, 1, 2); -impl_ppi_channel!(PPI_CH7, 7, true, 1, 2); -impl_ppi_channel!(PPI_CH8, 8, true, 1, 2); -impl_ppi_channel!(PPI_CH9, 9, true, 1, 2); -impl_ppi_channel!(PPI_CH10, 10, true, 1, 2); -impl_ppi_channel!(PPI_CH11, 11, true, 1, 2); -impl_ppi_channel!(PPI_CH12, 12, true, 1, 2); -impl_ppi_channel!(PPI_CH13, 13, true, 1, 2); -impl_ppi_channel!(PPI_CH14, 14, true, 1, 2); -impl_ppi_channel!(PPI_CH15, 15, true, 1, 2); -impl_ppi_channel!(PPI_CH16, 16, true, 1, 2); -impl_ppi_channel!(PPI_CH17, 17, true, 1, 2); -impl_ppi_channel!(PPI_CH18, 18, true, 1, 2); -impl_ppi_channel!(PPI_CH19, 19, true, 1, 2); -impl_ppi_channel!(PPI_CH20, 20, false, 0, 1); -impl_ppi_channel!(PPI_CH21, 21, false, 0, 1); -impl_ppi_channel!(PPI_CH22, 22, false, 0, 1); -impl_ppi_channel!(PPI_CH23, 23, false, 0, 1); -impl_ppi_channel!(PPI_CH24, 24, false, 0, 1); -impl_ppi_channel!(PPI_CH25, 25, false, 0, 1); -impl_ppi_channel!(PPI_CH26, 26, false, 0, 1); -impl_ppi_channel!(PPI_CH27, 27, false, 0, 1); -impl_ppi_channel!(PPI_CH28, 28, false, 0, 1); -impl_ppi_channel!(PPI_CH29, 29, false, 0, 1); -impl_ppi_channel!(PPI_CH30, 30, false, 0, 1); -impl_ppi_channel!(PPI_CH31, 31, false, 0, 1); +impl_ppi_channel!(PPI_CH0, 0 => configurable); +impl_ppi_channel!(PPI_CH1, 1 => configurable); +impl_ppi_channel!(PPI_CH2, 2 => configurable); +impl_ppi_channel!(PPI_CH3, 3 => configurable); +impl_ppi_channel!(PPI_CH4, 4 => configurable); +impl_ppi_channel!(PPI_CH5, 5 => configurable); +impl_ppi_channel!(PPI_CH6, 6 => configurable); +impl_ppi_channel!(PPI_CH7, 7 => configurable); +impl_ppi_channel!(PPI_CH8, 8 => configurable); +impl_ppi_channel!(PPI_CH9, 9 => configurable); +impl_ppi_channel!(PPI_CH10, 10 => configurable); +impl_ppi_channel!(PPI_CH11, 11 => configurable); +impl_ppi_channel!(PPI_CH12, 12 => configurable); +impl_ppi_channel!(PPI_CH13, 13 => configurable); +impl_ppi_channel!(PPI_CH14, 14 => configurable); +impl_ppi_channel!(PPI_CH15, 15 => configurable); +impl_ppi_channel!(PPI_CH16, 16 => configurable); +impl_ppi_channel!(PPI_CH17, 17 => configurable); +impl_ppi_channel!(PPI_CH18, 18 => configurable); +impl_ppi_channel!(PPI_CH19, 19 => configurable); +impl_ppi_channel!(PPI_CH20, 20 => static); +impl_ppi_channel!(PPI_CH21, 21 => static); +impl_ppi_channel!(PPI_CH22, 22 => static); +impl_ppi_channel!(PPI_CH23, 23 => static); +impl_ppi_channel!(PPI_CH24, 24 => static); +impl_ppi_channel!(PPI_CH25, 25 => static); +impl_ppi_channel!(PPI_CH26, 26 => static); +impl_ppi_channel!(PPI_CH27, 27 => static); +impl_ppi_channel!(PPI_CH28, 28 => static); +impl_ppi_channel!(PPI_CH29, 29 => static); +impl_ppi_channel!(PPI_CH30, 30 => static); +impl_ppi_channel!(PPI_CH31, 31 => static); impl_saadc_input!(P0_02, ANALOGINPUT0); impl_saadc_input!(P0_03, ANALOGINPUT1); diff --git a/embassy-nrf/src/chips/nrf52811.rs b/embassy-nrf/src/chips/nrf52811.rs index 0c54d9b9..7551492c 100644 --- a/embassy-nrf/src/chips/nrf52811.rs +++ b/embassy-nrf/src/chips/nrf52811.rs @@ -173,38 +173,38 @@ impl_pin!(P0_29, 0, 29); impl_pin!(P0_30, 0, 30); impl_pin!(P0_31, 0, 31); -impl_ppi_channel!(PPI_CH0, 0, true, 1, 2); -impl_ppi_channel!(PPI_CH1, 1, true, 1, 2); -impl_ppi_channel!(PPI_CH2, 2, true, 1, 2); -impl_ppi_channel!(PPI_CH3, 3, true, 1, 2); -impl_ppi_channel!(PPI_CH4, 4, true, 1, 2); -impl_ppi_channel!(PPI_CH5, 5, true, 1, 2); -impl_ppi_channel!(PPI_CH6, 6, true, 1, 2); -impl_ppi_channel!(PPI_CH7, 7, true, 1, 2); -impl_ppi_channel!(PPI_CH8, 8, true, 1, 2); -impl_ppi_channel!(PPI_CH9, 9, true, 1, 2); -impl_ppi_channel!(PPI_CH10, 10, true, 1, 2); -impl_ppi_channel!(PPI_CH11, 11, true, 1, 2); -impl_ppi_channel!(PPI_CH12, 12, true, 1, 2); -impl_ppi_channel!(PPI_CH13, 13, true, 1, 2); -impl_ppi_channel!(PPI_CH14, 14, true, 1, 2); -impl_ppi_channel!(PPI_CH15, 15, true, 1, 2); -impl_ppi_channel!(PPI_CH16, 16, true, 1, 2); -impl_ppi_channel!(PPI_CH17, 17, true, 1, 2); -impl_ppi_channel!(PPI_CH18, 18, true, 1, 2); -impl_ppi_channel!(PPI_CH19, 19, true, 1, 2); -impl_ppi_channel!(PPI_CH20, 20, false, 0, 1); -impl_ppi_channel!(PPI_CH21, 21, false, 0, 1); -impl_ppi_channel!(PPI_CH22, 22, false, 0, 1); -impl_ppi_channel!(PPI_CH23, 23, false, 0, 1); -impl_ppi_channel!(PPI_CH24, 24, false, 0, 1); -impl_ppi_channel!(PPI_CH25, 25, false, 0, 1); -impl_ppi_channel!(PPI_CH26, 26, false, 0, 1); -impl_ppi_channel!(PPI_CH27, 27, false, 0, 1); -impl_ppi_channel!(PPI_CH28, 28, false, 0, 1); -impl_ppi_channel!(PPI_CH29, 29, false, 0, 1); -impl_ppi_channel!(PPI_CH30, 30, false, 0, 1); -impl_ppi_channel!(PPI_CH31, 31, false, 0, 1); +impl_ppi_channel!(PPI_CH0, 0 => configurable); +impl_ppi_channel!(PPI_CH1, 1 => configurable); +impl_ppi_channel!(PPI_CH2, 2 => configurable); +impl_ppi_channel!(PPI_CH3, 3 => configurable); +impl_ppi_channel!(PPI_CH4, 4 => configurable); +impl_ppi_channel!(PPI_CH5, 5 => configurable); +impl_ppi_channel!(PPI_CH6, 6 => configurable); +impl_ppi_channel!(PPI_CH7, 7 => configurable); +impl_ppi_channel!(PPI_CH8, 8 => configurable); +impl_ppi_channel!(PPI_CH9, 9 => configurable); +impl_ppi_channel!(PPI_CH10, 10 => configurable); +impl_ppi_channel!(PPI_CH11, 11 => configurable); +impl_ppi_channel!(PPI_CH12, 12 => configurable); +impl_ppi_channel!(PPI_CH13, 13 => configurable); +impl_ppi_channel!(PPI_CH14, 14 => configurable); +impl_ppi_channel!(PPI_CH15, 15 => configurable); +impl_ppi_channel!(PPI_CH16, 16 => configurable); +impl_ppi_channel!(PPI_CH17, 17 => configurable); +impl_ppi_channel!(PPI_CH18, 18 => configurable); +impl_ppi_channel!(PPI_CH19, 19 => configurable); +impl_ppi_channel!(PPI_CH20, 20 => static); +impl_ppi_channel!(PPI_CH21, 21 => static); +impl_ppi_channel!(PPI_CH22, 22 => static); +impl_ppi_channel!(PPI_CH23, 23 => static); +impl_ppi_channel!(PPI_CH24, 24 => static); +impl_ppi_channel!(PPI_CH25, 25 => static); +impl_ppi_channel!(PPI_CH26, 26 => static); +impl_ppi_channel!(PPI_CH27, 27 => static); +impl_ppi_channel!(PPI_CH28, 28 => static); +impl_ppi_channel!(PPI_CH29, 29 => static); +impl_ppi_channel!(PPI_CH30, 30 => static); +impl_ppi_channel!(PPI_CH31, 31 => static); impl_saadc_input!(P0_02, ANALOGINPUT0); impl_saadc_input!(P0_03, ANALOGINPUT1); diff --git a/embassy-nrf/src/chips/nrf52820.rs b/embassy-nrf/src/chips/nrf52820.rs index d52f2f98..128e1503 100644 --- a/embassy-nrf/src/chips/nrf52820.rs +++ b/embassy-nrf/src/chips/nrf52820.rs @@ -168,38 +168,38 @@ impl_pin!(P0_29, 0, 29); impl_pin!(P0_30, 0, 30); impl_pin!(P0_31, 0, 31); -impl_ppi_channel!(PPI_CH0, 0, true, 1, 2); -impl_ppi_channel!(PPI_CH1, 1, true, 1, 2); -impl_ppi_channel!(PPI_CH2, 2, true, 1, 2); -impl_ppi_channel!(PPI_CH3, 3, true, 1, 2); -impl_ppi_channel!(PPI_CH4, 4, true, 1, 2); -impl_ppi_channel!(PPI_CH5, 5, true, 1, 2); -impl_ppi_channel!(PPI_CH6, 6, true, 1, 2); -impl_ppi_channel!(PPI_CH7, 7, true, 1, 2); -impl_ppi_channel!(PPI_CH8, 8, true, 1, 2); -impl_ppi_channel!(PPI_CH9, 9, true, 1, 2); -impl_ppi_channel!(PPI_CH10, 10, true, 1, 2); -impl_ppi_channel!(PPI_CH11, 11, true, 1, 2); -impl_ppi_channel!(PPI_CH12, 12, true, 1, 2); -impl_ppi_channel!(PPI_CH13, 13, true, 1, 2); -impl_ppi_channel!(PPI_CH14, 14, true, 1, 2); -impl_ppi_channel!(PPI_CH15, 15, true, 1, 2); -impl_ppi_channel!(PPI_CH16, 16, true, 1, 2); -impl_ppi_channel!(PPI_CH17, 17, true, 1, 2); -impl_ppi_channel!(PPI_CH18, 18, true, 1, 2); -impl_ppi_channel!(PPI_CH19, 19, true, 1, 2); -impl_ppi_channel!(PPI_CH20, 20, false, 0, 1); -impl_ppi_channel!(PPI_CH21, 21, false, 0, 1); -impl_ppi_channel!(PPI_CH22, 22, false, 0, 1); -impl_ppi_channel!(PPI_CH23, 23, false, 0, 1); -impl_ppi_channel!(PPI_CH24, 24, false, 0, 1); -impl_ppi_channel!(PPI_CH25, 25, false, 0, 1); -impl_ppi_channel!(PPI_CH26, 26, false, 0, 1); -impl_ppi_channel!(PPI_CH27, 27, false, 0, 1); -impl_ppi_channel!(PPI_CH28, 28, false, 0, 1); -impl_ppi_channel!(PPI_CH29, 29, false, 0, 1); -impl_ppi_channel!(PPI_CH30, 30, false, 0, 1); -impl_ppi_channel!(PPI_CH31, 31, false, 0, 1); +impl_ppi_channel!(PPI_CH0, 0 => configurable); +impl_ppi_channel!(PPI_CH1, 1 => configurable); +impl_ppi_channel!(PPI_CH2, 2 => configurable); +impl_ppi_channel!(PPI_CH3, 3 => configurable); +impl_ppi_channel!(PPI_CH4, 4 => configurable); +impl_ppi_channel!(PPI_CH5, 5 => configurable); +impl_ppi_channel!(PPI_CH6, 6 => configurable); +impl_ppi_channel!(PPI_CH7, 7 => configurable); +impl_ppi_channel!(PPI_CH8, 8 => configurable); +impl_ppi_channel!(PPI_CH9, 9 => configurable); +impl_ppi_channel!(PPI_CH10, 10 => configurable); +impl_ppi_channel!(PPI_CH11, 11 => configurable); +impl_ppi_channel!(PPI_CH12, 12 => configurable); +impl_ppi_channel!(PPI_CH13, 13 => configurable); +impl_ppi_channel!(PPI_CH14, 14 => configurable); +impl_ppi_channel!(PPI_CH15, 15 => configurable); +impl_ppi_channel!(PPI_CH16, 16 => configurable); +impl_ppi_channel!(PPI_CH17, 17 => configurable); +impl_ppi_channel!(PPI_CH18, 18 => configurable); +impl_ppi_channel!(PPI_CH19, 19 => configurable); +impl_ppi_channel!(PPI_CH20, 20 => static); +impl_ppi_channel!(PPI_CH21, 21 => static); +impl_ppi_channel!(PPI_CH22, 22 => static); +impl_ppi_channel!(PPI_CH23, 23 => static); +impl_ppi_channel!(PPI_CH24, 24 => static); +impl_ppi_channel!(PPI_CH25, 25 => static); +impl_ppi_channel!(PPI_CH26, 26 => static); +impl_ppi_channel!(PPI_CH27, 27 => static); +impl_ppi_channel!(PPI_CH28, 28 => static); +impl_ppi_channel!(PPI_CH29, 29 => static); +impl_ppi_channel!(PPI_CH30, 30 => static); +impl_ppi_channel!(PPI_CH31, 31 => static); pub mod irqs { use crate::pac::Interrupt as InterruptEnum; diff --git a/embassy-nrf/src/chips/nrf52832.rs b/embassy-nrf/src/chips/nrf52832.rs index d97a6535..432af143 100644 --- a/embassy-nrf/src/chips/nrf52832.rs +++ b/embassy-nrf/src/chips/nrf52832.rs @@ -190,38 +190,38 @@ impl_pin!(P0_29, 0, 29); impl_pin!(P0_30, 0, 30); impl_pin!(P0_31, 0, 31); -impl_ppi_channel!(PPI_CH0, 0, true, 1, 2); -impl_ppi_channel!(PPI_CH1, 1, true, 1, 2); -impl_ppi_channel!(PPI_CH2, 2, true, 1, 2); -impl_ppi_channel!(PPI_CH3, 3, true, 1, 2); -impl_ppi_channel!(PPI_CH4, 4, true, 1, 2); -impl_ppi_channel!(PPI_CH5, 5, true, 1, 2); -impl_ppi_channel!(PPI_CH6, 6, true, 1, 2); -impl_ppi_channel!(PPI_CH7, 7, true, 1, 2); -impl_ppi_channel!(PPI_CH8, 8, true, 1, 2); -impl_ppi_channel!(PPI_CH9, 9, true, 1, 2); -impl_ppi_channel!(PPI_CH10, 10, true, 1, 2); -impl_ppi_channel!(PPI_CH11, 11, true, 1, 2); -impl_ppi_channel!(PPI_CH12, 12, true, 1, 2); -impl_ppi_channel!(PPI_CH13, 13, true, 1, 2); -impl_ppi_channel!(PPI_CH14, 14, true, 1, 2); -impl_ppi_channel!(PPI_CH15, 15, true, 1, 2); -impl_ppi_channel!(PPI_CH16, 16, true, 1, 2); -impl_ppi_channel!(PPI_CH17, 17, true, 1, 2); -impl_ppi_channel!(PPI_CH18, 18, true, 1, 2); -impl_ppi_channel!(PPI_CH19, 19, true, 1, 2); -impl_ppi_channel!(PPI_CH20, 20, false, 0, 1); -impl_ppi_channel!(PPI_CH21, 21, false, 0, 1); -impl_ppi_channel!(PPI_CH22, 22, false, 0, 1); -impl_ppi_channel!(PPI_CH23, 23, false, 0, 1); -impl_ppi_channel!(PPI_CH24, 24, false, 0, 1); -impl_ppi_channel!(PPI_CH25, 25, false, 0, 1); -impl_ppi_channel!(PPI_CH26, 26, false, 0, 1); -impl_ppi_channel!(PPI_CH27, 27, false, 0, 1); -impl_ppi_channel!(PPI_CH28, 28, false, 0, 1); -impl_ppi_channel!(PPI_CH29, 29, false, 0, 1); -impl_ppi_channel!(PPI_CH30, 30, false, 0, 1); -impl_ppi_channel!(PPI_CH31, 31, false, 0, 1); +impl_ppi_channel!(PPI_CH0, 0 => configurable); +impl_ppi_channel!(PPI_CH1, 1 => configurable); +impl_ppi_channel!(PPI_CH2, 2 => configurable); +impl_ppi_channel!(PPI_CH3, 3 => configurable); +impl_ppi_channel!(PPI_CH4, 4 => configurable); +impl_ppi_channel!(PPI_CH5, 5 => configurable); +impl_ppi_channel!(PPI_CH6, 6 => configurable); +impl_ppi_channel!(PPI_CH7, 7 => configurable); +impl_ppi_channel!(PPI_CH8, 8 => configurable); +impl_ppi_channel!(PPI_CH9, 9 => configurable); +impl_ppi_channel!(PPI_CH10, 10 => configurable); +impl_ppi_channel!(PPI_CH11, 11 => configurable); +impl_ppi_channel!(PPI_CH12, 12 => configurable); +impl_ppi_channel!(PPI_CH13, 13 => configurable); +impl_ppi_channel!(PPI_CH14, 14 => configurable); +impl_ppi_channel!(PPI_CH15, 15 => configurable); +impl_ppi_channel!(PPI_CH16, 16 => configurable); +impl_ppi_channel!(PPI_CH17, 17 => configurable); +impl_ppi_channel!(PPI_CH18, 18 => configurable); +impl_ppi_channel!(PPI_CH19, 19 => configurable); +impl_ppi_channel!(PPI_CH20, 20 => static); +impl_ppi_channel!(PPI_CH21, 21 => static); +impl_ppi_channel!(PPI_CH22, 22 => static); +impl_ppi_channel!(PPI_CH23, 23 => static); +impl_ppi_channel!(PPI_CH24, 24 => static); +impl_ppi_channel!(PPI_CH25, 25 => static); +impl_ppi_channel!(PPI_CH26, 26 => static); +impl_ppi_channel!(PPI_CH27, 27 => static); +impl_ppi_channel!(PPI_CH28, 28 => static); +impl_ppi_channel!(PPI_CH29, 29 => static); +impl_ppi_channel!(PPI_CH30, 30 => static); +impl_ppi_channel!(PPI_CH31, 31 => static); impl_saadc_input!(P0_02, ANALOGINPUT0); impl_saadc_input!(P0_03, ANALOGINPUT1); diff --git a/embassy-nrf/src/chips/nrf52833.rs b/embassy-nrf/src/chips/nrf52833.rs index 9bf370c4..7c7198df 100644 --- a/embassy-nrf/src/chips/nrf52833.rs +++ b/embassy-nrf/src/chips/nrf52833.rs @@ -226,38 +226,38 @@ impl_pin!(P1_13, 1, 13); impl_pin!(P1_14, 1, 14); impl_pin!(P1_15, 1, 15); -impl_ppi_channel!(PPI_CH0, 0, true, 1, 2); -impl_ppi_channel!(PPI_CH1, 1, true, 1, 2); -impl_ppi_channel!(PPI_CH2, 2, true, 1, 2); -impl_ppi_channel!(PPI_CH3, 3, true, 1, 2); -impl_ppi_channel!(PPI_CH4, 4, true, 1, 2); -impl_ppi_channel!(PPI_CH5, 5, true, 1, 2); -impl_ppi_channel!(PPI_CH6, 6, true, 1, 2); -impl_ppi_channel!(PPI_CH7, 7, true, 1, 2); -impl_ppi_channel!(PPI_CH8, 8, true, 1, 2); -impl_ppi_channel!(PPI_CH9, 9, true, 1, 2); -impl_ppi_channel!(PPI_CH10, 10, true, 1, 2); -impl_ppi_channel!(PPI_CH11, 11, true, 1, 2); -impl_ppi_channel!(PPI_CH12, 12, true, 1, 2); -impl_ppi_channel!(PPI_CH13, 13, true, 1, 2); -impl_ppi_channel!(PPI_CH14, 14, true, 1, 2); -impl_ppi_channel!(PPI_CH15, 15, true, 1, 2); -impl_ppi_channel!(PPI_CH16, 16, true, 1, 2); -impl_ppi_channel!(PPI_CH17, 17, true, 1, 2); -impl_ppi_channel!(PPI_CH18, 18, true, 1, 2); -impl_ppi_channel!(PPI_CH19, 19, true, 1, 2); -impl_ppi_channel!(PPI_CH20, 20, false, 0, 1); -impl_ppi_channel!(PPI_CH21, 21, false, 0, 1); -impl_ppi_channel!(PPI_CH22, 22, false, 0, 1); -impl_ppi_channel!(PPI_CH23, 23, false, 0, 1); -impl_ppi_channel!(PPI_CH24, 24, false, 0, 1); -impl_ppi_channel!(PPI_CH25, 25, false, 0, 1); -impl_ppi_channel!(PPI_CH26, 26, false, 0, 1); -impl_ppi_channel!(PPI_CH27, 27, false, 0, 1); -impl_ppi_channel!(PPI_CH28, 28, false, 0, 1); -impl_ppi_channel!(PPI_CH29, 29, false, 0, 1); -impl_ppi_channel!(PPI_CH30, 30, false, 0, 1); -impl_ppi_channel!(PPI_CH31, 31, false, 0, 1); +impl_ppi_channel!(PPI_CH0, 0 => configurable); +impl_ppi_channel!(PPI_CH1, 1 => configurable); +impl_ppi_channel!(PPI_CH2, 2 => configurable); +impl_ppi_channel!(PPI_CH3, 3 => configurable); +impl_ppi_channel!(PPI_CH4, 4 => configurable); +impl_ppi_channel!(PPI_CH5, 5 => configurable); +impl_ppi_channel!(PPI_CH6, 6 => configurable); +impl_ppi_channel!(PPI_CH7, 7 => configurable); +impl_ppi_channel!(PPI_CH8, 8 => configurable); +impl_ppi_channel!(PPI_CH9, 9 => configurable); +impl_ppi_channel!(PPI_CH10, 10 => configurable); +impl_ppi_channel!(PPI_CH11, 11 => configurable); +impl_ppi_channel!(PPI_CH12, 12 => configurable); +impl_ppi_channel!(PPI_CH13, 13 => configurable); +impl_ppi_channel!(PPI_CH14, 14 => configurable); +impl_ppi_channel!(PPI_CH15, 15 => configurable); +impl_ppi_channel!(PPI_CH16, 16 => configurable); +impl_ppi_channel!(PPI_CH17, 17 => configurable); +impl_ppi_channel!(PPI_CH18, 18 => configurable); +impl_ppi_channel!(PPI_CH19, 19 => configurable); +impl_ppi_channel!(PPI_CH20, 20 => static); +impl_ppi_channel!(PPI_CH21, 21 => static); +impl_ppi_channel!(PPI_CH22, 22 => static); +impl_ppi_channel!(PPI_CH23, 23 => static); +impl_ppi_channel!(PPI_CH24, 24 => static); +impl_ppi_channel!(PPI_CH25, 25 => static); +impl_ppi_channel!(PPI_CH26, 26 => static); +impl_ppi_channel!(PPI_CH27, 27 => static); +impl_ppi_channel!(PPI_CH28, 28 => static); +impl_ppi_channel!(PPI_CH29, 29 => static); +impl_ppi_channel!(PPI_CH30, 30 => static); +impl_ppi_channel!(PPI_CH31, 31 => static); impl_saadc_input!(P0_02, ANALOGINPUT0); impl_saadc_input!(P0_03, ANALOGINPUT1); diff --git a/embassy-nrf/src/chips/nrf52840.rs b/embassy-nrf/src/chips/nrf52840.rs index 266328d5..f5b90cd5 100644 --- a/embassy-nrf/src/chips/nrf52840.rs +++ b/embassy-nrf/src/chips/nrf52840.rs @@ -231,38 +231,38 @@ impl_pin!(P1_13, 1, 13); impl_pin!(P1_14, 1, 14); impl_pin!(P1_15, 1, 15); -impl_ppi_channel!(PPI_CH0, 0, true, 1, 2); -impl_ppi_channel!(PPI_CH1, 1, true, 1, 2); -impl_ppi_channel!(PPI_CH2, 2, true, 1, 2); -impl_ppi_channel!(PPI_CH3, 3, true, 1, 2); -impl_ppi_channel!(PPI_CH4, 4, true, 1, 2); -impl_ppi_channel!(PPI_CH5, 5, true, 1, 2); -impl_ppi_channel!(PPI_CH6, 6, true, 1, 2); -impl_ppi_channel!(PPI_CH7, 7, true, 1, 2); -impl_ppi_channel!(PPI_CH8, 8, true, 1, 2); -impl_ppi_channel!(PPI_CH9, 9, true, 1, 2); -impl_ppi_channel!(PPI_CH10, 10, true, 1, 2); -impl_ppi_channel!(PPI_CH11, 11, true, 1, 2); -impl_ppi_channel!(PPI_CH12, 12, true, 1, 2); -impl_ppi_channel!(PPI_CH13, 13, true, 1, 2); -impl_ppi_channel!(PPI_CH14, 14, true, 1, 2); -impl_ppi_channel!(PPI_CH15, 15, true, 1, 2); -impl_ppi_channel!(PPI_CH16, 16, true, 1, 2); -impl_ppi_channel!(PPI_CH17, 17, true, 1, 2); -impl_ppi_channel!(PPI_CH18, 18, true, 1, 2); -impl_ppi_channel!(PPI_CH19, 19, true, 1, 2); -impl_ppi_channel!(PPI_CH20, 20, false, 0, 1); -impl_ppi_channel!(PPI_CH21, 21, false, 0, 1); -impl_ppi_channel!(PPI_CH22, 22, false, 0, 1); -impl_ppi_channel!(PPI_CH23, 23, false, 0, 1); -impl_ppi_channel!(PPI_CH24, 24, false, 0, 1); -impl_ppi_channel!(PPI_CH25, 25, false, 0, 1); -impl_ppi_channel!(PPI_CH26, 26, false, 0, 1); -impl_ppi_channel!(PPI_CH27, 27, false, 0, 1); -impl_ppi_channel!(PPI_CH28, 28, false, 0, 1); -impl_ppi_channel!(PPI_CH29, 29, false, 0, 1); -impl_ppi_channel!(PPI_CH30, 30, false, 0, 1); -impl_ppi_channel!(PPI_CH31, 31, false, 0, 1); +impl_ppi_channel!(PPI_CH0, 0 => configurable); +impl_ppi_channel!(PPI_CH1, 1 => configurable); +impl_ppi_channel!(PPI_CH2, 2 => configurable); +impl_ppi_channel!(PPI_CH3, 3 => configurable); +impl_ppi_channel!(PPI_CH4, 4 => configurable); +impl_ppi_channel!(PPI_CH5, 5 => configurable); +impl_ppi_channel!(PPI_CH6, 6 => configurable); +impl_ppi_channel!(PPI_CH7, 7 => configurable); +impl_ppi_channel!(PPI_CH8, 8 => configurable); +impl_ppi_channel!(PPI_CH9, 9 => configurable); +impl_ppi_channel!(PPI_CH10, 10 => configurable); +impl_ppi_channel!(PPI_CH11, 11 => configurable); +impl_ppi_channel!(PPI_CH12, 12 => configurable); +impl_ppi_channel!(PPI_CH13, 13 => configurable); +impl_ppi_channel!(PPI_CH14, 14 => configurable); +impl_ppi_channel!(PPI_CH15, 15 => configurable); +impl_ppi_channel!(PPI_CH16, 16 => configurable); +impl_ppi_channel!(PPI_CH17, 17 => configurable); +impl_ppi_channel!(PPI_CH18, 18 => configurable); +impl_ppi_channel!(PPI_CH19, 19 => configurable); +impl_ppi_channel!(PPI_CH20, 20 => static); +impl_ppi_channel!(PPI_CH21, 21 => static); +impl_ppi_channel!(PPI_CH22, 22 => static); +impl_ppi_channel!(PPI_CH23, 23 => static); +impl_ppi_channel!(PPI_CH24, 24 => static); +impl_ppi_channel!(PPI_CH25, 25 => static); +impl_ppi_channel!(PPI_CH26, 26 => static); +impl_ppi_channel!(PPI_CH27, 27 => static); +impl_ppi_channel!(PPI_CH28, 28 => static); +impl_ppi_channel!(PPI_CH29, 29 => static); +impl_ppi_channel!(PPI_CH30, 30 => static); +impl_ppi_channel!(PPI_CH31, 31 => static); impl_saadc_input!(P0_02, ANALOGINPUT0); impl_saadc_input!(P0_03, ANALOGINPUT1); diff --git a/embassy-nrf/src/chips/nrf9160.rs b/embassy-nrf/src/chips/nrf9160.rs index 7357e9e2..6ca91810 100644 --- a/embassy-nrf/src/chips/nrf9160.rs +++ b/embassy-nrf/src/chips/nrf9160.rs @@ -184,22 +184,22 @@ impl_pin!(P0_29, 0, 29); impl_pin!(P0_30, 0, 30); impl_pin!(P0_31, 0, 31); -impl_ppi_channel!(PPI_CH0, 0, true, many, many); -impl_ppi_channel!(PPI_CH1, 1, true, many, many); -impl_ppi_channel!(PPI_CH2, 2, true, many, many); -impl_ppi_channel!(PPI_CH3, 3, true, many, many); -impl_ppi_channel!(PPI_CH4, 4, true, many, many); -impl_ppi_channel!(PPI_CH5, 5, true, many, many); -impl_ppi_channel!(PPI_CH6, 6, true, many, many); -impl_ppi_channel!(PPI_CH7, 7, true, many, many); -impl_ppi_channel!(PPI_CH8, 8, true, many, many); -impl_ppi_channel!(PPI_CH9, 9, true, many, many); -impl_ppi_channel!(PPI_CH10, 10, true, many, many); -impl_ppi_channel!(PPI_CH11, 11, true, many, many); -impl_ppi_channel!(PPI_CH12, 12, true, many, many); -impl_ppi_channel!(PPI_CH13, 13, true, many, many); -impl_ppi_channel!(PPI_CH14, 14, true, many, many); -impl_ppi_channel!(PPI_CH15, 15, true, many, many); +impl_ppi_channel!(PPI_CH0, 0 => configurable); +impl_ppi_channel!(PPI_CH1, 1 => configurable); +impl_ppi_channel!(PPI_CH2, 2 => configurable); +impl_ppi_channel!(PPI_CH3, 3 => configurable); +impl_ppi_channel!(PPI_CH4, 4 => configurable); +impl_ppi_channel!(PPI_CH5, 5 => configurable); +impl_ppi_channel!(PPI_CH6, 6 => configurable); +impl_ppi_channel!(PPI_CH7, 7 => configurable); +impl_ppi_channel!(PPI_CH8, 8 => configurable); +impl_ppi_channel!(PPI_CH9, 9 => configurable); +impl_ppi_channel!(PPI_CH10, 10 => configurable); +impl_ppi_channel!(PPI_CH11, 11 => configurable); +impl_ppi_channel!(PPI_CH12, 12 => configurable); +impl_ppi_channel!(PPI_CH13, 13 => configurable); +impl_ppi_channel!(PPI_CH14, 14 => configurable); +impl_ppi_channel!(PPI_CH15, 15 => configurable); impl_saadc_input!(P0_13, ANALOGINPUT0); impl_saadc_input!(P0_14, ANALOGINPUT1); diff --git a/embassy-nrf/src/ppi/mod.rs b/embassy-nrf/src/ppi/mod.rs index bfbc69b7..cea8a0e6 100644 --- a/embassy-nrf/src/ppi/mod.rs +++ b/embassy-nrf/src/ppi/mod.rs @@ -38,21 +38,6 @@ pub struct Ppi<'d, C: Channel, const EVENT_COUNT: usize, const TASK_COUNT: usize impl<'d, C: Channel + 'd, const EVENT_COUNT: usize, const TASK_COUNT: usize> Ppi<'d, C, EVENT_COUNT, TASK_COUNT> { - pub fn degrade(self) -> Ppi<'d, AnyChannel, EVENT_COUNT, TASK_COUNT> { - Ppi { - ch: AnyChannel { - number: self.ch.number() as u8, - #[cfg(feature = "_ppi")] - has_configurable_task: self.ch.is_task_configurable(), - }, - #[cfg(feature = "_dppi")] - events: self.events, - #[cfg(feature = "_dppi")] - tasks: self.tasks, - phantom: PhantomData, - } - } - /// Enables the channel. pub fn enable(&mut self) { let r = unsafe { &*pac::PPI::ptr() }; @@ -77,7 +62,8 @@ impl<'d, C: Channel, const EVENT_COUNT: usize, const TASK_COUNT: usize> Drop } } -impl<'d, C: ZeroToOneChannel> Ppi<'d, C, 0, 1> { +#[cfg(not(feature = "nrf51"))] // Not for nrf51 because of the fork task +impl<'d, C: StaticChannel> Ppi<'d, C, 0, 1> { pub fn new_zero_to_one(ch: impl Unborrow + 'd, task: Task) -> Self { unborrow!(ch); @@ -97,7 +83,7 @@ impl<'d, C: ZeroToOneChannel> Ppi<'d, C, 0, 1> { } } -impl<'d, C: OneToOneChannel> Ppi<'d, C, 1, 1> { +impl<'d, C: ConfigurableChannel> Ppi<'d, C, 1, 1> { pub fn new_one_to_one(ch: impl Unborrow + 'd, event: Event, task: Task) -> Self { unborrow!(ch); @@ -117,7 +103,8 @@ impl<'d, C: OneToOneChannel> Ppi<'d, C, 1, 1> { } } -impl<'d, C: OneToTwoChannel> Ppi<'d, C, 1, 2> { +#[cfg(not(feature = "nrf51"))] // Not for nrf51 because of the fork task +impl<'d, C: ConfigurableChannel> Ppi<'d, C, 1, 2> { pub fn new_one_to_two( ch: impl Unborrow + 'd, event: Event, @@ -142,7 +129,8 @@ impl<'d, C: OneToTwoChannel> Ppi<'d, C, 1, 2> { } } -impl<'d, C: ManyToManyChannel, const EVENT_COUNT: usize, const TASK_COUNT: usize> +#[cfg(feature = "_dppi")] +impl<'d, C: ConfigurableChannel, const EVENT_COUNT: usize, const TASK_COUNT: usize> Ppi<'d, C, EVENT_COUNT, TASK_COUNT> { pub fn new_many_to_many( @@ -221,72 +209,107 @@ pub(crate) mod sealed { pub trait Channel: sealed::Channel + Unborrow + Sized { /// Returns the number of the channel fn number(&self) -> usize; - #[cfg(feature = "_ppi")] - fn is_task_configurable(&self) -> bool; + fn configurable() -> bool; } -pub trait ZeroToOneChannel: Channel {} -pub trait OneToOneChannel: ZeroToOneChannel {} -pub trait OneToTwoChannel: OneToOneChannel {} -pub trait ManyToManyChannel: OneToTwoChannel {} +pub trait ConfigurableChannel: Channel { + fn degrade(self) -> AnyConfigurableChannel; +} + +pub trait StaticChannel: Channel { + fn degrade(self) -> AnyStaticChannel; +} pub trait Group: sealed::Group + Sized { fn number(&self) -> usize; + fn degrade(self) -> AnyGroup { + AnyGroup { + number: self.number() as u8, + } + } } // ====================== // channels -pub struct AnyChannel { - number: u8, - #[cfg(feature = "_ppi")] - has_configurable_task: bool, +/// The any channel can represent any static channel at runtime. +/// This can be used to have fewer generic parameters in some places. +pub struct AnyStaticChannel { + pub(crate) number: u8, } -unsafe_impl_unborrow!(AnyChannel); -impl sealed::Channel for AnyChannel {} -impl Channel for AnyChannel { +unsafe_impl_unborrow!(AnyStaticChannel); +impl sealed::Channel for AnyStaticChannel {} +impl Channel for AnyStaticChannel { fn number(&self) -> usize { self.number as usize } - #[cfg(feature = "_ppi")] - fn is_task_configurable(&self) -> bool { - self.has_configurable_task + fn configurable() -> bool { + false + } +} +impl StaticChannel for AnyStaticChannel { + fn degrade(self) -> AnyStaticChannel { + self + } +} + +/// The any configurable channel can represent any configurable channel at runtime. +/// This can be used to have fewer generic parameters in some places. +pub struct AnyConfigurableChannel { + pub(crate) number: u8, +} +unsafe_impl_unborrow!(AnyConfigurableChannel); +impl sealed::Channel for AnyConfigurableChannel {} +impl Channel for AnyConfigurableChannel { + fn number(&self) -> usize { + self.number as usize + } + + fn configurable() -> bool { + true + } +} +impl ConfigurableChannel for AnyConfigurableChannel { + fn degrade(self) -> AnyConfigurableChannel { + self } } macro_rules! impl_ppi_channel { - ($type:ident, $number:expr, $has_configurable_task:expr) => { + ($type:ident, $number:expr, $configurability:expr) => { impl crate::ppi::sealed::Channel for peripherals::$type {} impl crate::ppi::Channel for peripherals::$type { fn number(&self) -> usize { $number } - #[cfg(feature = "_ppi")] - fn is_task_configurable(&self) -> bool { - $has_configurable_task + fn configurable() -> bool { + $configurability } } }; - ($type:ident, $number:expr, $has_configurable_task:expr, 0, 0) => { - impl_ppi_channel!($type, $number, $has_configurable_task); + ($type:ident, $number:expr => static) => { + impl_ppi_channel!($type, $number, false); + impl crate::ppi::StaticChannel for peripherals::$type { + fn degrade(self) -> crate::ppi::AnyStaticChannel { + use crate::ppi::Channel; + crate::ppi::AnyStaticChannel { + number: self.number() as u8, + } + } + } }; - ($type:ident, $number:expr, $has_configurable_task:expr, 0, 1) => { - impl_ppi_channel!($type, $number, $has_configurable_task, 0, 0); - impl crate::ppi::ZeroToOneChannel for peripherals::$type {} - }; - ($type:ident, $number:expr, $has_configurable_task:expr, 1, 1) => { - impl_ppi_channel!($type, $number, $has_configurable_task, 0, 1); - impl crate::ppi::OneToOneChannel for peripherals::$type {} - }; - ($type:ident, $number:expr, $has_configurable_task:expr, 1, 2) => { - impl_ppi_channel!($type, $number, $has_configurable_task, 1, 1); - impl crate::ppi::OneToTwoChannel for peripherals::$type {} - }; - ($type:ident, $number:expr, $has_configurable_task:expr, many, many) => { - impl_ppi_channel!($type, $number, $has_configurable_task, 1, 2); - impl crate::ppi::ManyToManyChannel for peripherals::$type {} + ($type:ident, $number:expr => configurable) => { + impl_ppi_channel!($type, $number, true); + impl crate::ppi::ConfigurableChannel for peripherals::$type { + fn degrade(self) -> crate::ppi::AnyConfigurableChannel { + use crate::ppi::Channel; + crate::ppi::AnyConfigurableChannel { + number: self.number() as u8, + } + } + } }; } diff --git a/embassy-nrf/src/ppi/ppi.rs b/embassy-nrf/src/ppi/ppi.rs index 67d2086c..0bcb3a79 100644 --- a/embassy-nrf/src/ppi/ppi.rs +++ b/embassy-nrf/src/ppi/ppi.rs @@ -15,6 +15,7 @@ impl<'d, C: Channel + 'd, const EVENT_COUNT: usize, const TASK_COUNT: usize> } } + #[cfg(not(feature = "nrf51"))] fn set_fork_task(task: Option<&Task>, channel: usize) { let r = unsafe { &*pac::PPI::ptr() }; if let Some(task) = task { @@ -40,16 +41,18 @@ impl<'d, C: Channel + 'd, const EVENT_COUNT: usize, const TASK_COUNT: usize> /// Enables all tasks and events pub(super) fn enable_all(tasks: &[Task], events: &[Event], channel: &C) { // One configurable task, no fork - if channel.is_task_configurable() && TASK_COUNT == 1 { + if C::configurable() && TASK_COUNT == 1 { Self::set_main_task(Some(&tasks[0]), channel.number()); } // One configurable task, as fork - if !channel.is_task_configurable() && TASK_COUNT == 1 { + #[cfg(not(feature = "nrf51"))] + if !C::configurable() && TASK_COUNT == 1 { Self::set_fork_task(Some(&tasks[0]), channel.number()); } // Two configurable tasks (main + fork) + #[cfg(not(feature = "nrf51"))] if TASK_COUNT == 2 { Self::set_main_task(Some(&tasks[0]), channel.number()); Self::set_fork_task(Some(&tasks[1]), channel.number()); @@ -62,11 +65,12 @@ impl<'d, C: Channel + 'd, const EVENT_COUNT: usize, const TASK_COUNT: usize> /// Disable all tasks and events pub(super) fn disable_all(&self) { - if self.ch.is_task_configurable() { + if C::configurable() { Self::set_main_task(None, self.ch.number()); } - if TASK_COUNT == 1 && !self.ch.is_task_configurable() || TASK_COUNT == 2 { + #[cfg(not(feature = "nrf51"))] + if TASK_COUNT == 1 && !C::configurable() || TASK_COUNT == 2 { Self::set_fork_task(None, self.ch.number()); } diff --git a/embassy-nrf/src/uarte.rs b/embassy-nrf/src/uarte.rs index 36cf65d8..4bbdec63 100644 --- a/embassy-nrf/src/uarte.rs +++ b/embassy-nrf/src/uarte.rs @@ -18,7 +18,7 @@ use crate::gpio::sealed::Pin as _; use crate::gpio::{self, OptionalPin as GpioOptionalPin, Pin as GpioPin}; use crate::interrupt::Interrupt; use crate::pac; -use crate::ppi::{AnyChannel, Event, OneToOneChannel, OneToTwoChannel, Ppi, Task}; +use crate::ppi::{AnyConfigurableChannel, ConfigurableChannel, Event, Ppi, Task}; use crate::timer::Instance as TimerInstance; use crate::timer::{Frequency, Timer}; @@ -331,8 +331,8 @@ impl<'d, T: Instance> Write for Uarte<'d, T> { pub struct UarteWithIdle<'d, U: Instance, T: TimerInstance> { uarte: Uarte<'d, U>, timer: Timer<'d, T>, - ppi_ch1: Ppi<'d, AnyChannel, 1, 2>, - _ppi_ch2: Ppi<'d, AnyChannel, 1, 1>, + ppi_ch1: Ppi<'d, AnyConfigurableChannel, 1, 2>, + _ppi_ch2: Ppi<'d, AnyConfigurableChannel, 1, 1>, } impl<'d, U: Instance, T: TimerInstance> UarteWithIdle<'d, U, T> { @@ -348,8 +348,8 @@ impl<'d, U: Instance, T: TimerInstance> UarteWithIdle<'d, U, T> { pub unsafe fn new( uarte: impl Unborrow + 'd, timer: impl Unborrow + 'd, - ppi_ch1: impl Unborrow + 'd, - ppi_ch2: impl Unborrow + 'd, + ppi_ch1: impl Unborrow + 'd, + ppi_ch2: impl Unborrow + 'd, irq: impl Unborrow + 'd, rxd: impl Unborrow + 'd, txd: impl Unborrow + 'd, @@ -379,20 +379,18 @@ impl<'d, U: Instance, T: TimerInstance> UarteWithIdle<'d, U, T> { timer.cc(0).short_compare_stop(); let mut ppi_ch1 = Ppi::new_one_to_two( - ppi_ch1, + ppi_ch1.degrade(), Event::from_reg(&r.events_rxdrdy), timer.task_clear(), timer.task_start(), - ) - .degrade(); + ); ppi_ch1.enable(); let mut ppi_ch2 = Ppi::new_one_to_one( - ppi_ch2, + ppi_ch2.degrade(), timer.cc(0).event_compare(), Task::from_reg(&r.tasks_stoprx), - ) - .degrade(); + ); ppi_ch2.enable(); Self {