Fewer channel traits, more cfg to make the system work
This commit is contained in:
parent
4d3341dbb9
commit
c63d747209
12 changed files with 335 additions and 312 deletions
|
@ -15,7 +15,7 @@ use embassy_hal_common::{low_power_wait_until, unborrow};
|
||||||
use crate::gpio::sealed::Pin as _;
|
use crate::gpio::sealed::Pin as _;
|
||||||
use crate::gpio::{OptionalPin as GpioOptionalPin, Pin as GpioPin};
|
use crate::gpio::{OptionalPin as GpioOptionalPin, Pin as GpioPin};
|
||||||
use crate::pac;
|
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::Instance as TimerInstance;
|
||||||
use crate::timer::{Frequency, Timer};
|
use crate::timer::{Frequency, Timer};
|
||||||
use crate::uarte::{Config, Instance as UarteInstance};
|
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> {
|
struct StateInner<'d, U: UarteInstance, T: TimerInstance> {
|
||||||
phantom: PhantomData<&'d mut U>,
|
phantom: PhantomData<&'d mut U>,
|
||||||
timer: Timer<'d, T>,
|
timer: Timer<'d, T>,
|
||||||
_ppi_ch1: Ppi<'d, AnyChannel, 1, 2>,
|
_ppi_ch1: Ppi<'d, AnyConfigurableChannel, 1, 2>,
|
||||||
_ppi_ch2: Ppi<'d, AnyChannel, 1, 1>,
|
_ppi_ch2: Ppi<'d, AnyConfigurableChannel, 1, 1>,
|
||||||
|
|
||||||
rx: RingBuffer<'d>,
|
rx: RingBuffer<'d>,
|
||||||
rx_state: RxState,
|
rx_state: RxState,
|
||||||
|
@ -70,8 +70,8 @@ impl<'d, U: UarteInstance, T: TimerInstance> BufferedUarte<'d, U, T> {
|
||||||
state: &'d mut State<'d, U, T>,
|
state: &'d mut State<'d, U, T>,
|
||||||
_uarte: impl Unborrow<Target = U> + 'd,
|
_uarte: impl Unborrow<Target = U> + 'd,
|
||||||
timer: impl Unborrow<Target = T> + 'd,
|
timer: impl Unborrow<Target = T> + 'd,
|
||||||
ppi_ch1: impl Unborrow<Target = impl OneToTwoChannel + 'd> + 'd,
|
ppi_ch1: impl Unborrow<Target = impl ConfigurableChannel + 'd> + 'd,
|
||||||
ppi_ch2: impl Unborrow<Target = impl OneToOneChannel + 'd> + 'd,
|
ppi_ch2: impl Unborrow<Target = impl ConfigurableChannel + 'd> + 'd,
|
||||||
irq: impl Unborrow<Target = U::Interrupt> + 'd,
|
irq: impl Unborrow<Target = U::Interrupt> + 'd,
|
||||||
rxd: impl Unborrow<Target = impl GpioPin> + 'd,
|
rxd: impl Unborrow<Target = impl GpioPin> + 'd,
|
||||||
txd: impl Unborrow<Target = impl GpioPin> + 'd,
|
txd: impl Unborrow<Target = impl GpioPin> + 'd,
|
||||||
|
@ -145,20 +145,18 @@ impl<'d, U: UarteInstance, T: TimerInstance> BufferedUarte<'d, U, T> {
|
||||||
timer.cc(0).short_compare_stop();
|
timer.cc(0).short_compare_stop();
|
||||||
|
|
||||||
let mut ppi_ch1 = Ppi::new_one_to_two(
|
let mut ppi_ch1 = Ppi::new_one_to_two(
|
||||||
ppi_ch1,
|
ppi_ch1.degrade(),
|
||||||
Event::from_reg(&r.events_rxdrdy),
|
Event::from_reg(&r.events_rxdrdy),
|
||||||
timer.task_clear(),
|
timer.task_clear(),
|
||||||
timer.task_start(),
|
timer.task_start(),
|
||||||
)
|
);
|
||||||
.degrade();
|
|
||||||
ppi_ch1.enable();
|
ppi_ch1.enable();
|
||||||
|
|
||||||
let mut ppi_ch2 = Ppi::new_one_to_one(
|
let mut ppi_ch2 = Ppi::new_one_to_one(
|
||||||
ppi_ch2,
|
ppi_ch2.degrade(),
|
||||||
timer.cc(0).event_compare(),
|
timer.cc(0).event_compare(),
|
||||||
Task::from_reg(&r.tasks_stoprx),
|
Task::from_reg(&r.tasks_stoprx),
|
||||||
)
|
);
|
||||||
.degrade();
|
|
||||||
ppi_ch2.enable();
|
ppi_ch2.enable();
|
||||||
|
|
||||||
Self {
|
Self {
|
||||||
|
|
|
@ -167,28 +167,28 @@ impl_pin!(P0_29, 0, 29);
|
||||||
impl_pin!(P0_30, 0, 30);
|
impl_pin!(P0_30, 0, 30);
|
||||||
impl_pin!(P0_31, 0, 31);
|
impl_pin!(P0_31, 0, 31);
|
||||||
|
|
||||||
impl_ppi_channel!(PPI_CH0, 0, true, 1, 2);
|
impl_ppi_channel!(PPI_CH0, 0 => configurable);
|
||||||
impl_ppi_channel!(PPI_CH1, 1, true, 1, 2);
|
impl_ppi_channel!(PPI_CH1, 1 => configurable);
|
||||||
impl_ppi_channel!(PPI_CH2, 2, true, 1, 2);
|
impl_ppi_channel!(PPI_CH2, 2 => configurable);
|
||||||
impl_ppi_channel!(PPI_CH3, 3, true, 1, 2);
|
impl_ppi_channel!(PPI_CH3, 3 => configurable);
|
||||||
impl_ppi_channel!(PPI_CH4, 4, true, 1, 2);
|
impl_ppi_channel!(PPI_CH4, 4 => configurable);
|
||||||
impl_ppi_channel!(PPI_CH5, 5, true, 1, 2);
|
impl_ppi_channel!(PPI_CH5, 5 => configurable);
|
||||||
impl_ppi_channel!(PPI_CH6, 6, true, 1, 2);
|
impl_ppi_channel!(PPI_CH6, 6 => configurable);
|
||||||
impl_ppi_channel!(PPI_CH7, 7, true, 1, 2);
|
impl_ppi_channel!(PPI_CH7, 7 => configurable);
|
||||||
impl_ppi_channel!(PPI_CH8, 8, true, 1, 2);
|
impl_ppi_channel!(PPI_CH8, 8 => configurable);
|
||||||
impl_ppi_channel!(PPI_CH9, 9, true, 1, 2);
|
impl_ppi_channel!(PPI_CH9, 9 => configurable);
|
||||||
impl_ppi_channel!(PPI_CH20, 20, false, 0, 1);
|
impl_ppi_channel!(PPI_CH20, 20 => static);
|
||||||
impl_ppi_channel!(PPI_CH21, 21, false, 0, 1);
|
impl_ppi_channel!(PPI_CH21, 21 => static);
|
||||||
impl_ppi_channel!(PPI_CH22, 22, false, 0, 1);
|
impl_ppi_channel!(PPI_CH22, 22 => static);
|
||||||
impl_ppi_channel!(PPI_CH23, 23, false, 0, 1);
|
impl_ppi_channel!(PPI_CH23, 23 => static);
|
||||||
impl_ppi_channel!(PPI_CH24, 24, false, 0, 1);
|
impl_ppi_channel!(PPI_CH24, 24 => static);
|
||||||
impl_ppi_channel!(PPI_CH25, 25, false, 0, 1);
|
impl_ppi_channel!(PPI_CH25, 25 => static);
|
||||||
impl_ppi_channel!(PPI_CH26, 26, false, 0, 1);
|
impl_ppi_channel!(PPI_CH26, 26 => static);
|
||||||
impl_ppi_channel!(PPI_CH27, 27, false, 0, 1);
|
impl_ppi_channel!(PPI_CH27, 27 => static);
|
||||||
impl_ppi_channel!(PPI_CH28, 28, false, 0, 1);
|
impl_ppi_channel!(PPI_CH28, 28 => static);
|
||||||
impl_ppi_channel!(PPI_CH29, 29, false, 0, 1);
|
impl_ppi_channel!(PPI_CH29, 29 => static);
|
||||||
impl_ppi_channel!(PPI_CH30, 30, false, 0, 1);
|
impl_ppi_channel!(PPI_CH30, 30 => static);
|
||||||
impl_ppi_channel!(PPI_CH31, 31, false, 0, 1);
|
impl_ppi_channel!(PPI_CH31, 31 => static);
|
||||||
|
|
||||||
impl_saadc_input!(P0_04, ANALOGINPUT2);
|
impl_saadc_input!(P0_04, ANALOGINPUT2);
|
||||||
impl_saadc_input!(P0_05, ANALOGINPUT3);
|
impl_saadc_input!(P0_05, ANALOGINPUT3);
|
||||||
|
|
|
@ -172,38 +172,38 @@ impl_pin!(P0_29, 0, 29);
|
||||||
impl_pin!(P0_30, 0, 30);
|
impl_pin!(P0_30, 0, 30);
|
||||||
impl_pin!(P0_31, 0, 31);
|
impl_pin!(P0_31, 0, 31);
|
||||||
|
|
||||||
impl_ppi_channel!(PPI_CH0, 0, true, 1, 2);
|
impl_ppi_channel!(PPI_CH0, 0 => configurable);
|
||||||
impl_ppi_channel!(PPI_CH1, 1, true, 1, 2);
|
impl_ppi_channel!(PPI_CH1, 1 => configurable);
|
||||||
impl_ppi_channel!(PPI_CH2, 2, true, 1, 2);
|
impl_ppi_channel!(PPI_CH2, 2 => configurable);
|
||||||
impl_ppi_channel!(PPI_CH3, 3, true, 1, 2);
|
impl_ppi_channel!(PPI_CH3, 3 => configurable);
|
||||||
impl_ppi_channel!(PPI_CH4, 4, true, 1, 2);
|
impl_ppi_channel!(PPI_CH4, 4 => configurable);
|
||||||
impl_ppi_channel!(PPI_CH5, 5, true, 1, 2);
|
impl_ppi_channel!(PPI_CH5, 5 => configurable);
|
||||||
impl_ppi_channel!(PPI_CH6, 6, true, 1, 2);
|
impl_ppi_channel!(PPI_CH6, 6 => configurable);
|
||||||
impl_ppi_channel!(PPI_CH7, 7, true, 1, 2);
|
impl_ppi_channel!(PPI_CH7, 7 => configurable);
|
||||||
impl_ppi_channel!(PPI_CH8, 8, true, 1, 2);
|
impl_ppi_channel!(PPI_CH8, 8 => configurable);
|
||||||
impl_ppi_channel!(PPI_CH9, 9, true, 1, 2);
|
impl_ppi_channel!(PPI_CH9, 9 => configurable);
|
||||||
impl_ppi_channel!(PPI_CH10, 10, true, 1, 2);
|
impl_ppi_channel!(PPI_CH10, 10 => configurable);
|
||||||
impl_ppi_channel!(PPI_CH11, 11, true, 1, 2);
|
impl_ppi_channel!(PPI_CH11, 11 => configurable);
|
||||||
impl_ppi_channel!(PPI_CH12, 12, true, 1, 2);
|
impl_ppi_channel!(PPI_CH12, 12 => configurable);
|
||||||
impl_ppi_channel!(PPI_CH13, 13, true, 1, 2);
|
impl_ppi_channel!(PPI_CH13, 13 => configurable);
|
||||||
impl_ppi_channel!(PPI_CH14, 14, true, 1, 2);
|
impl_ppi_channel!(PPI_CH14, 14 => configurable);
|
||||||
impl_ppi_channel!(PPI_CH15, 15, true, 1, 2);
|
impl_ppi_channel!(PPI_CH15, 15 => configurable);
|
||||||
impl_ppi_channel!(PPI_CH16, 16, true, 1, 2);
|
impl_ppi_channel!(PPI_CH16, 16 => configurable);
|
||||||
impl_ppi_channel!(PPI_CH17, 17, true, 1, 2);
|
impl_ppi_channel!(PPI_CH17, 17 => configurable);
|
||||||
impl_ppi_channel!(PPI_CH18, 18, true, 1, 2);
|
impl_ppi_channel!(PPI_CH18, 18 => configurable);
|
||||||
impl_ppi_channel!(PPI_CH19, 19, true, 1, 2);
|
impl_ppi_channel!(PPI_CH19, 19 => configurable);
|
||||||
impl_ppi_channel!(PPI_CH20, 20, false, 0, 1);
|
impl_ppi_channel!(PPI_CH20, 20 => static);
|
||||||
impl_ppi_channel!(PPI_CH21, 21, false, 0, 1);
|
impl_ppi_channel!(PPI_CH21, 21 => static);
|
||||||
impl_ppi_channel!(PPI_CH22, 22, false, 0, 1);
|
impl_ppi_channel!(PPI_CH22, 22 => static);
|
||||||
impl_ppi_channel!(PPI_CH23, 23, false, 0, 1);
|
impl_ppi_channel!(PPI_CH23, 23 => static);
|
||||||
impl_ppi_channel!(PPI_CH24, 24, false, 0, 1);
|
impl_ppi_channel!(PPI_CH24, 24 => static);
|
||||||
impl_ppi_channel!(PPI_CH25, 25, false, 0, 1);
|
impl_ppi_channel!(PPI_CH25, 25 => static);
|
||||||
impl_ppi_channel!(PPI_CH26, 26, false, 0, 1);
|
impl_ppi_channel!(PPI_CH26, 26 => static);
|
||||||
impl_ppi_channel!(PPI_CH27, 27, false, 0, 1);
|
impl_ppi_channel!(PPI_CH27, 27 => static);
|
||||||
impl_ppi_channel!(PPI_CH28, 28, false, 0, 1);
|
impl_ppi_channel!(PPI_CH28, 28 => static);
|
||||||
impl_ppi_channel!(PPI_CH29, 29, false, 0, 1);
|
impl_ppi_channel!(PPI_CH29, 29 => static);
|
||||||
impl_ppi_channel!(PPI_CH30, 30, false, 0, 1);
|
impl_ppi_channel!(PPI_CH30, 30 => static);
|
||||||
impl_ppi_channel!(PPI_CH31, 31, false, 0, 1);
|
impl_ppi_channel!(PPI_CH31, 31 => static);
|
||||||
|
|
||||||
impl_saadc_input!(P0_02, ANALOGINPUT0);
|
impl_saadc_input!(P0_02, ANALOGINPUT0);
|
||||||
impl_saadc_input!(P0_03, ANALOGINPUT1);
|
impl_saadc_input!(P0_03, ANALOGINPUT1);
|
||||||
|
|
|
@ -173,38 +173,38 @@ impl_pin!(P0_29, 0, 29);
|
||||||
impl_pin!(P0_30, 0, 30);
|
impl_pin!(P0_30, 0, 30);
|
||||||
impl_pin!(P0_31, 0, 31);
|
impl_pin!(P0_31, 0, 31);
|
||||||
|
|
||||||
impl_ppi_channel!(PPI_CH0, 0, true, 1, 2);
|
impl_ppi_channel!(PPI_CH0, 0 => configurable);
|
||||||
impl_ppi_channel!(PPI_CH1, 1, true, 1, 2);
|
impl_ppi_channel!(PPI_CH1, 1 => configurable);
|
||||||
impl_ppi_channel!(PPI_CH2, 2, true, 1, 2);
|
impl_ppi_channel!(PPI_CH2, 2 => configurable);
|
||||||
impl_ppi_channel!(PPI_CH3, 3, true, 1, 2);
|
impl_ppi_channel!(PPI_CH3, 3 => configurable);
|
||||||
impl_ppi_channel!(PPI_CH4, 4, true, 1, 2);
|
impl_ppi_channel!(PPI_CH4, 4 => configurable);
|
||||||
impl_ppi_channel!(PPI_CH5, 5, true, 1, 2);
|
impl_ppi_channel!(PPI_CH5, 5 => configurable);
|
||||||
impl_ppi_channel!(PPI_CH6, 6, true, 1, 2);
|
impl_ppi_channel!(PPI_CH6, 6 => configurable);
|
||||||
impl_ppi_channel!(PPI_CH7, 7, true, 1, 2);
|
impl_ppi_channel!(PPI_CH7, 7 => configurable);
|
||||||
impl_ppi_channel!(PPI_CH8, 8, true, 1, 2);
|
impl_ppi_channel!(PPI_CH8, 8 => configurable);
|
||||||
impl_ppi_channel!(PPI_CH9, 9, true, 1, 2);
|
impl_ppi_channel!(PPI_CH9, 9 => configurable);
|
||||||
impl_ppi_channel!(PPI_CH10, 10, true, 1, 2);
|
impl_ppi_channel!(PPI_CH10, 10 => configurable);
|
||||||
impl_ppi_channel!(PPI_CH11, 11, true, 1, 2);
|
impl_ppi_channel!(PPI_CH11, 11 => configurable);
|
||||||
impl_ppi_channel!(PPI_CH12, 12, true, 1, 2);
|
impl_ppi_channel!(PPI_CH12, 12 => configurable);
|
||||||
impl_ppi_channel!(PPI_CH13, 13, true, 1, 2);
|
impl_ppi_channel!(PPI_CH13, 13 => configurable);
|
||||||
impl_ppi_channel!(PPI_CH14, 14, true, 1, 2);
|
impl_ppi_channel!(PPI_CH14, 14 => configurable);
|
||||||
impl_ppi_channel!(PPI_CH15, 15, true, 1, 2);
|
impl_ppi_channel!(PPI_CH15, 15 => configurable);
|
||||||
impl_ppi_channel!(PPI_CH16, 16, true, 1, 2);
|
impl_ppi_channel!(PPI_CH16, 16 => configurable);
|
||||||
impl_ppi_channel!(PPI_CH17, 17, true, 1, 2);
|
impl_ppi_channel!(PPI_CH17, 17 => configurable);
|
||||||
impl_ppi_channel!(PPI_CH18, 18, true, 1, 2);
|
impl_ppi_channel!(PPI_CH18, 18 => configurable);
|
||||||
impl_ppi_channel!(PPI_CH19, 19, true, 1, 2);
|
impl_ppi_channel!(PPI_CH19, 19 => configurable);
|
||||||
impl_ppi_channel!(PPI_CH20, 20, false, 0, 1);
|
impl_ppi_channel!(PPI_CH20, 20 => static);
|
||||||
impl_ppi_channel!(PPI_CH21, 21, false, 0, 1);
|
impl_ppi_channel!(PPI_CH21, 21 => static);
|
||||||
impl_ppi_channel!(PPI_CH22, 22, false, 0, 1);
|
impl_ppi_channel!(PPI_CH22, 22 => static);
|
||||||
impl_ppi_channel!(PPI_CH23, 23, false, 0, 1);
|
impl_ppi_channel!(PPI_CH23, 23 => static);
|
||||||
impl_ppi_channel!(PPI_CH24, 24, false, 0, 1);
|
impl_ppi_channel!(PPI_CH24, 24 => static);
|
||||||
impl_ppi_channel!(PPI_CH25, 25, false, 0, 1);
|
impl_ppi_channel!(PPI_CH25, 25 => static);
|
||||||
impl_ppi_channel!(PPI_CH26, 26, false, 0, 1);
|
impl_ppi_channel!(PPI_CH26, 26 => static);
|
||||||
impl_ppi_channel!(PPI_CH27, 27, false, 0, 1);
|
impl_ppi_channel!(PPI_CH27, 27 => static);
|
||||||
impl_ppi_channel!(PPI_CH28, 28, false, 0, 1);
|
impl_ppi_channel!(PPI_CH28, 28 => static);
|
||||||
impl_ppi_channel!(PPI_CH29, 29, false, 0, 1);
|
impl_ppi_channel!(PPI_CH29, 29 => static);
|
||||||
impl_ppi_channel!(PPI_CH30, 30, false, 0, 1);
|
impl_ppi_channel!(PPI_CH30, 30 => static);
|
||||||
impl_ppi_channel!(PPI_CH31, 31, false, 0, 1);
|
impl_ppi_channel!(PPI_CH31, 31 => static);
|
||||||
|
|
||||||
impl_saadc_input!(P0_02, ANALOGINPUT0);
|
impl_saadc_input!(P0_02, ANALOGINPUT0);
|
||||||
impl_saadc_input!(P0_03, ANALOGINPUT1);
|
impl_saadc_input!(P0_03, ANALOGINPUT1);
|
||||||
|
|
|
@ -168,38 +168,38 @@ impl_pin!(P0_29, 0, 29);
|
||||||
impl_pin!(P0_30, 0, 30);
|
impl_pin!(P0_30, 0, 30);
|
||||||
impl_pin!(P0_31, 0, 31);
|
impl_pin!(P0_31, 0, 31);
|
||||||
|
|
||||||
impl_ppi_channel!(PPI_CH0, 0, true, 1, 2);
|
impl_ppi_channel!(PPI_CH0, 0 => configurable);
|
||||||
impl_ppi_channel!(PPI_CH1, 1, true, 1, 2);
|
impl_ppi_channel!(PPI_CH1, 1 => configurable);
|
||||||
impl_ppi_channel!(PPI_CH2, 2, true, 1, 2);
|
impl_ppi_channel!(PPI_CH2, 2 => configurable);
|
||||||
impl_ppi_channel!(PPI_CH3, 3, true, 1, 2);
|
impl_ppi_channel!(PPI_CH3, 3 => configurable);
|
||||||
impl_ppi_channel!(PPI_CH4, 4, true, 1, 2);
|
impl_ppi_channel!(PPI_CH4, 4 => configurable);
|
||||||
impl_ppi_channel!(PPI_CH5, 5, true, 1, 2);
|
impl_ppi_channel!(PPI_CH5, 5 => configurable);
|
||||||
impl_ppi_channel!(PPI_CH6, 6, true, 1, 2);
|
impl_ppi_channel!(PPI_CH6, 6 => configurable);
|
||||||
impl_ppi_channel!(PPI_CH7, 7, true, 1, 2);
|
impl_ppi_channel!(PPI_CH7, 7 => configurable);
|
||||||
impl_ppi_channel!(PPI_CH8, 8, true, 1, 2);
|
impl_ppi_channel!(PPI_CH8, 8 => configurable);
|
||||||
impl_ppi_channel!(PPI_CH9, 9, true, 1, 2);
|
impl_ppi_channel!(PPI_CH9, 9 => configurable);
|
||||||
impl_ppi_channel!(PPI_CH10, 10, true, 1, 2);
|
impl_ppi_channel!(PPI_CH10, 10 => configurable);
|
||||||
impl_ppi_channel!(PPI_CH11, 11, true, 1, 2);
|
impl_ppi_channel!(PPI_CH11, 11 => configurable);
|
||||||
impl_ppi_channel!(PPI_CH12, 12, true, 1, 2);
|
impl_ppi_channel!(PPI_CH12, 12 => configurable);
|
||||||
impl_ppi_channel!(PPI_CH13, 13, true, 1, 2);
|
impl_ppi_channel!(PPI_CH13, 13 => configurable);
|
||||||
impl_ppi_channel!(PPI_CH14, 14, true, 1, 2);
|
impl_ppi_channel!(PPI_CH14, 14 => configurable);
|
||||||
impl_ppi_channel!(PPI_CH15, 15, true, 1, 2);
|
impl_ppi_channel!(PPI_CH15, 15 => configurable);
|
||||||
impl_ppi_channel!(PPI_CH16, 16, true, 1, 2);
|
impl_ppi_channel!(PPI_CH16, 16 => configurable);
|
||||||
impl_ppi_channel!(PPI_CH17, 17, true, 1, 2);
|
impl_ppi_channel!(PPI_CH17, 17 => configurable);
|
||||||
impl_ppi_channel!(PPI_CH18, 18, true, 1, 2);
|
impl_ppi_channel!(PPI_CH18, 18 => configurable);
|
||||||
impl_ppi_channel!(PPI_CH19, 19, true, 1, 2);
|
impl_ppi_channel!(PPI_CH19, 19 => configurable);
|
||||||
impl_ppi_channel!(PPI_CH20, 20, false, 0, 1);
|
impl_ppi_channel!(PPI_CH20, 20 => static);
|
||||||
impl_ppi_channel!(PPI_CH21, 21, false, 0, 1);
|
impl_ppi_channel!(PPI_CH21, 21 => static);
|
||||||
impl_ppi_channel!(PPI_CH22, 22, false, 0, 1);
|
impl_ppi_channel!(PPI_CH22, 22 => static);
|
||||||
impl_ppi_channel!(PPI_CH23, 23, false, 0, 1);
|
impl_ppi_channel!(PPI_CH23, 23 => static);
|
||||||
impl_ppi_channel!(PPI_CH24, 24, false, 0, 1);
|
impl_ppi_channel!(PPI_CH24, 24 => static);
|
||||||
impl_ppi_channel!(PPI_CH25, 25, false, 0, 1);
|
impl_ppi_channel!(PPI_CH25, 25 => static);
|
||||||
impl_ppi_channel!(PPI_CH26, 26, false, 0, 1);
|
impl_ppi_channel!(PPI_CH26, 26 => static);
|
||||||
impl_ppi_channel!(PPI_CH27, 27, false, 0, 1);
|
impl_ppi_channel!(PPI_CH27, 27 => static);
|
||||||
impl_ppi_channel!(PPI_CH28, 28, false, 0, 1);
|
impl_ppi_channel!(PPI_CH28, 28 => static);
|
||||||
impl_ppi_channel!(PPI_CH29, 29, false, 0, 1);
|
impl_ppi_channel!(PPI_CH29, 29 => static);
|
||||||
impl_ppi_channel!(PPI_CH30, 30, false, 0, 1);
|
impl_ppi_channel!(PPI_CH30, 30 => static);
|
||||||
impl_ppi_channel!(PPI_CH31, 31, false, 0, 1);
|
impl_ppi_channel!(PPI_CH31, 31 => static);
|
||||||
|
|
||||||
pub mod irqs {
|
pub mod irqs {
|
||||||
use crate::pac::Interrupt as InterruptEnum;
|
use crate::pac::Interrupt as InterruptEnum;
|
||||||
|
|
|
@ -190,38 +190,38 @@ impl_pin!(P0_29, 0, 29);
|
||||||
impl_pin!(P0_30, 0, 30);
|
impl_pin!(P0_30, 0, 30);
|
||||||
impl_pin!(P0_31, 0, 31);
|
impl_pin!(P0_31, 0, 31);
|
||||||
|
|
||||||
impl_ppi_channel!(PPI_CH0, 0, true, 1, 2);
|
impl_ppi_channel!(PPI_CH0, 0 => configurable);
|
||||||
impl_ppi_channel!(PPI_CH1, 1, true, 1, 2);
|
impl_ppi_channel!(PPI_CH1, 1 => configurable);
|
||||||
impl_ppi_channel!(PPI_CH2, 2, true, 1, 2);
|
impl_ppi_channel!(PPI_CH2, 2 => configurable);
|
||||||
impl_ppi_channel!(PPI_CH3, 3, true, 1, 2);
|
impl_ppi_channel!(PPI_CH3, 3 => configurable);
|
||||||
impl_ppi_channel!(PPI_CH4, 4, true, 1, 2);
|
impl_ppi_channel!(PPI_CH4, 4 => configurable);
|
||||||
impl_ppi_channel!(PPI_CH5, 5, true, 1, 2);
|
impl_ppi_channel!(PPI_CH5, 5 => configurable);
|
||||||
impl_ppi_channel!(PPI_CH6, 6, true, 1, 2);
|
impl_ppi_channel!(PPI_CH6, 6 => configurable);
|
||||||
impl_ppi_channel!(PPI_CH7, 7, true, 1, 2);
|
impl_ppi_channel!(PPI_CH7, 7 => configurable);
|
||||||
impl_ppi_channel!(PPI_CH8, 8, true, 1, 2);
|
impl_ppi_channel!(PPI_CH8, 8 => configurable);
|
||||||
impl_ppi_channel!(PPI_CH9, 9, true, 1, 2);
|
impl_ppi_channel!(PPI_CH9, 9 => configurable);
|
||||||
impl_ppi_channel!(PPI_CH10, 10, true, 1, 2);
|
impl_ppi_channel!(PPI_CH10, 10 => configurable);
|
||||||
impl_ppi_channel!(PPI_CH11, 11, true, 1, 2);
|
impl_ppi_channel!(PPI_CH11, 11 => configurable);
|
||||||
impl_ppi_channel!(PPI_CH12, 12, true, 1, 2);
|
impl_ppi_channel!(PPI_CH12, 12 => configurable);
|
||||||
impl_ppi_channel!(PPI_CH13, 13, true, 1, 2);
|
impl_ppi_channel!(PPI_CH13, 13 => configurable);
|
||||||
impl_ppi_channel!(PPI_CH14, 14, true, 1, 2);
|
impl_ppi_channel!(PPI_CH14, 14 => configurable);
|
||||||
impl_ppi_channel!(PPI_CH15, 15, true, 1, 2);
|
impl_ppi_channel!(PPI_CH15, 15 => configurable);
|
||||||
impl_ppi_channel!(PPI_CH16, 16, true, 1, 2);
|
impl_ppi_channel!(PPI_CH16, 16 => configurable);
|
||||||
impl_ppi_channel!(PPI_CH17, 17, true, 1, 2);
|
impl_ppi_channel!(PPI_CH17, 17 => configurable);
|
||||||
impl_ppi_channel!(PPI_CH18, 18, true, 1, 2);
|
impl_ppi_channel!(PPI_CH18, 18 => configurable);
|
||||||
impl_ppi_channel!(PPI_CH19, 19, true, 1, 2);
|
impl_ppi_channel!(PPI_CH19, 19 => configurable);
|
||||||
impl_ppi_channel!(PPI_CH20, 20, false, 0, 1);
|
impl_ppi_channel!(PPI_CH20, 20 => static);
|
||||||
impl_ppi_channel!(PPI_CH21, 21, false, 0, 1);
|
impl_ppi_channel!(PPI_CH21, 21 => static);
|
||||||
impl_ppi_channel!(PPI_CH22, 22, false, 0, 1);
|
impl_ppi_channel!(PPI_CH22, 22 => static);
|
||||||
impl_ppi_channel!(PPI_CH23, 23, false, 0, 1);
|
impl_ppi_channel!(PPI_CH23, 23 => static);
|
||||||
impl_ppi_channel!(PPI_CH24, 24, false, 0, 1);
|
impl_ppi_channel!(PPI_CH24, 24 => static);
|
||||||
impl_ppi_channel!(PPI_CH25, 25, false, 0, 1);
|
impl_ppi_channel!(PPI_CH25, 25 => static);
|
||||||
impl_ppi_channel!(PPI_CH26, 26, false, 0, 1);
|
impl_ppi_channel!(PPI_CH26, 26 => static);
|
||||||
impl_ppi_channel!(PPI_CH27, 27, false, 0, 1);
|
impl_ppi_channel!(PPI_CH27, 27 => static);
|
||||||
impl_ppi_channel!(PPI_CH28, 28, false, 0, 1);
|
impl_ppi_channel!(PPI_CH28, 28 => static);
|
||||||
impl_ppi_channel!(PPI_CH29, 29, false, 0, 1);
|
impl_ppi_channel!(PPI_CH29, 29 => static);
|
||||||
impl_ppi_channel!(PPI_CH30, 30, false, 0, 1);
|
impl_ppi_channel!(PPI_CH30, 30 => static);
|
||||||
impl_ppi_channel!(PPI_CH31, 31, false, 0, 1);
|
impl_ppi_channel!(PPI_CH31, 31 => static);
|
||||||
|
|
||||||
impl_saadc_input!(P0_02, ANALOGINPUT0);
|
impl_saadc_input!(P0_02, ANALOGINPUT0);
|
||||||
impl_saadc_input!(P0_03, ANALOGINPUT1);
|
impl_saadc_input!(P0_03, ANALOGINPUT1);
|
||||||
|
|
|
@ -226,38 +226,38 @@ impl_pin!(P1_13, 1, 13);
|
||||||
impl_pin!(P1_14, 1, 14);
|
impl_pin!(P1_14, 1, 14);
|
||||||
impl_pin!(P1_15, 1, 15);
|
impl_pin!(P1_15, 1, 15);
|
||||||
|
|
||||||
impl_ppi_channel!(PPI_CH0, 0, true, 1, 2);
|
impl_ppi_channel!(PPI_CH0, 0 => configurable);
|
||||||
impl_ppi_channel!(PPI_CH1, 1, true, 1, 2);
|
impl_ppi_channel!(PPI_CH1, 1 => configurable);
|
||||||
impl_ppi_channel!(PPI_CH2, 2, true, 1, 2);
|
impl_ppi_channel!(PPI_CH2, 2 => configurable);
|
||||||
impl_ppi_channel!(PPI_CH3, 3, true, 1, 2);
|
impl_ppi_channel!(PPI_CH3, 3 => configurable);
|
||||||
impl_ppi_channel!(PPI_CH4, 4, true, 1, 2);
|
impl_ppi_channel!(PPI_CH4, 4 => configurable);
|
||||||
impl_ppi_channel!(PPI_CH5, 5, true, 1, 2);
|
impl_ppi_channel!(PPI_CH5, 5 => configurable);
|
||||||
impl_ppi_channel!(PPI_CH6, 6, true, 1, 2);
|
impl_ppi_channel!(PPI_CH6, 6 => configurable);
|
||||||
impl_ppi_channel!(PPI_CH7, 7, true, 1, 2);
|
impl_ppi_channel!(PPI_CH7, 7 => configurable);
|
||||||
impl_ppi_channel!(PPI_CH8, 8, true, 1, 2);
|
impl_ppi_channel!(PPI_CH8, 8 => configurable);
|
||||||
impl_ppi_channel!(PPI_CH9, 9, true, 1, 2);
|
impl_ppi_channel!(PPI_CH9, 9 => configurable);
|
||||||
impl_ppi_channel!(PPI_CH10, 10, true, 1, 2);
|
impl_ppi_channel!(PPI_CH10, 10 => configurable);
|
||||||
impl_ppi_channel!(PPI_CH11, 11, true, 1, 2);
|
impl_ppi_channel!(PPI_CH11, 11 => configurable);
|
||||||
impl_ppi_channel!(PPI_CH12, 12, true, 1, 2);
|
impl_ppi_channel!(PPI_CH12, 12 => configurable);
|
||||||
impl_ppi_channel!(PPI_CH13, 13, true, 1, 2);
|
impl_ppi_channel!(PPI_CH13, 13 => configurable);
|
||||||
impl_ppi_channel!(PPI_CH14, 14, true, 1, 2);
|
impl_ppi_channel!(PPI_CH14, 14 => configurable);
|
||||||
impl_ppi_channel!(PPI_CH15, 15, true, 1, 2);
|
impl_ppi_channel!(PPI_CH15, 15 => configurable);
|
||||||
impl_ppi_channel!(PPI_CH16, 16, true, 1, 2);
|
impl_ppi_channel!(PPI_CH16, 16 => configurable);
|
||||||
impl_ppi_channel!(PPI_CH17, 17, true, 1, 2);
|
impl_ppi_channel!(PPI_CH17, 17 => configurable);
|
||||||
impl_ppi_channel!(PPI_CH18, 18, true, 1, 2);
|
impl_ppi_channel!(PPI_CH18, 18 => configurable);
|
||||||
impl_ppi_channel!(PPI_CH19, 19, true, 1, 2);
|
impl_ppi_channel!(PPI_CH19, 19 => configurable);
|
||||||
impl_ppi_channel!(PPI_CH20, 20, false, 0, 1);
|
impl_ppi_channel!(PPI_CH20, 20 => static);
|
||||||
impl_ppi_channel!(PPI_CH21, 21, false, 0, 1);
|
impl_ppi_channel!(PPI_CH21, 21 => static);
|
||||||
impl_ppi_channel!(PPI_CH22, 22, false, 0, 1);
|
impl_ppi_channel!(PPI_CH22, 22 => static);
|
||||||
impl_ppi_channel!(PPI_CH23, 23, false, 0, 1);
|
impl_ppi_channel!(PPI_CH23, 23 => static);
|
||||||
impl_ppi_channel!(PPI_CH24, 24, false, 0, 1);
|
impl_ppi_channel!(PPI_CH24, 24 => static);
|
||||||
impl_ppi_channel!(PPI_CH25, 25, false, 0, 1);
|
impl_ppi_channel!(PPI_CH25, 25 => static);
|
||||||
impl_ppi_channel!(PPI_CH26, 26, false, 0, 1);
|
impl_ppi_channel!(PPI_CH26, 26 => static);
|
||||||
impl_ppi_channel!(PPI_CH27, 27, false, 0, 1);
|
impl_ppi_channel!(PPI_CH27, 27 => static);
|
||||||
impl_ppi_channel!(PPI_CH28, 28, false, 0, 1);
|
impl_ppi_channel!(PPI_CH28, 28 => static);
|
||||||
impl_ppi_channel!(PPI_CH29, 29, false, 0, 1);
|
impl_ppi_channel!(PPI_CH29, 29 => static);
|
||||||
impl_ppi_channel!(PPI_CH30, 30, false, 0, 1);
|
impl_ppi_channel!(PPI_CH30, 30 => static);
|
||||||
impl_ppi_channel!(PPI_CH31, 31, false, 0, 1);
|
impl_ppi_channel!(PPI_CH31, 31 => static);
|
||||||
|
|
||||||
impl_saadc_input!(P0_02, ANALOGINPUT0);
|
impl_saadc_input!(P0_02, ANALOGINPUT0);
|
||||||
impl_saadc_input!(P0_03, ANALOGINPUT1);
|
impl_saadc_input!(P0_03, ANALOGINPUT1);
|
||||||
|
|
|
@ -231,38 +231,38 @@ impl_pin!(P1_13, 1, 13);
|
||||||
impl_pin!(P1_14, 1, 14);
|
impl_pin!(P1_14, 1, 14);
|
||||||
impl_pin!(P1_15, 1, 15);
|
impl_pin!(P1_15, 1, 15);
|
||||||
|
|
||||||
impl_ppi_channel!(PPI_CH0, 0, true, 1, 2);
|
impl_ppi_channel!(PPI_CH0, 0 => configurable);
|
||||||
impl_ppi_channel!(PPI_CH1, 1, true, 1, 2);
|
impl_ppi_channel!(PPI_CH1, 1 => configurable);
|
||||||
impl_ppi_channel!(PPI_CH2, 2, true, 1, 2);
|
impl_ppi_channel!(PPI_CH2, 2 => configurable);
|
||||||
impl_ppi_channel!(PPI_CH3, 3, true, 1, 2);
|
impl_ppi_channel!(PPI_CH3, 3 => configurable);
|
||||||
impl_ppi_channel!(PPI_CH4, 4, true, 1, 2);
|
impl_ppi_channel!(PPI_CH4, 4 => configurable);
|
||||||
impl_ppi_channel!(PPI_CH5, 5, true, 1, 2);
|
impl_ppi_channel!(PPI_CH5, 5 => configurable);
|
||||||
impl_ppi_channel!(PPI_CH6, 6, true, 1, 2);
|
impl_ppi_channel!(PPI_CH6, 6 => configurable);
|
||||||
impl_ppi_channel!(PPI_CH7, 7, true, 1, 2);
|
impl_ppi_channel!(PPI_CH7, 7 => configurable);
|
||||||
impl_ppi_channel!(PPI_CH8, 8, true, 1, 2);
|
impl_ppi_channel!(PPI_CH8, 8 => configurable);
|
||||||
impl_ppi_channel!(PPI_CH9, 9, true, 1, 2);
|
impl_ppi_channel!(PPI_CH9, 9 => configurable);
|
||||||
impl_ppi_channel!(PPI_CH10, 10, true, 1, 2);
|
impl_ppi_channel!(PPI_CH10, 10 => configurable);
|
||||||
impl_ppi_channel!(PPI_CH11, 11, true, 1, 2);
|
impl_ppi_channel!(PPI_CH11, 11 => configurable);
|
||||||
impl_ppi_channel!(PPI_CH12, 12, true, 1, 2);
|
impl_ppi_channel!(PPI_CH12, 12 => configurable);
|
||||||
impl_ppi_channel!(PPI_CH13, 13, true, 1, 2);
|
impl_ppi_channel!(PPI_CH13, 13 => configurable);
|
||||||
impl_ppi_channel!(PPI_CH14, 14, true, 1, 2);
|
impl_ppi_channel!(PPI_CH14, 14 => configurable);
|
||||||
impl_ppi_channel!(PPI_CH15, 15, true, 1, 2);
|
impl_ppi_channel!(PPI_CH15, 15 => configurable);
|
||||||
impl_ppi_channel!(PPI_CH16, 16, true, 1, 2);
|
impl_ppi_channel!(PPI_CH16, 16 => configurable);
|
||||||
impl_ppi_channel!(PPI_CH17, 17, true, 1, 2);
|
impl_ppi_channel!(PPI_CH17, 17 => configurable);
|
||||||
impl_ppi_channel!(PPI_CH18, 18, true, 1, 2);
|
impl_ppi_channel!(PPI_CH18, 18 => configurable);
|
||||||
impl_ppi_channel!(PPI_CH19, 19, true, 1, 2);
|
impl_ppi_channel!(PPI_CH19, 19 => configurable);
|
||||||
impl_ppi_channel!(PPI_CH20, 20, false, 0, 1);
|
impl_ppi_channel!(PPI_CH20, 20 => static);
|
||||||
impl_ppi_channel!(PPI_CH21, 21, false, 0, 1);
|
impl_ppi_channel!(PPI_CH21, 21 => static);
|
||||||
impl_ppi_channel!(PPI_CH22, 22, false, 0, 1);
|
impl_ppi_channel!(PPI_CH22, 22 => static);
|
||||||
impl_ppi_channel!(PPI_CH23, 23, false, 0, 1);
|
impl_ppi_channel!(PPI_CH23, 23 => static);
|
||||||
impl_ppi_channel!(PPI_CH24, 24, false, 0, 1);
|
impl_ppi_channel!(PPI_CH24, 24 => static);
|
||||||
impl_ppi_channel!(PPI_CH25, 25, false, 0, 1);
|
impl_ppi_channel!(PPI_CH25, 25 => static);
|
||||||
impl_ppi_channel!(PPI_CH26, 26, false, 0, 1);
|
impl_ppi_channel!(PPI_CH26, 26 => static);
|
||||||
impl_ppi_channel!(PPI_CH27, 27, false, 0, 1);
|
impl_ppi_channel!(PPI_CH27, 27 => static);
|
||||||
impl_ppi_channel!(PPI_CH28, 28, false, 0, 1);
|
impl_ppi_channel!(PPI_CH28, 28 => static);
|
||||||
impl_ppi_channel!(PPI_CH29, 29, false, 0, 1);
|
impl_ppi_channel!(PPI_CH29, 29 => static);
|
||||||
impl_ppi_channel!(PPI_CH30, 30, false, 0, 1);
|
impl_ppi_channel!(PPI_CH30, 30 => static);
|
||||||
impl_ppi_channel!(PPI_CH31, 31, false, 0, 1);
|
impl_ppi_channel!(PPI_CH31, 31 => static);
|
||||||
|
|
||||||
impl_saadc_input!(P0_02, ANALOGINPUT0);
|
impl_saadc_input!(P0_02, ANALOGINPUT0);
|
||||||
impl_saadc_input!(P0_03, ANALOGINPUT1);
|
impl_saadc_input!(P0_03, ANALOGINPUT1);
|
||||||
|
|
|
@ -184,22 +184,22 @@ impl_pin!(P0_29, 0, 29);
|
||||||
impl_pin!(P0_30, 0, 30);
|
impl_pin!(P0_30, 0, 30);
|
||||||
impl_pin!(P0_31, 0, 31);
|
impl_pin!(P0_31, 0, 31);
|
||||||
|
|
||||||
impl_ppi_channel!(PPI_CH0, 0, true, many, many);
|
impl_ppi_channel!(PPI_CH0, 0 => configurable);
|
||||||
impl_ppi_channel!(PPI_CH1, 1, true, many, many);
|
impl_ppi_channel!(PPI_CH1, 1 => configurable);
|
||||||
impl_ppi_channel!(PPI_CH2, 2, true, many, many);
|
impl_ppi_channel!(PPI_CH2, 2 => configurable);
|
||||||
impl_ppi_channel!(PPI_CH3, 3, true, many, many);
|
impl_ppi_channel!(PPI_CH3, 3 => configurable);
|
||||||
impl_ppi_channel!(PPI_CH4, 4, true, many, many);
|
impl_ppi_channel!(PPI_CH4, 4 => configurable);
|
||||||
impl_ppi_channel!(PPI_CH5, 5, true, many, many);
|
impl_ppi_channel!(PPI_CH5, 5 => configurable);
|
||||||
impl_ppi_channel!(PPI_CH6, 6, true, many, many);
|
impl_ppi_channel!(PPI_CH6, 6 => configurable);
|
||||||
impl_ppi_channel!(PPI_CH7, 7, true, many, many);
|
impl_ppi_channel!(PPI_CH7, 7 => configurable);
|
||||||
impl_ppi_channel!(PPI_CH8, 8, true, many, many);
|
impl_ppi_channel!(PPI_CH8, 8 => configurable);
|
||||||
impl_ppi_channel!(PPI_CH9, 9, true, many, many);
|
impl_ppi_channel!(PPI_CH9, 9 => configurable);
|
||||||
impl_ppi_channel!(PPI_CH10, 10, true, many, many);
|
impl_ppi_channel!(PPI_CH10, 10 => configurable);
|
||||||
impl_ppi_channel!(PPI_CH11, 11, true, many, many);
|
impl_ppi_channel!(PPI_CH11, 11 => configurable);
|
||||||
impl_ppi_channel!(PPI_CH12, 12, true, many, many);
|
impl_ppi_channel!(PPI_CH12, 12 => configurable);
|
||||||
impl_ppi_channel!(PPI_CH13, 13, true, many, many);
|
impl_ppi_channel!(PPI_CH13, 13 => configurable);
|
||||||
impl_ppi_channel!(PPI_CH14, 14, true, many, many);
|
impl_ppi_channel!(PPI_CH14, 14 => configurable);
|
||||||
impl_ppi_channel!(PPI_CH15, 15, true, many, many);
|
impl_ppi_channel!(PPI_CH15, 15 => configurable);
|
||||||
|
|
||||||
impl_saadc_input!(P0_13, ANALOGINPUT0);
|
impl_saadc_input!(P0_13, ANALOGINPUT0);
|
||||||
impl_saadc_input!(P0_14, ANALOGINPUT1);
|
impl_saadc_input!(P0_14, ANALOGINPUT1);
|
||||||
|
|
|
@ -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>
|
impl<'d, C: Channel + 'd, const EVENT_COUNT: usize, const TASK_COUNT: usize>
|
||||||
Ppi<'d, C, EVENT_COUNT, TASK_COUNT>
|
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.
|
/// Enables the channel.
|
||||||
pub fn enable(&mut self) {
|
pub fn enable(&mut self) {
|
||||||
let r = unsafe { &*pac::PPI::ptr() };
|
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<Target = C> + 'd, task: Task) -> Self {
|
pub fn new_zero_to_one(ch: impl Unborrow<Target = C> + 'd, task: Task) -> Self {
|
||||||
unborrow!(ch);
|
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<Target = C> + 'd, event: Event, task: Task) -> Self {
|
pub fn new_one_to_one(ch: impl Unborrow<Target = C> + 'd, event: Event, task: Task) -> Self {
|
||||||
unborrow!(ch);
|
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(
|
pub fn new_one_to_two(
|
||||||
ch: impl Unborrow<Target = C> + 'd,
|
ch: impl Unborrow<Target = C> + 'd,
|
||||||
event: Event,
|
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>
|
Ppi<'d, C, EVENT_COUNT, TASK_COUNT>
|
||||||
{
|
{
|
||||||
pub fn new_many_to_many(
|
pub fn new_many_to_many(
|
||||||
|
@ -221,72 +209,107 @@ pub(crate) mod sealed {
|
||||||
pub trait Channel: sealed::Channel + Unborrow<Target = Self> + Sized {
|
pub trait Channel: sealed::Channel + Unborrow<Target = Self> + Sized {
|
||||||
/// Returns the number of the channel
|
/// Returns the number of the channel
|
||||||
fn number(&self) -> usize;
|
fn number(&self) -> usize;
|
||||||
#[cfg(feature = "_ppi")]
|
fn configurable() -> bool;
|
||||||
fn is_task_configurable(&self) -> bool;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub trait ZeroToOneChannel: Channel {}
|
pub trait ConfigurableChannel: Channel {
|
||||||
pub trait OneToOneChannel: ZeroToOneChannel {}
|
fn degrade(self) -> AnyConfigurableChannel;
|
||||||
pub trait OneToTwoChannel: OneToOneChannel {}
|
}
|
||||||
pub trait ManyToManyChannel: OneToTwoChannel {}
|
|
||||||
|
pub trait StaticChannel: Channel {
|
||||||
|
fn degrade(self) -> AnyStaticChannel;
|
||||||
|
}
|
||||||
|
|
||||||
pub trait Group: sealed::Group + Sized {
|
pub trait Group: sealed::Group + Sized {
|
||||||
fn number(&self) -> usize;
|
fn number(&self) -> usize;
|
||||||
|
fn degrade(self) -> AnyGroup {
|
||||||
|
AnyGroup {
|
||||||
|
number: self.number() as u8,
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ======================
|
// ======================
|
||||||
// channels
|
// channels
|
||||||
|
|
||||||
pub struct AnyChannel {
|
/// The any channel can represent any static channel at runtime.
|
||||||
number: u8,
|
/// This can be used to have fewer generic parameters in some places.
|
||||||
#[cfg(feature = "_ppi")]
|
pub struct AnyStaticChannel {
|
||||||
has_configurable_task: bool,
|
pub(crate) number: u8,
|
||||||
}
|
}
|
||||||
unsafe_impl_unborrow!(AnyChannel);
|
unsafe_impl_unborrow!(AnyStaticChannel);
|
||||||
impl sealed::Channel for AnyChannel {}
|
impl sealed::Channel for AnyStaticChannel {}
|
||||||
impl Channel for AnyChannel {
|
impl Channel for AnyStaticChannel {
|
||||||
fn number(&self) -> usize {
|
fn number(&self) -> usize {
|
||||||
self.number as usize
|
self.number as usize
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "_ppi")]
|
fn configurable() -> bool {
|
||||||
fn is_task_configurable(&self) -> bool {
|
false
|
||||||
self.has_configurable_task
|
}
|
||||||
|
}
|
||||||
|
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 {
|
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::sealed::Channel for peripherals::$type {}
|
||||||
impl crate::ppi::Channel for peripherals::$type {
|
impl crate::ppi::Channel for peripherals::$type {
|
||||||
fn number(&self) -> usize {
|
fn number(&self) -> usize {
|
||||||
$number
|
$number
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "_ppi")]
|
fn configurable() -> bool {
|
||||||
fn is_task_configurable(&self) -> bool {
|
$configurability
|
||||||
$has_configurable_task
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
($type:ident, $number:expr, $has_configurable_task:expr, 0, 0) => {
|
($type:ident, $number:expr => static) => {
|
||||||
impl_ppi_channel!($type, $number, $has_configurable_task);
|
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) => {
|
($type:ident, $number:expr => configurable) => {
|
||||||
impl_ppi_channel!($type, $number, $has_configurable_task, 0, 0);
|
impl_ppi_channel!($type, $number, true);
|
||||||
impl crate::ppi::ZeroToOneChannel for peripherals::$type {}
|
impl crate::ppi::ConfigurableChannel for peripherals::$type {
|
||||||
};
|
fn degrade(self) -> crate::ppi::AnyConfigurableChannel {
|
||||||
($type:ident, $number:expr, $has_configurable_task:expr, 1, 1) => {
|
use crate::ppi::Channel;
|
||||||
impl_ppi_channel!($type, $number, $has_configurable_task, 0, 1);
|
crate::ppi::AnyConfigurableChannel {
|
||||||
impl crate::ppi::OneToOneChannel for peripherals::$type {}
|
number: self.number() as u8,
|
||||||
};
|
}
|
||||||
($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 {}
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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) {
|
fn set_fork_task(task: Option<&Task>, channel: usize) {
|
||||||
let r = unsafe { &*pac::PPI::ptr() };
|
let r = unsafe { &*pac::PPI::ptr() };
|
||||||
if let Some(task) = task {
|
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
|
/// Enables all tasks and events
|
||||||
pub(super) fn enable_all(tasks: &[Task], events: &[Event], channel: &C) {
|
pub(super) fn enable_all(tasks: &[Task], events: &[Event], channel: &C) {
|
||||||
// One configurable task, no fork
|
// 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());
|
Self::set_main_task(Some(&tasks[0]), channel.number());
|
||||||
}
|
}
|
||||||
|
|
||||||
// One configurable task, as fork
|
// 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());
|
Self::set_fork_task(Some(&tasks[0]), channel.number());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Two configurable tasks (main + fork)
|
// Two configurable tasks (main + fork)
|
||||||
|
#[cfg(not(feature = "nrf51"))]
|
||||||
if TASK_COUNT == 2 {
|
if TASK_COUNT == 2 {
|
||||||
Self::set_main_task(Some(&tasks[0]), channel.number());
|
Self::set_main_task(Some(&tasks[0]), channel.number());
|
||||||
Self::set_fork_task(Some(&tasks[1]), 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
|
/// Disable all tasks and events
|
||||||
pub(super) fn disable_all(&self) {
|
pub(super) fn disable_all(&self) {
|
||||||
if self.ch.is_task_configurable() {
|
if C::configurable() {
|
||||||
Self::set_main_task(None, self.ch.number());
|
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());
|
Self::set_fork_task(None, self.ch.number());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -18,7 +18,7 @@ use crate::gpio::sealed::Pin as _;
|
||||||
use crate::gpio::{self, OptionalPin as GpioOptionalPin, Pin as GpioPin};
|
use crate::gpio::{self, OptionalPin as GpioOptionalPin, Pin as GpioPin};
|
||||||
use crate::interrupt::Interrupt;
|
use crate::interrupt::Interrupt;
|
||||||
use crate::pac;
|
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::Instance as TimerInstance;
|
||||||
use crate::timer::{Frequency, Timer};
|
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> {
|
pub struct UarteWithIdle<'d, U: Instance, T: TimerInstance> {
|
||||||
uarte: Uarte<'d, U>,
|
uarte: Uarte<'d, U>,
|
||||||
timer: Timer<'d, T>,
|
timer: Timer<'d, T>,
|
||||||
ppi_ch1: Ppi<'d, AnyChannel, 1, 2>,
|
ppi_ch1: Ppi<'d, AnyConfigurableChannel, 1, 2>,
|
||||||
_ppi_ch2: Ppi<'d, AnyChannel, 1, 1>,
|
_ppi_ch2: Ppi<'d, AnyConfigurableChannel, 1, 1>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'d, U: Instance, T: TimerInstance> UarteWithIdle<'d, U, T> {
|
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(
|
pub unsafe fn new(
|
||||||
uarte: impl Unborrow<Target = U> + 'd,
|
uarte: impl Unborrow<Target = U> + 'd,
|
||||||
timer: impl Unborrow<Target = T> + 'd,
|
timer: impl Unborrow<Target = T> + 'd,
|
||||||
ppi_ch1: impl Unborrow<Target = impl OneToTwoChannel + 'd> + 'd,
|
ppi_ch1: impl Unborrow<Target = impl ConfigurableChannel + 'd> + 'd,
|
||||||
ppi_ch2: impl Unborrow<Target = impl OneToOneChannel + 'd> + 'd,
|
ppi_ch2: impl Unborrow<Target = impl ConfigurableChannel + 'd> + 'd,
|
||||||
irq: impl Unborrow<Target = U::Interrupt> + 'd,
|
irq: impl Unborrow<Target = U::Interrupt> + 'd,
|
||||||
rxd: impl Unborrow<Target = impl GpioPin> + 'd,
|
rxd: impl Unborrow<Target = impl GpioPin> + 'd,
|
||||||
txd: impl Unborrow<Target = impl GpioPin> + 'd,
|
txd: impl Unborrow<Target = impl GpioPin> + 'd,
|
||||||
|
@ -379,20 +379,18 @@ impl<'d, U: Instance, T: TimerInstance> UarteWithIdle<'d, U, T> {
|
||||||
timer.cc(0).short_compare_stop();
|
timer.cc(0).short_compare_stop();
|
||||||
|
|
||||||
let mut ppi_ch1 = Ppi::new_one_to_two(
|
let mut ppi_ch1 = Ppi::new_one_to_two(
|
||||||
ppi_ch1,
|
ppi_ch1.degrade(),
|
||||||
Event::from_reg(&r.events_rxdrdy),
|
Event::from_reg(&r.events_rxdrdy),
|
||||||
timer.task_clear(),
|
timer.task_clear(),
|
||||||
timer.task_start(),
|
timer.task_start(),
|
||||||
)
|
);
|
||||||
.degrade();
|
|
||||||
ppi_ch1.enable();
|
ppi_ch1.enable();
|
||||||
|
|
||||||
let mut ppi_ch2 = Ppi::new_one_to_one(
|
let mut ppi_ch2 = Ppi::new_one_to_one(
|
||||||
ppi_ch2,
|
ppi_ch2.degrade(),
|
||||||
timer.cc(0).event_compare(),
|
timer.cc(0).event_compare(),
|
||||||
Task::from_reg(&r.tasks_stoprx),
|
Task::from_reg(&r.tasks_stoprx),
|
||||||
)
|
);
|
||||||
.degrade();
|
|
||||||
ppi_ch2.enable();
|
ppi_ch2.enable();
|
||||||
|
|
||||||
Self {
|
Self {
|
||||||
|
|
Loading…
Reference in a new issue