aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDion Dokter <[email protected]>2021-10-26 09:45:29 +0200
committerDario Nieuwenhuis <[email protected]>2021-10-26 14:47:34 +0200
commitc63d74720980fcf9acbf5b1d8adbb9dc2031d391 (patch)
treea90b0824d649025ce8e44177e542ec0e3610afe7
parent4d3341dbb980131762d714cb5b5d8dfb11060119 (diff)
Fewer channel traits, more cfg to make the system work
-rw-r--r--embassy-nrf/src/buffered_uarte.rs20
-rw-r--r--embassy-nrf/src/chips/nrf52805.rs44
-rw-r--r--embassy-nrf/src/chips/nrf52810.rs64
-rw-r--r--embassy-nrf/src/chips/nrf52811.rs64
-rw-r--r--embassy-nrf/src/chips/nrf52820.rs64
-rw-r--r--embassy-nrf/src/chips/nrf52832.rs64
-rw-r--r--embassy-nrf/src/chips/nrf52833.rs64
-rw-r--r--embassy-nrf/src/chips/nrf52840.rs64
-rw-r--r--embassy-nrf/src/chips/nrf9160.rs32
-rw-r--r--embassy-nrf/src/ppi/mod.rs135
-rw-r--r--embassy-nrf/src/ppi/ppi.rs12
-rw-r--r--embassy-nrf/src/uarte.rs20
12 files changed, 335 insertions, 312 deletions
diff --git a/embassy-nrf/src/buffered_uarte.rs b/embassy-nrf/src/buffered_uarte.rs
index 1dc04f4f6..717ada78d 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};
15use crate::gpio::sealed::Pin as _; 15use crate::gpio::sealed::Pin as _;
16use crate::gpio::{OptionalPin as GpioOptionalPin, Pin as GpioPin}; 16use crate::gpio::{OptionalPin as GpioOptionalPin, Pin as GpioPin};
17use crate::pac; 17use crate::pac;
18use crate::ppi::{AnyChannel, Event, OneToOneChannel, OneToTwoChannel, Ppi, Task}; 18use crate::ppi::{AnyConfigurableChannel, ConfigurableChannel, Event, Ppi, Task};
19use crate::timer::Instance as TimerInstance; 19use crate::timer::Instance as TimerInstance;
20use crate::timer::{Frequency, Timer}; 20use crate::timer::{Frequency, Timer};
21use crate::uarte::{Config, Instance as UarteInstance}; 21use crate::uarte::{Config, Instance as UarteInstance};
@@ -45,8 +45,8 @@ impl<'d, U: UarteInstance, T: TimerInstance> State<'d, U, T> {
45struct StateInner<'d, U: UarteInstance, T: TimerInstance> { 45struct StateInner<'d, U: UarteInstance, T: TimerInstance> {
46 phantom: PhantomData<&'d mut U>, 46 phantom: PhantomData<&'d mut U>,
47 timer: Timer<'d, T>, 47 timer: Timer<'d, T>,
48 _ppi_ch1: Ppi<'d, AnyChannel, 1, 2>, 48 _ppi_ch1: Ppi<'d, AnyConfigurableChannel, 1, 2>,
49 _ppi_ch2: Ppi<'d, AnyChannel, 1, 1>, 49 _ppi_ch2: Ppi<'d, AnyConfigurableChannel, 1, 1>,
50 50
51 rx: RingBuffer<'d>, 51 rx: RingBuffer<'d>,
52 rx_state: RxState, 52 rx_state: RxState,
@@ -70,8 +70,8 @@ impl<'d, U: UarteInstance, T: TimerInstance> BufferedUarte<'d, U, T> {
70 state: &'d mut State<'d, U, T>, 70 state: &'d mut State<'d, U, T>,
71 _uarte: impl Unborrow<Target = U> + 'd, 71 _uarte: impl Unborrow<Target = U> + 'd,
72 timer: impl Unborrow<Target = T> + 'd, 72 timer: impl Unborrow<Target = T> + 'd,
73 ppi_ch1: impl Unborrow<Target = impl OneToTwoChannel + 'd> + 'd, 73 ppi_ch1: impl Unborrow<Target = impl ConfigurableChannel + 'd> + 'd,
74 ppi_ch2: impl Unborrow<Target = impl OneToOneChannel + 'd> + 'd, 74 ppi_ch2: impl Unborrow<Target = impl ConfigurableChannel + 'd> + 'd,
75 irq: impl Unborrow<Target = U::Interrupt> + 'd, 75 irq: impl Unborrow<Target = U::Interrupt> + 'd,
76 rxd: impl Unborrow<Target = impl GpioPin> + 'd, 76 rxd: impl Unborrow<Target = impl GpioPin> + 'd,
77 txd: impl Unborrow<Target = impl GpioPin> + 'd, 77 txd: impl Unborrow<Target = impl GpioPin> + 'd,
@@ -145,20 +145,18 @@ impl<'d, U: UarteInstance, T: TimerInstance> BufferedUarte<'d, U, T> {
145 timer.cc(0).short_compare_stop(); 145 timer.cc(0).short_compare_stop();
146 146
147 let mut ppi_ch1 = Ppi::new_one_to_two( 147 let mut ppi_ch1 = Ppi::new_one_to_two(
148 ppi_ch1, 148 ppi_ch1.degrade(),
149 Event::from_reg(&r.events_rxdrdy), 149 Event::from_reg(&r.events_rxdrdy),
150 timer.task_clear(), 150 timer.task_clear(),
151 timer.task_start(), 151 timer.task_start(),
152 ) 152 );
153 .degrade();
154 ppi_ch1.enable(); 153 ppi_ch1.enable();
155 154
156 let mut ppi_ch2 = Ppi::new_one_to_one( 155 let mut ppi_ch2 = Ppi::new_one_to_one(
157 ppi_ch2, 156 ppi_ch2.degrade(),
158 timer.cc(0).event_compare(), 157 timer.cc(0).event_compare(),
159 Task::from_reg(&r.tasks_stoprx), 158 Task::from_reg(&r.tasks_stoprx),
160 ) 159 );
161 .degrade();
162 ppi_ch2.enable(); 160 ppi_ch2.enable();
163 161
164 Self { 162 Self {
diff --git a/embassy-nrf/src/chips/nrf52805.rs b/embassy-nrf/src/chips/nrf52805.rs
index 326f4a8be..689896485 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);
167impl_pin!(P0_30, 0, 30); 167impl_pin!(P0_30, 0, 30);
168impl_pin!(P0_31, 0, 31); 168impl_pin!(P0_31, 0, 31);
169 169
170impl_ppi_channel!(PPI_CH0, 0, true, 1, 2); 170impl_ppi_channel!(PPI_CH0, 0 => configurable);
171impl_ppi_channel!(PPI_CH1, 1, true, 1, 2); 171impl_ppi_channel!(PPI_CH1, 1 => configurable);
172impl_ppi_channel!(PPI_CH2, 2, true, 1, 2); 172impl_ppi_channel!(PPI_CH2, 2 => configurable);
173impl_ppi_channel!(PPI_CH3, 3, true, 1, 2); 173impl_ppi_channel!(PPI_CH3, 3 => configurable);
174impl_ppi_channel!(PPI_CH4, 4, true, 1, 2); 174impl_ppi_channel!(PPI_CH4, 4 => configurable);
175impl_ppi_channel!(PPI_CH5, 5, true, 1, 2); 175impl_ppi_channel!(PPI_CH5, 5 => configurable);
176impl_ppi_channel!(PPI_CH6, 6, true, 1, 2); 176impl_ppi_channel!(PPI_CH6, 6 => configurable);
177impl_ppi_channel!(PPI_CH7, 7, true, 1, 2); 177impl_ppi_channel!(PPI_CH7, 7 => configurable);
178impl_ppi_channel!(PPI_CH8, 8, true, 1, 2); 178impl_ppi_channel!(PPI_CH8, 8 => configurable);
179impl_ppi_channel!(PPI_CH9, 9, true, 1, 2); 179impl_ppi_channel!(PPI_CH9, 9 => configurable);
180impl_ppi_channel!(PPI_CH20, 20, false, 0, 1); 180impl_ppi_channel!(PPI_CH20, 20 => static);
181impl_ppi_channel!(PPI_CH21, 21, false, 0, 1); 181impl_ppi_channel!(PPI_CH21, 21 => static);
182impl_ppi_channel!(PPI_CH22, 22, false, 0, 1); 182impl_ppi_channel!(PPI_CH22, 22 => static);
183impl_ppi_channel!(PPI_CH23, 23, false, 0, 1); 183impl_ppi_channel!(PPI_CH23, 23 => static);
184impl_ppi_channel!(PPI_CH24, 24, false, 0, 1); 184impl_ppi_channel!(PPI_CH24, 24 => static);
185impl_ppi_channel!(PPI_CH25, 25, false, 0, 1); 185impl_ppi_channel!(PPI_CH25, 25 => static);
186impl_ppi_channel!(PPI_CH26, 26, false, 0, 1); 186impl_ppi_channel!(PPI_CH26, 26 => static);
187impl_ppi_channel!(PPI_CH27, 27, false, 0, 1); 187impl_ppi_channel!(PPI_CH27, 27 => static);
188impl_ppi_channel!(PPI_CH28, 28, false, 0, 1); 188impl_ppi_channel!(PPI_CH28, 28 => static);
189impl_ppi_channel!(PPI_CH29, 29, false, 0, 1); 189impl_ppi_channel!(PPI_CH29, 29 => static);
190impl_ppi_channel!(PPI_CH30, 30, false, 0, 1); 190impl_ppi_channel!(PPI_CH30, 30 => static);
191impl_ppi_channel!(PPI_CH31, 31, false, 0, 1); 191impl_ppi_channel!(PPI_CH31, 31 => static);
192 192
193impl_saadc_input!(P0_04, ANALOGINPUT2); 193impl_saadc_input!(P0_04, ANALOGINPUT2);
194impl_saadc_input!(P0_05, ANALOGINPUT3); 194impl_saadc_input!(P0_05, ANALOGINPUT3);
diff --git a/embassy-nrf/src/chips/nrf52810.rs b/embassy-nrf/src/chips/nrf52810.rs
index 4c16d51a7..b3b3593bb 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);
172impl_pin!(P0_30, 0, 30); 172impl_pin!(P0_30, 0, 30);
173impl_pin!(P0_31, 0, 31); 173impl_pin!(P0_31, 0, 31);
174 174
175impl_ppi_channel!(PPI_CH0, 0, true, 1, 2); 175impl_ppi_channel!(PPI_CH0, 0 => configurable);
176impl_ppi_channel!(PPI_CH1, 1, true, 1, 2); 176impl_ppi_channel!(PPI_CH1, 1 => configurable);
177impl_ppi_channel!(PPI_CH2, 2, true, 1, 2); 177impl_ppi_channel!(PPI_CH2, 2 => configurable);
178impl_ppi_channel!(PPI_CH3, 3, true, 1, 2); 178impl_ppi_channel!(PPI_CH3, 3 => configurable);
179impl_ppi_channel!(PPI_CH4, 4, true, 1, 2); 179impl_ppi_channel!(PPI_CH4, 4 => configurable);
180impl_ppi_channel!(PPI_CH5, 5, true, 1, 2); 180impl_ppi_channel!(PPI_CH5, 5 => configurable);
181impl_ppi_channel!(PPI_CH6, 6, true, 1, 2); 181impl_ppi_channel!(PPI_CH6, 6 => configurable);
182impl_ppi_channel!(PPI_CH7, 7, true, 1, 2); 182impl_ppi_channel!(PPI_CH7, 7 => configurable);
183impl_ppi_channel!(PPI_CH8, 8, true, 1, 2); 183impl_ppi_channel!(PPI_CH8, 8 => configurable);
184impl_ppi_channel!(PPI_CH9, 9, true, 1, 2); 184impl_ppi_channel!(PPI_CH9, 9 => configurable);
185impl_ppi_channel!(PPI_CH10, 10, true, 1, 2); 185impl_ppi_channel!(PPI_CH10, 10 => configurable);
186impl_ppi_channel!(PPI_CH11, 11, true, 1, 2); 186impl_ppi_channel!(PPI_CH11, 11 => configurable);
187impl_ppi_channel!(PPI_CH12, 12, true, 1, 2); 187impl_ppi_channel!(PPI_CH12, 12 => configurable);
188impl_ppi_channel!(PPI_CH13, 13, true, 1, 2); 188impl_ppi_channel!(PPI_CH13, 13 => configurable);
189impl_ppi_channel!(PPI_CH14, 14, true, 1, 2); 189impl_ppi_channel!(PPI_CH14, 14 => configurable);
190impl_ppi_channel!(PPI_CH15, 15, true, 1, 2); 190impl_ppi_channel!(PPI_CH15, 15 => configurable);
191impl_ppi_channel!(PPI_CH16, 16, true, 1, 2); 191impl_ppi_channel!(PPI_CH16, 16 => configurable);
192impl_ppi_channel!(PPI_CH17, 17, true, 1, 2); 192impl_ppi_channel!(PPI_CH17, 17 => configurable);
193impl_ppi_channel!(PPI_CH18, 18, true, 1, 2); 193impl_ppi_channel!(PPI_CH18, 18 => configurable);
194impl_ppi_channel!(PPI_CH19, 19, true, 1, 2); 194impl_ppi_channel!(PPI_CH19, 19 => configurable);
195impl_ppi_channel!(PPI_CH20, 20, false, 0, 1); 195impl_ppi_channel!(PPI_CH20, 20 => static);
196impl_ppi_channel!(PPI_CH21, 21, false, 0, 1); 196impl_ppi_channel!(PPI_CH21, 21 => static);
197impl_ppi_channel!(PPI_CH22, 22, false, 0, 1); 197impl_ppi_channel!(PPI_CH22, 22 => static);
198impl_ppi_channel!(PPI_CH23, 23, false, 0, 1); 198impl_ppi_channel!(PPI_CH23, 23 => static);
199impl_ppi_channel!(PPI_CH24, 24, false, 0, 1); 199impl_ppi_channel!(PPI_CH24, 24 => static);
200impl_ppi_channel!(PPI_CH25, 25, false, 0, 1); 200impl_ppi_channel!(PPI_CH25, 25 => static);
201impl_ppi_channel!(PPI_CH26, 26, false, 0, 1); 201impl_ppi_channel!(PPI_CH26, 26 => static);
202impl_ppi_channel!(PPI_CH27, 27, false, 0, 1); 202impl_ppi_channel!(PPI_CH27, 27 => static);
203impl_ppi_channel!(PPI_CH28, 28, false, 0, 1); 203impl_ppi_channel!(PPI_CH28, 28 => static);
204impl_ppi_channel!(PPI_CH29, 29, false, 0, 1); 204impl_ppi_channel!(PPI_CH29, 29 => static);
205impl_ppi_channel!(PPI_CH30, 30, false, 0, 1); 205impl_ppi_channel!(PPI_CH30, 30 => static);
206impl_ppi_channel!(PPI_CH31, 31, false, 0, 1); 206impl_ppi_channel!(PPI_CH31, 31 => static);
207 207
208impl_saadc_input!(P0_02, ANALOGINPUT0); 208impl_saadc_input!(P0_02, ANALOGINPUT0);
209impl_saadc_input!(P0_03, ANALOGINPUT1); 209impl_saadc_input!(P0_03, ANALOGINPUT1);
diff --git a/embassy-nrf/src/chips/nrf52811.rs b/embassy-nrf/src/chips/nrf52811.rs
index 0c54d9b9e..7551492c3 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);
173impl_pin!(P0_30, 0, 30); 173impl_pin!(P0_30, 0, 30);
174impl_pin!(P0_31, 0, 31); 174impl_pin!(P0_31, 0, 31);
175 175
176impl_ppi_channel!(PPI_CH0, 0, true, 1, 2); 176impl_ppi_channel!(PPI_CH0, 0 => configurable);
177impl_ppi_channel!(PPI_CH1, 1, true, 1, 2); 177impl_ppi_channel!(PPI_CH1, 1 => configurable);
178impl_ppi_channel!(PPI_CH2, 2, true, 1, 2); 178impl_ppi_channel!(PPI_CH2, 2 => configurable);
179impl_ppi_channel!(PPI_CH3, 3, true, 1, 2); 179impl_ppi_channel!(PPI_CH3, 3 => configurable);
180impl_ppi_channel!(PPI_CH4, 4, true, 1, 2); 180impl_ppi_channel!(PPI_CH4, 4 => configurable);
181impl_ppi_channel!(PPI_CH5, 5, true, 1, 2); 181impl_ppi_channel!(PPI_CH5, 5 => configurable);
182impl_ppi_channel!(PPI_CH6, 6, true, 1, 2); 182impl_ppi_channel!(PPI_CH6, 6 => configurable);
183impl_ppi_channel!(PPI_CH7, 7, true, 1, 2); 183impl_ppi_channel!(PPI_CH7, 7 => configurable);
184impl_ppi_channel!(PPI_CH8, 8, true, 1, 2); 184impl_ppi_channel!(PPI_CH8, 8 => configurable);
185impl_ppi_channel!(PPI_CH9, 9, true, 1, 2); 185impl_ppi_channel!(PPI_CH9, 9 => configurable);
186impl_ppi_channel!(PPI_CH10, 10, true, 1, 2); 186impl_ppi_channel!(PPI_CH10, 10 => configurable);
187impl_ppi_channel!(PPI_CH11, 11, true, 1, 2); 187impl_ppi_channel!(PPI_CH11, 11 => configurable);
188impl_ppi_channel!(PPI_CH12, 12, true, 1, 2); 188impl_ppi_channel!(PPI_CH12, 12 => configurable);
189impl_ppi_channel!(PPI_CH13, 13, true, 1, 2); 189impl_ppi_channel!(PPI_CH13, 13 => configurable);
190impl_ppi_channel!(PPI_CH14, 14, true, 1, 2); 190impl_ppi_channel!(PPI_CH14, 14 => configurable);
191impl_ppi_channel!(PPI_CH15, 15, true, 1, 2); 191impl_ppi_channel!(PPI_CH15, 15 => configurable);
192impl_ppi_channel!(PPI_CH16, 16, true, 1, 2); 192impl_ppi_channel!(PPI_CH16, 16 => configurable);
193impl_ppi_channel!(PPI_CH17, 17, true, 1, 2); 193impl_ppi_channel!(PPI_CH17, 17 => configurable);
194impl_ppi_channel!(PPI_CH18, 18, true, 1, 2); 194impl_ppi_channel!(PPI_CH18, 18 => configurable);
195impl_ppi_channel!(PPI_CH19, 19, true, 1, 2); 195impl_ppi_channel!(PPI_CH19, 19 => configurable);
196impl_ppi_channel!(PPI_CH20, 20, false, 0, 1); 196impl_ppi_channel!(PPI_CH20, 20 => static);
197impl_ppi_channel!(PPI_CH21, 21, false, 0, 1); 197impl_ppi_channel!(PPI_CH21, 21 => static);
198impl_ppi_channel!(PPI_CH22, 22, false, 0, 1); 198impl_ppi_channel!(PPI_CH22, 22 => static);
199impl_ppi_channel!(PPI_CH23, 23, false, 0, 1); 199impl_ppi_channel!(PPI_CH23, 23 => static);
200impl_ppi_channel!(PPI_CH24, 24, false, 0, 1); 200impl_ppi_channel!(PPI_CH24, 24 => static);
201impl_ppi_channel!(PPI_CH25, 25, false, 0, 1); 201impl_ppi_channel!(PPI_CH25, 25 => static);
202impl_ppi_channel!(PPI_CH26, 26, false, 0, 1); 202impl_ppi_channel!(PPI_CH26, 26 => static);
203impl_ppi_channel!(PPI_CH27, 27, false, 0, 1); 203impl_ppi_channel!(PPI_CH27, 27 => static);
204impl_ppi_channel!(PPI_CH28, 28, false, 0, 1); 204impl_ppi_channel!(PPI_CH28, 28 => static);
205impl_ppi_channel!(PPI_CH29, 29, false, 0, 1); 205impl_ppi_channel!(PPI_CH29, 29 => static);
206impl_ppi_channel!(PPI_CH30, 30, false, 0, 1); 206impl_ppi_channel!(PPI_CH30, 30 => static);
207impl_ppi_channel!(PPI_CH31, 31, false, 0, 1); 207impl_ppi_channel!(PPI_CH31, 31 => static);
208 208
209impl_saadc_input!(P0_02, ANALOGINPUT0); 209impl_saadc_input!(P0_02, ANALOGINPUT0);
210impl_saadc_input!(P0_03, ANALOGINPUT1); 210impl_saadc_input!(P0_03, ANALOGINPUT1);
diff --git a/embassy-nrf/src/chips/nrf52820.rs b/embassy-nrf/src/chips/nrf52820.rs
index d52f2f98a..128e1503f 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);
168impl_pin!(P0_30, 0, 30); 168impl_pin!(P0_30, 0, 30);
169impl_pin!(P0_31, 0, 31); 169impl_pin!(P0_31, 0, 31);
170 170
171impl_ppi_channel!(PPI_CH0, 0, true, 1, 2); 171impl_ppi_channel!(PPI_CH0, 0 => configurable);
172impl_ppi_channel!(PPI_CH1, 1, true, 1, 2); 172impl_ppi_channel!(PPI_CH1, 1 => configurable);
173impl_ppi_channel!(PPI_CH2, 2, true, 1, 2); 173impl_ppi_channel!(PPI_CH2, 2 => configurable);
174impl_ppi_channel!(PPI_CH3, 3, true, 1, 2); 174impl_ppi_channel!(PPI_CH3, 3 => configurable);
175impl_ppi_channel!(PPI_CH4, 4, true, 1, 2); 175impl_ppi_channel!(PPI_CH4, 4 => configurable);
176impl_ppi_channel!(PPI_CH5, 5, true, 1, 2); 176impl_ppi_channel!(PPI_CH5, 5 => configurable);
177impl_ppi_channel!(PPI_CH6, 6, true, 1, 2); 177impl_ppi_channel!(PPI_CH6, 6 => configurable);
178impl_ppi_channel!(PPI_CH7, 7, true, 1, 2); 178impl_ppi_channel!(PPI_CH7, 7 => configurable);
179impl_ppi_channel!(PPI_CH8, 8, true, 1, 2); 179impl_ppi_channel!(PPI_CH8, 8 => configurable);
180impl_ppi_channel!(PPI_CH9, 9, true, 1, 2); 180impl_ppi_channel!(PPI_CH9, 9 => configurable);
181impl_ppi_channel!(PPI_CH10, 10, true, 1, 2); 181impl_ppi_channel!(PPI_CH10, 10 => configurable);
182impl_ppi_channel!(PPI_CH11, 11, true, 1, 2); 182impl_ppi_channel!(PPI_CH11, 11 => configurable);
183impl_ppi_channel!(PPI_CH12, 12, true, 1, 2); 183impl_ppi_channel!(PPI_CH12, 12 => configurable);
184impl_ppi_channel!(PPI_CH13, 13, true, 1, 2); 184impl_ppi_channel!(PPI_CH13, 13 => configurable);
185impl_ppi_channel!(PPI_CH14, 14, true, 1, 2); 185impl_ppi_channel!(PPI_CH14, 14 => configurable);
186impl_ppi_channel!(PPI_CH15, 15, true, 1, 2); 186impl_ppi_channel!(PPI_CH15, 15 => configurable);
187impl_ppi_channel!(PPI_CH16, 16, true, 1, 2); 187impl_ppi_channel!(PPI_CH16, 16 => configurable);
188impl_ppi_channel!(PPI_CH17, 17, true, 1, 2); 188impl_ppi_channel!(PPI_CH17, 17 => configurable);
189impl_ppi_channel!(PPI_CH18, 18, true, 1, 2); 189impl_ppi_channel!(PPI_CH18, 18 => configurable);
190impl_ppi_channel!(PPI_CH19, 19, true, 1, 2); 190impl_ppi_channel!(PPI_CH19, 19 => configurable);
191impl_ppi_channel!(PPI_CH20, 20, false, 0, 1); 191impl_ppi_channel!(PPI_CH20, 20 => static);
192impl_ppi_channel!(PPI_CH21, 21, false, 0, 1); 192impl_ppi_channel!(PPI_CH21, 21 => static);
193impl_ppi_channel!(PPI_CH22, 22, false, 0, 1); 193impl_ppi_channel!(PPI_CH22, 22 => static);
194impl_ppi_channel!(PPI_CH23, 23, false, 0, 1); 194impl_ppi_channel!(PPI_CH23, 23 => static);
195impl_ppi_channel!(PPI_CH24, 24, false, 0, 1); 195impl_ppi_channel!(PPI_CH24, 24 => static);
196impl_ppi_channel!(PPI_CH25, 25, false, 0, 1); 196impl_ppi_channel!(PPI_CH25, 25 => static);
197impl_ppi_channel!(PPI_CH26, 26, false, 0, 1); 197impl_ppi_channel!(PPI_CH26, 26 => static);
198impl_ppi_channel!(PPI_CH27, 27, false, 0, 1); 198impl_ppi_channel!(PPI_CH27, 27 => static);
199impl_ppi_channel!(PPI_CH28, 28, false, 0, 1); 199impl_ppi_channel!(PPI_CH28, 28 => static);
200impl_ppi_channel!(PPI_CH29, 29, false, 0, 1); 200impl_ppi_channel!(PPI_CH29, 29 => static);
201impl_ppi_channel!(PPI_CH30, 30, false, 0, 1); 201impl_ppi_channel!(PPI_CH30, 30 => static);
202impl_ppi_channel!(PPI_CH31, 31, false, 0, 1); 202impl_ppi_channel!(PPI_CH31, 31 => static);
203 203
204pub mod irqs { 204pub mod irqs {
205 use crate::pac::Interrupt as InterruptEnum; 205 use crate::pac::Interrupt as InterruptEnum;
diff --git a/embassy-nrf/src/chips/nrf52832.rs b/embassy-nrf/src/chips/nrf52832.rs
index d97a65350..432af143c 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);
190impl_pin!(P0_30, 0, 30); 190impl_pin!(P0_30, 0, 30);
191impl_pin!(P0_31, 0, 31); 191impl_pin!(P0_31, 0, 31);
192 192
193impl_ppi_channel!(PPI_CH0, 0, true, 1, 2); 193impl_ppi_channel!(PPI_CH0, 0 => configurable);
194impl_ppi_channel!(PPI_CH1, 1, true, 1, 2); 194impl_ppi_channel!(PPI_CH1, 1 => configurable);
195impl_ppi_channel!(PPI_CH2, 2, true, 1, 2); 195impl_ppi_channel!(PPI_CH2, 2 => configurable);
196impl_ppi_channel!(PPI_CH3, 3, true, 1, 2); 196impl_ppi_channel!(PPI_CH3, 3 => configurable);
197impl_ppi_channel!(PPI_CH4, 4, true, 1, 2); 197impl_ppi_channel!(PPI_CH4, 4 => configurable);
198impl_ppi_channel!(PPI_CH5, 5, true, 1, 2); 198impl_ppi_channel!(PPI_CH5, 5 => configurable);
199impl_ppi_channel!(PPI_CH6, 6, true, 1, 2); 199impl_ppi_channel!(PPI_CH6, 6 => configurable);
200impl_ppi_channel!(PPI_CH7, 7, true, 1, 2); 200impl_ppi_channel!(PPI_CH7, 7 => configurable);
201impl_ppi_channel!(PPI_CH8, 8, true, 1, 2); 201impl_ppi_channel!(PPI_CH8, 8 => configurable);
202impl_ppi_channel!(PPI_CH9, 9, true, 1, 2); 202impl_ppi_channel!(PPI_CH9, 9 => configurable);
203impl_ppi_channel!(PPI_CH10, 10, true, 1, 2); 203impl_ppi_channel!(PPI_CH10, 10 => configurable);
204impl_ppi_channel!(PPI_CH11, 11, true, 1, 2); 204impl_ppi_channel!(PPI_CH11, 11 => configurable);
205impl_ppi_channel!(PPI_CH12, 12, true, 1, 2); 205impl_ppi_channel!(PPI_CH12, 12 => configurable);
206impl_ppi_channel!(PPI_CH13, 13, true, 1, 2); 206impl_ppi_channel!(PPI_CH13, 13 => configurable);
207impl_ppi_channel!(PPI_CH14, 14, true, 1, 2); 207impl_ppi_channel!(PPI_CH14, 14 => configurable);
208impl_ppi_channel!(PPI_CH15, 15, true, 1, 2); 208impl_ppi_channel!(PPI_CH15, 15 => configurable);
209impl_ppi_channel!(PPI_CH16, 16, true, 1, 2); 209impl_ppi_channel!(PPI_CH16, 16 => configurable);
210impl_ppi_channel!(PPI_CH17, 17, true, 1, 2); 210impl_ppi_channel!(PPI_CH17, 17 => configurable);
211impl_ppi_channel!(PPI_CH18, 18, true, 1, 2); 211impl_ppi_channel!(PPI_CH18, 18 => configurable);
212impl_ppi_channel!(PPI_CH19, 19, true, 1, 2); 212impl_ppi_channel!(PPI_CH19, 19 => configurable);
213impl_ppi_channel!(PPI_CH20, 20, false, 0, 1); 213impl_ppi_channel!(PPI_CH20, 20 => static);
214impl_ppi_channel!(PPI_CH21, 21, false, 0, 1); 214impl_ppi_channel!(PPI_CH21, 21 => static);
215impl_ppi_channel!(PPI_CH22, 22, false, 0, 1); 215impl_ppi_channel!(PPI_CH22, 22 => static);
216impl_ppi_channel!(PPI_CH23, 23, false, 0, 1); 216impl_ppi_channel!(PPI_CH23, 23 => static);
217impl_ppi_channel!(PPI_CH24, 24, false, 0, 1); 217impl_ppi_channel!(PPI_CH24, 24 => static);
218impl_ppi_channel!(PPI_CH25, 25, false, 0, 1); 218impl_ppi_channel!(PPI_CH25, 25 => static);
219impl_ppi_channel!(PPI_CH26, 26, false, 0, 1); 219impl_ppi_channel!(PPI_CH26, 26 => static);
220impl_ppi_channel!(PPI_CH27, 27, false, 0, 1); 220impl_ppi_channel!(PPI_CH27, 27 => static);
221impl_ppi_channel!(PPI_CH28, 28, false, 0, 1); 221impl_ppi_channel!(PPI_CH28, 28 => static);
222impl_ppi_channel!(PPI_CH29, 29, false, 0, 1); 222impl_ppi_channel!(PPI_CH29, 29 => static);
223impl_ppi_channel!(PPI_CH30, 30, false, 0, 1); 223impl_ppi_channel!(PPI_CH30, 30 => static);
224impl_ppi_channel!(PPI_CH31, 31, false, 0, 1); 224impl_ppi_channel!(PPI_CH31, 31 => static);
225 225
226impl_saadc_input!(P0_02, ANALOGINPUT0); 226impl_saadc_input!(P0_02, ANALOGINPUT0);
227impl_saadc_input!(P0_03, ANALOGINPUT1); 227impl_saadc_input!(P0_03, ANALOGINPUT1);
diff --git a/embassy-nrf/src/chips/nrf52833.rs b/embassy-nrf/src/chips/nrf52833.rs
index 9bf370c4b..7c7198dfd 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);
226impl_pin!(P1_14, 1, 14); 226impl_pin!(P1_14, 1, 14);
227impl_pin!(P1_15, 1, 15); 227impl_pin!(P1_15, 1, 15);
228 228
229impl_ppi_channel!(PPI_CH0, 0, true, 1, 2); 229impl_ppi_channel!(PPI_CH0, 0 => configurable);
230impl_ppi_channel!(PPI_CH1, 1, true, 1, 2); 230impl_ppi_channel!(PPI_CH1, 1 => configurable);
231impl_ppi_channel!(PPI_CH2, 2, true, 1, 2); 231impl_ppi_channel!(PPI_CH2, 2 => configurable);
232impl_ppi_channel!(PPI_CH3, 3, true, 1, 2); 232impl_ppi_channel!(PPI_CH3, 3 => configurable);
233impl_ppi_channel!(PPI_CH4, 4, true, 1, 2); 233impl_ppi_channel!(PPI_CH4, 4 => configurable);
234impl_ppi_channel!(PPI_CH5, 5, true, 1, 2); 234impl_ppi_channel!(PPI_CH5, 5 => configurable);
235impl_ppi_channel!(PPI_CH6, 6, true, 1, 2); 235impl_ppi_channel!(PPI_CH6, 6 => configurable);
236impl_ppi_channel!(PPI_CH7, 7, true, 1, 2); 236impl_ppi_channel!(PPI_CH7, 7 => configurable);
237impl_ppi_channel!(PPI_CH8, 8, true, 1, 2); 237impl_ppi_channel!(PPI_CH8, 8 => configurable);
238impl_ppi_channel!(PPI_CH9, 9, true, 1, 2); 238impl_ppi_channel!(PPI_CH9, 9 => configurable);
239impl_ppi_channel!(PPI_CH10, 10, true, 1, 2); 239impl_ppi_channel!(PPI_CH10, 10 => configurable);
240impl_ppi_channel!(PPI_CH11, 11, true, 1, 2); 240impl_ppi_channel!(PPI_CH11, 11 => configurable);
241impl_ppi_channel!(PPI_CH12, 12, true, 1, 2); 241impl_ppi_channel!(PPI_CH12, 12 => configurable);
242impl_ppi_channel!(PPI_CH13, 13, true, 1, 2); 242impl_ppi_channel!(PPI_CH13, 13 => configurable);
243impl_ppi_channel!(PPI_CH14, 14, true, 1, 2); 243impl_ppi_channel!(PPI_CH14, 14 => configurable);
244impl_ppi_channel!(PPI_CH15, 15, true, 1, 2); 244impl_ppi_channel!(PPI_CH15, 15 => configurable);
245impl_ppi_channel!(PPI_CH16, 16, true, 1, 2); 245impl_ppi_channel!(PPI_CH16, 16 => configurable);
246impl_ppi_channel!(PPI_CH17, 17, true, 1, 2); 246impl_ppi_channel!(PPI_CH17, 17 => configurable);
247impl_ppi_channel!(PPI_CH18, 18, true, 1, 2); 247impl_ppi_channel!(PPI_CH18, 18 => configurable);
248impl_ppi_channel!(PPI_CH19, 19, true, 1, 2); 248impl_ppi_channel!(PPI_CH19, 19 => configurable);
249impl_ppi_channel!(PPI_CH20, 20, false, 0, 1); 249impl_ppi_channel!(PPI_CH20, 20 => static);
250impl_ppi_channel!(PPI_CH21, 21, false, 0, 1); 250impl_ppi_channel!(PPI_CH21, 21 => static);
251impl_ppi_channel!(PPI_CH22, 22, false, 0, 1); 251impl_ppi_channel!(PPI_CH22, 22 => static);
252impl_ppi_channel!(PPI_CH23, 23, false, 0, 1); 252impl_ppi_channel!(PPI_CH23, 23 => static);
253impl_ppi_channel!(PPI_CH24, 24, false, 0, 1); 253impl_ppi_channel!(PPI_CH24, 24 => static);
254impl_ppi_channel!(PPI_CH25, 25, false, 0, 1); 254impl_ppi_channel!(PPI_CH25, 25 => static);
255impl_ppi_channel!(PPI_CH26, 26, false, 0, 1); 255impl_ppi_channel!(PPI_CH26, 26 => static);
256impl_ppi_channel!(PPI_CH27, 27, false, 0, 1); 256impl_ppi_channel!(PPI_CH27, 27 => static);
257impl_ppi_channel!(PPI_CH28, 28, false, 0, 1); 257impl_ppi_channel!(PPI_CH28, 28 => static);
258impl_ppi_channel!(PPI_CH29, 29, false, 0, 1); 258impl_ppi_channel!(PPI_CH29, 29 => static);
259impl_ppi_channel!(PPI_CH30, 30, false, 0, 1); 259impl_ppi_channel!(PPI_CH30, 30 => static);
260impl_ppi_channel!(PPI_CH31, 31, false, 0, 1); 260impl_ppi_channel!(PPI_CH31, 31 => static);
261 261
262impl_saadc_input!(P0_02, ANALOGINPUT0); 262impl_saadc_input!(P0_02, ANALOGINPUT0);
263impl_saadc_input!(P0_03, ANALOGINPUT1); 263impl_saadc_input!(P0_03, ANALOGINPUT1);
diff --git a/embassy-nrf/src/chips/nrf52840.rs b/embassy-nrf/src/chips/nrf52840.rs
index 266328d58..f5b90cd5a 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);
231impl_pin!(P1_14, 1, 14); 231impl_pin!(P1_14, 1, 14);
232impl_pin!(P1_15, 1, 15); 232impl_pin!(P1_15, 1, 15);
233 233
234impl_ppi_channel!(PPI_CH0, 0, true, 1, 2); 234impl_ppi_channel!(PPI_CH0, 0 => configurable);
235impl_ppi_channel!(PPI_CH1, 1, true, 1, 2); 235impl_ppi_channel!(PPI_CH1, 1 => configurable);
236impl_ppi_channel!(PPI_CH2, 2, true, 1, 2); 236impl_ppi_channel!(PPI_CH2, 2 => configurable);
237impl_ppi_channel!(PPI_CH3, 3, true, 1, 2); 237impl_ppi_channel!(PPI_CH3, 3 => configurable);
238impl_ppi_channel!(PPI_CH4, 4, true, 1, 2); 238impl_ppi_channel!(PPI_CH4, 4 => configurable);
239impl_ppi_channel!(PPI_CH5, 5, true, 1, 2); 239impl_ppi_channel!(PPI_CH5, 5 => configurable);
240impl_ppi_channel!(PPI_CH6, 6, true, 1, 2); 240impl_ppi_channel!(PPI_CH6, 6 => configurable);
241impl_ppi_channel!(PPI_CH7, 7, true, 1, 2); 241impl_ppi_channel!(PPI_CH7, 7 => configurable);
242impl_ppi_channel!(PPI_CH8, 8, true, 1, 2); 242impl_ppi_channel!(PPI_CH8, 8 => configurable);
243impl_ppi_channel!(PPI_CH9, 9, true, 1, 2); 243impl_ppi_channel!(PPI_CH9, 9 => configurable);
244impl_ppi_channel!(PPI_CH10, 10, true, 1, 2); 244impl_ppi_channel!(PPI_CH10, 10 => configurable);
245impl_ppi_channel!(PPI_CH11, 11, true, 1, 2); 245impl_ppi_channel!(PPI_CH11, 11 => configurable);
246impl_ppi_channel!(PPI_CH12, 12, true, 1, 2); 246impl_ppi_channel!(PPI_CH12, 12 => configurable);
247impl_ppi_channel!(PPI_CH13, 13, true, 1, 2); 247impl_ppi_channel!(PPI_CH13, 13 => configurable);
248impl_ppi_channel!(PPI_CH14, 14, true, 1, 2); 248impl_ppi_channel!(PPI_CH14, 14 => configurable);
249impl_ppi_channel!(PPI_CH15, 15, true, 1, 2); 249impl_ppi_channel!(PPI_CH15, 15 => configurable);
250impl_ppi_channel!(PPI_CH16, 16, true, 1, 2); 250impl_ppi_channel!(PPI_CH16, 16 => configurable);
251impl_ppi_channel!(PPI_CH17, 17, true, 1, 2); 251impl_ppi_channel!(PPI_CH17, 17 => configurable);
252impl_ppi_channel!(PPI_CH18, 18, true, 1, 2); 252impl_ppi_channel!(PPI_CH18, 18 => configurable);
253impl_ppi_channel!(PPI_CH19, 19, true, 1, 2); 253impl_ppi_channel!(PPI_CH19, 19 => configurable);
254impl_ppi_channel!(PPI_CH20, 20, false, 0, 1); 254impl_ppi_channel!(PPI_CH20, 20 => static);
255impl_ppi_channel!(PPI_CH21, 21, false, 0, 1); 255impl_ppi_channel!(PPI_CH21, 21 => static);
256impl_ppi_channel!(PPI_CH22, 22, false, 0, 1); 256impl_ppi_channel!(PPI_CH22, 22 => static);
257impl_ppi_channel!(PPI_CH23, 23, false, 0, 1); 257impl_ppi_channel!(PPI_CH23, 23 => static);
258impl_ppi_channel!(PPI_CH24, 24, false, 0, 1); 258impl_ppi_channel!(PPI_CH24, 24 => static);
259impl_ppi_channel!(PPI_CH25, 25, false, 0, 1); 259impl_ppi_channel!(PPI_CH25, 25 => static);
260impl_ppi_channel!(PPI_CH26, 26, false, 0, 1); 260impl_ppi_channel!(PPI_CH26, 26 => static);
261impl_ppi_channel!(PPI_CH27, 27, false, 0, 1); 261impl_ppi_channel!(PPI_CH27, 27 => static);
262impl_ppi_channel!(PPI_CH28, 28, false, 0, 1); 262impl_ppi_channel!(PPI_CH28, 28 => static);
263impl_ppi_channel!(PPI_CH29, 29, false, 0, 1); 263impl_ppi_channel!(PPI_CH29, 29 => static);
264impl_ppi_channel!(PPI_CH30, 30, false, 0, 1); 264impl_ppi_channel!(PPI_CH30, 30 => static);
265impl_ppi_channel!(PPI_CH31, 31, false, 0, 1); 265impl_ppi_channel!(PPI_CH31, 31 => static);
266 266
267impl_saadc_input!(P0_02, ANALOGINPUT0); 267impl_saadc_input!(P0_02, ANALOGINPUT0);
268impl_saadc_input!(P0_03, ANALOGINPUT1); 268impl_saadc_input!(P0_03, ANALOGINPUT1);
diff --git a/embassy-nrf/src/chips/nrf9160.rs b/embassy-nrf/src/chips/nrf9160.rs
index 7357e9e22..6ca918104 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);
184impl_pin!(P0_30, 0, 30); 184impl_pin!(P0_30, 0, 30);
185impl_pin!(P0_31, 0, 31); 185impl_pin!(P0_31, 0, 31);
186 186
187impl_ppi_channel!(PPI_CH0, 0, true, many, many); 187impl_ppi_channel!(PPI_CH0, 0 => configurable);
188impl_ppi_channel!(PPI_CH1, 1, true, many, many); 188impl_ppi_channel!(PPI_CH1, 1 => configurable);
189impl_ppi_channel!(PPI_CH2, 2, true, many, many); 189impl_ppi_channel!(PPI_CH2, 2 => configurable);
190impl_ppi_channel!(PPI_CH3, 3, true, many, many); 190impl_ppi_channel!(PPI_CH3, 3 => configurable);
191impl_ppi_channel!(PPI_CH4, 4, true, many, many); 191impl_ppi_channel!(PPI_CH4, 4 => configurable);
192impl_ppi_channel!(PPI_CH5, 5, true, many, many); 192impl_ppi_channel!(PPI_CH5, 5 => configurable);
193impl_ppi_channel!(PPI_CH6, 6, true, many, many); 193impl_ppi_channel!(PPI_CH6, 6 => configurable);
194impl_ppi_channel!(PPI_CH7, 7, true, many, many); 194impl_ppi_channel!(PPI_CH7, 7 => configurable);
195impl_ppi_channel!(PPI_CH8, 8, true, many, many); 195impl_ppi_channel!(PPI_CH8, 8 => configurable);
196impl_ppi_channel!(PPI_CH9, 9, true, many, many); 196impl_ppi_channel!(PPI_CH9, 9 => configurable);
197impl_ppi_channel!(PPI_CH10, 10, true, many, many); 197impl_ppi_channel!(PPI_CH10, 10 => configurable);
198impl_ppi_channel!(PPI_CH11, 11, true, many, many); 198impl_ppi_channel!(PPI_CH11, 11 => configurable);
199impl_ppi_channel!(PPI_CH12, 12, true, many, many); 199impl_ppi_channel!(PPI_CH12, 12 => configurable);
200impl_ppi_channel!(PPI_CH13, 13, true, many, many); 200impl_ppi_channel!(PPI_CH13, 13 => configurable);
201impl_ppi_channel!(PPI_CH14, 14, true, many, many); 201impl_ppi_channel!(PPI_CH14, 14 => configurable);
202impl_ppi_channel!(PPI_CH15, 15, true, many, many); 202impl_ppi_channel!(PPI_CH15, 15 => configurable);
203 203
204impl_saadc_input!(P0_13, ANALOGINPUT0); 204impl_saadc_input!(P0_13, ANALOGINPUT0);
205impl_saadc_input!(P0_14, ANALOGINPUT1); 205impl_saadc_input!(P0_14, ANALOGINPUT1);
diff --git a/embassy-nrf/src/ppi/mod.rs b/embassy-nrf/src/ppi/mod.rs
index bfbc69b79..cea8a0e68 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
38impl<'d, C: Channel + 'd, const EVENT_COUNT: usize, const TASK_COUNT: usize> 38impl<'d, C: Channel + 'd, const EVENT_COUNT: usize, const TASK_COUNT: usize>
39 Ppi<'d, C, EVENT_COUNT, TASK_COUNT> 39 Ppi<'d, C, EVENT_COUNT, TASK_COUNT>
40{ 40{
41 pub fn degrade(self) -> Ppi<'d, AnyChannel, EVENT_COUNT, TASK_COUNT> {
42 Ppi {
43 ch: AnyChannel {
44 number: self.ch.number() as u8,
45 #[cfg(feature = "_ppi")]
46 has_configurable_task: self.ch.is_task_configurable(),
47 },
48 #[cfg(feature = "_dppi")]
49 events: self.events,
50 #[cfg(feature = "_dppi")]
51 tasks: self.tasks,
52 phantom: PhantomData,
53 }
54 }
55
56 /// Enables the channel. 41 /// Enables the channel.
57 pub fn enable(&mut self) { 42 pub fn enable(&mut self) {
58 let r = unsafe { &*pac::PPI::ptr() }; 43 let r = unsafe { &*pac::PPI::ptr() };
@@ -77,7 +62,8 @@ impl<'d, C: Channel, const EVENT_COUNT: usize, const TASK_COUNT: usize> Drop
77 } 62 }
78} 63}
79 64
80impl<'d, C: ZeroToOneChannel> Ppi<'d, C, 0, 1> { 65#[cfg(not(feature = "nrf51"))] // Not for nrf51 because of the fork task
66impl<'d, C: StaticChannel> Ppi<'d, C, 0, 1> {
81 pub fn new_zero_to_one(ch: impl Unborrow<Target = C> + 'd, task: Task) -> Self { 67 pub fn new_zero_to_one(ch: impl Unborrow<Target = C> + 'd, task: Task) -> Self {
82 unborrow!(ch); 68 unborrow!(ch);
83 69
@@ -97,7 +83,7 @@ impl<'d, C: ZeroToOneChannel> Ppi<'d, C, 0, 1> {
97 } 83 }
98} 84}
99 85
100impl<'d, C: OneToOneChannel> Ppi<'d, C, 1, 1> { 86impl<'d, C: ConfigurableChannel> Ppi<'d, C, 1, 1> {
101 pub fn new_one_to_one(ch: impl Unborrow<Target = C> + 'd, event: Event, task: Task) -> Self { 87 pub fn new_one_to_one(ch: impl Unborrow<Target = C> + 'd, event: Event, task: Task) -> Self {
102 unborrow!(ch); 88 unborrow!(ch);
103 89
@@ -117,7 +103,8 @@ impl<'d, C: OneToOneChannel> Ppi<'d, C, 1, 1> {
117 } 103 }
118} 104}
119 105
120impl<'d, C: OneToTwoChannel> Ppi<'d, C, 1, 2> { 106#[cfg(not(feature = "nrf51"))] // Not for nrf51 because of the fork task
107impl<'d, C: ConfigurableChannel> Ppi<'d, C, 1, 2> {
121 pub fn new_one_to_two( 108 pub fn new_one_to_two(
122 ch: impl Unborrow<Target = C> + 'd, 109 ch: impl Unborrow<Target = C> + 'd,
123 event: Event, 110 event: Event,
@@ -142,7 +129,8 @@ impl<'d, C: OneToTwoChannel> Ppi<'d, C, 1, 2> {
142 } 129 }
143} 130}
144 131
145impl<'d, C: ManyToManyChannel, const EVENT_COUNT: usize, const TASK_COUNT: usize> 132#[cfg(feature = "_dppi")]
133impl<'d, C: ConfigurableChannel, const EVENT_COUNT: usize, const TASK_COUNT: usize>
146 Ppi<'d, C, EVENT_COUNT, TASK_COUNT> 134 Ppi<'d, C, EVENT_COUNT, TASK_COUNT>
147{ 135{
148 pub fn new_many_to_many( 136 pub fn new_many_to_many(
@@ -221,72 +209,107 @@ pub(crate) mod sealed {
221pub trait Channel: sealed::Channel + Unborrow<Target = Self> + Sized { 209pub trait Channel: sealed::Channel + Unborrow<Target = Self> + Sized {
222 /// Returns the number of the channel 210 /// Returns the number of the channel
223 fn number(&self) -> usize; 211 fn number(&self) -> usize;
224 #[cfg(feature = "_ppi")] 212 fn configurable() -> bool;
225 fn is_task_configurable(&self) -> bool; 213}
214
215pub trait ConfigurableChannel: Channel {
216 fn degrade(self) -> AnyConfigurableChannel;
226} 217}
227 218
228pub trait ZeroToOneChannel: Channel {} 219pub trait StaticChannel: Channel {
229pub trait OneToOneChannel: ZeroToOneChannel {} 220 fn degrade(self) -> AnyStaticChannel;
230pub trait OneToTwoChannel: OneToOneChannel {} 221}
231pub trait ManyToManyChannel: OneToTwoChannel {}
232 222
233pub trait Group: sealed::Group + Sized { 223pub trait Group: sealed::Group + Sized {
234 fn number(&self) -> usize; 224 fn number(&self) -> usize;
225 fn degrade(self) -> AnyGroup {
226 AnyGroup {
227 number: self.number() as u8,
228 }
229 }
235} 230}
236 231
237// ====================== 232// ======================
238// channels 233// channels
239 234
240pub struct AnyChannel { 235/// The any channel can represent any static channel at runtime.
241 number: u8, 236/// This can be used to have fewer generic parameters in some places.
242 #[cfg(feature = "_ppi")] 237pub struct AnyStaticChannel {
243 has_configurable_task: bool, 238 pub(crate) number: u8,
239}
240unsafe_impl_unborrow!(AnyStaticChannel);
241impl sealed::Channel for AnyStaticChannel {}
242impl Channel for AnyStaticChannel {
243 fn number(&self) -> usize {
244 self.number as usize
245 }
246
247 fn configurable() -> bool {
248 false
249 }
250}
251impl StaticChannel for AnyStaticChannel {
252 fn degrade(self) -> AnyStaticChannel {
253 self
254 }
255}
256
257/// The any configurable channel can represent any configurable channel at runtime.
258/// This can be used to have fewer generic parameters in some places.
259pub struct AnyConfigurableChannel {
260 pub(crate) number: u8,
244} 261}
245unsafe_impl_unborrow!(AnyChannel); 262unsafe_impl_unborrow!(AnyConfigurableChannel);
246impl sealed::Channel for AnyChannel {} 263impl sealed::Channel for AnyConfigurableChannel {}
247impl Channel for AnyChannel { 264impl Channel for AnyConfigurableChannel {
248 fn number(&self) -> usize { 265 fn number(&self) -> usize {
249 self.number as usize 266 self.number as usize
250 } 267 }
251 268
252 #[cfg(feature = "_ppi")] 269 fn configurable() -> bool {
253 fn is_task_configurable(&self) -> bool { 270 true
254 self.has_configurable_task 271 }
272}
273impl ConfigurableChannel for AnyConfigurableChannel {
274 fn degrade(self) -> AnyConfigurableChannel {
275 self
255 } 276 }
256} 277}
257 278
258macro_rules! impl_ppi_channel { 279macro_rules! impl_ppi_channel {
259 ($type:ident, $number:expr, $has_configurable_task:expr) => { 280 ($type:ident, $number:expr, $configurability:expr) => {
260 impl crate::ppi::sealed::Channel for peripherals::$type {} 281 impl crate::ppi::sealed::Channel for peripherals::$type {}
261 impl crate::ppi::Channel for peripherals::$type { 282 impl crate::ppi::Channel for peripherals::$type {
262 fn number(&self) -> usize { 283 fn number(&self) -> usize {
263 $number 284 $number
264 } 285 }
265 286
266 #[cfg(feature = "_ppi")] 287 fn configurable() -> bool {
267 fn is_task_configurable(&self) -> bool { 288 $configurability
268 $has_configurable_task
269 } 289 }
270 } 290 }
271 }; 291 };
272 ($type:ident, $number:expr, $has_configurable_task:expr, 0, 0) => { 292 ($type:ident, $number:expr => static) => {
273 impl_ppi_channel!($type, $number, $has_configurable_task); 293 impl_ppi_channel!($type, $number, false);
274 }; 294 impl crate::ppi::StaticChannel for peripherals::$type {
275 ($type:ident, $number:expr, $has_configurable_task:expr, 0, 1) => { 295 fn degrade(self) -> crate::ppi::AnyStaticChannel {
276 impl_ppi_channel!($type, $number, $has_configurable_task, 0, 0); 296 use crate::ppi::Channel;
277 impl crate::ppi::ZeroToOneChannel for peripherals::$type {} 297 crate::ppi::AnyStaticChannel {
278 }; 298 number: self.number() as u8,
279 ($type:ident, $number:expr, $has_configurable_task:expr, 1, 1) => { 299 }
280 impl_ppi_channel!($type, $number, $has_configurable_task, 0, 1); 300 }
281 impl crate::ppi::OneToOneChannel for peripherals::$type {} 301 }
282 };
283 ($type:ident, $number:expr, $has_configurable_task:expr, 1, 2) => {
284 impl_ppi_channel!($type, $number, $has_configurable_task, 1, 1);
285 impl crate::ppi::OneToTwoChannel for peripherals::$type {}
286 }; 302 };
287 ($type:ident, $number:expr, $has_configurable_task:expr, many, many) => { 303 ($type:ident, $number:expr => configurable) => {
288 impl_ppi_channel!($type, $number, $has_configurable_task, 1, 2); 304 impl_ppi_channel!($type, $number, true);
289 impl crate::ppi::ManyToManyChannel for peripherals::$type {} 305 impl crate::ppi::ConfigurableChannel for peripherals::$type {
306 fn degrade(self) -> crate::ppi::AnyConfigurableChannel {
307 use crate::ppi::Channel;
308 crate::ppi::AnyConfigurableChannel {
309 number: self.number() as u8,
310 }
311 }
312 }
290 }; 313 };
291} 314}
292 315
diff --git a/embassy-nrf/src/ppi/ppi.rs b/embassy-nrf/src/ppi/ppi.rs
index 67d2086c3..0bcb3a791 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>
15 } 15 }
16 } 16 }
17 17
18 #[cfg(not(feature = "nrf51"))]
18 fn set_fork_task(task: Option<&Task>, channel: usize) { 19 fn set_fork_task(task: Option<&Task>, channel: usize) {
19 let r = unsafe { &*pac::PPI::ptr() }; 20 let r = unsafe { &*pac::PPI::ptr() };
20 if let Some(task) = task { 21 if let Some(task) = task {
@@ -40,16 +41,18 @@ impl<'d, C: Channel + 'd, const EVENT_COUNT: usize, const TASK_COUNT: usize>
40 /// Enables all tasks and events 41 /// Enables all tasks and events
41 pub(super) fn enable_all(tasks: &[Task], events: &[Event], channel: &C) { 42 pub(super) fn enable_all(tasks: &[Task], events: &[Event], channel: &C) {
42 // One configurable task, no fork 43 // One configurable task, no fork
43 if channel.is_task_configurable() && TASK_COUNT == 1 { 44 if C::configurable() && TASK_COUNT == 1 {
44 Self::set_main_task(Some(&tasks[0]), channel.number()); 45 Self::set_main_task(Some(&tasks[0]), channel.number());
45 } 46 }
46 47
47 // One configurable task, as fork 48 // One configurable task, as fork
48 if !channel.is_task_configurable() && TASK_COUNT == 1 { 49 #[cfg(not(feature = "nrf51"))]
50 if !C::configurable() && TASK_COUNT == 1 {
49 Self::set_fork_task(Some(&tasks[0]), channel.number()); 51 Self::set_fork_task(Some(&tasks[0]), channel.number());
50 } 52 }
51 53
52 // Two configurable tasks (main + fork) 54 // Two configurable tasks (main + fork)
55 #[cfg(not(feature = "nrf51"))]
53 if TASK_COUNT == 2 { 56 if TASK_COUNT == 2 {
54 Self::set_main_task(Some(&tasks[0]), channel.number()); 57 Self::set_main_task(Some(&tasks[0]), channel.number());
55 Self::set_fork_task(Some(&tasks[1]), channel.number()); 58 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>
62 65
63 /// Disable all tasks and events 66 /// Disable all tasks and events
64 pub(super) fn disable_all(&self) { 67 pub(super) fn disable_all(&self) {
65 if self.ch.is_task_configurable() { 68 if C::configurable() {
66 Self::set_main_task(None, self.ch.number()); 69 Self::set_main_task(None, self.ch.number());
67 } 70 }
68 71
69 if TASK_COUNT == 1 && !self.ch.is_task_configurable() || TASK_COUNT == 2 { 72 #[cfg(not(feature = "nrf51"))]
73 if TASK_COUNT == 1 && !C::configurable() || TASK_COUNT == 2 {
70 Self::set_fork_task(None, self.ch.number()); 74 Self::set_fork_task(None, self.ch.number());
71 } 75 }
72 76
diff --git a/embassy-nrf/src/uarte.rs b/embassy-nrf/src/uarte.rs
index 36cf65d89..4bbdec63f 100644
--- a/embassy-nrf/src/uarte.rs
+++ b/embassy-nrf/src/uarte.rs
@@ -18,7 +18,7 @@ use crate::gpio::sealed::Pin as _;
18use crate::gpio::{self, OptionalPin as GpioOptionalPin, Pin as GpioPin}; 18use crate::gpio::{self, OptionalPin as GpioOptionalPin, Pin as GpioPin};
19use crate::interrupt::Interrupt; 19use crate::interrupt::Interrupt;
20use crate::pac; 20use crate::pac;
21use crate::ppi::{AnyChannel, Event, OneToOneChannel, OneToTwoChannel, Ppi, Task}; 21use crate::ppi::{AnyConfigurableChannel, ConfigurableChannel, Event, Ppi, Task};
22use crate::timer::Instance as TimerInstance; 22use crate::timer::Instance as TimerInstance;
23use crate::timer::{Frequency, Timer}; 23use crate::timer::{Frequency, Timer};
24 24
@@ -331,8 +331,8 @@ impl<'d, T: Instance> Write for Uarte<'d, T> {
331pub struct UarteWithIdle<'d, U: Instance, T: TimerInstance> { 331pub struct UarteWithIdle<'d, U: Instance, T: TimerInstance> {
332 uarte: Uarte<'d, U>, 332 uarte: Uarte<'d, U>,
333 timer: Timer<'d, T>, 333 timer: Timer<'d, T>,
334 ppi_ch1: Ppi<'d, AnyChannel, 1, 2>, 334 ppi_ch1: Ppi<'d, AnyConfigurableChannel, 1, 2>,
335 _ppi_ch2: Ppi<'d, AnyChannel, 1, 1>, 335 _ppi_ch2: Ppi<'d, AnyConfigurableChannel, 1, 1>,
336} 336}
337 337
338impl<'d, U: Instance, T: TimerInstance> UarteWithIdle<'d, U, T> { 338impl<'d, U: Instance, T: TimerInstance> UarteWithIdle<'d, U, T> {
@@ -348,8 +348,8 @@ impl<'d, U: Instance, T: TimerInstance> UarteWithIdle<'d, U, T> {
348 pub unsafe fn new( 348 pub unsafe fn new(
349 uarte: impl Unborrow<Target = U> + 'd, 349 uarte: impl Unborrow<Target = U> + 'd,
350 timer: impl Unborrow<Target = T> + 'd, 350 timer: impl Unborrow<Target = T> + 'd,
351 ppi_ch1: impl Unborrow<Target = impl OneToTwoChannel + 'd> + 'd, 351 ppi_ch1: impl Unborrow<Target = impl ConfigurableChannel + 'd> + 'd,
352 ppi_ch2: impl Unborrow<Target = impl OneToOneChannel + 'd> + 'd, 352 ppi_ch2: impl Unborrow<Target = impl ConfigurableChannel + 'd> + 'd,
353 irq: impl Unborrow<Target = U::Interrupt> + 'd, 353 irq: impl Unborrow<Target = U::Interrupt> + 'd,
354 rxd: impl Unborrow<Target = impl GpioPin> + 'd, 354 rxd: impl Unborrow<Target = impl GpioPin> + 'd,
355 txd: impl Unborrow<Target = impl GpioPin> + 'd, 355 txd: impl Unborrow<Target = impl GpioPin> + 'd,
@@ -379,20 +379,18 @@ impl<'d, U: Instance, T: TimerInstance> UarteWithIdle<'d, U, T> {
379 timer.cc(0).short_compare_stop(); 379 timer.cc(0).short_compare_stop();
380 380
381 let mut ppi_ch1 = Ppi::new_one_to_two( 381 let mut ppi_ch1 = Ppi::new_one_to_two(
382 ppi_ch1, 382 ppi_ch1.degrade(),
383 Event::from_reg(&r.events_rxdrdy), 383 Event::from_reg(&r.events_rxdrdy),
384 timer.task_clear(), 384 timer.task_clear(),
385 timer.task_start(), 385 timer.task_start(),
386 ) 386 );
387 .degrade();
388 ppi_ch1.enable(); 387 ppi_ch1.enable();
389 388
390 let mut ppi_ch2 = Ppi::new_one_to_one( 389 let mut ppi_ch2 = Ppi::new_one_to_one(
391 ppi_ch2, 390 ppi_ch2.degrade(),
392 timer.cc(0).event_compare(), 391 timer.cc(0).event_compare(),
393 Task::from_reg(&r.tasks_stoprx), 392 Task::from_reg(&r.tasks_stoprx),
394 ) 393 );
395 .degrade();
396 ppi_ch2.enable(); 394 ppi_ch2.enable();
397 395
398 Self { 396 Self {