From cf13dd7df860afeb9bccee2ca64004f0ac3643d2 Mon Sep 17 00:00:00 2001 From: Dario Nieuwenhuis Date: Mon, 11 Oct 2021 01:19:06 +0200 Subject: [PATCH] nrf/ppi: nrf52805 only has 10 configurable channels. --- embassy-nrf/src/chips/nrf52805.rs | 23 ++++++++++++++ embassy-nrf/src/chips/nrf52810.rs | 33 +++++++++++++++++++ embassy-nrf/src/chips/nrf52811.rs | 33 +++++++++++++++++++ embassy-nrf/src/chips/nrf52820.rs | 33 +++++++++++++++++++ embassy-nrf/src/chips/nrf52832.rs | 33 +++++++++++++++++++ embassy-nrf/src/chips/nrf52833.rs | 33 +++++++++++++++++++ embassy-nrf/src/chips/nrf52840.rs | 33 +++++++++++++++++++ embassy-nrf/src/ppi.rs | 53 ++++++------------------------- 8 files changed, 230 insertions(+), 44 deletions(-) diff --git a/embassy-nrf/src/chips/nrf52805.rs b/embassy-nrf/src/chips/nrf52805.rs index f214d927..3bf87e3d 100644 --- a/embassy-nrf/src/chips/nrf52805.rs +++ b/embassy-nrf/src/chips/nrf52805.rs @@ -159,6 +159,29 @@ impl_pin!(P0_29, 0, 29); impl_pin!(P0_30, 0, 30); impl_pin!(P0_31, 0, 31); +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); +impl_ppi_channel!(PPI_CH21, 21); +impl_ppi_channel!(PPI_CH22, 22); +impl_ppi_channel!(PPI_CH23, 23); +impl_ppi_channel!(PPI_CH24, 24); +impl_ppi_channel!(PPI_CH25, 25); +impl_ppi_channel!(PPI_CH26, 26); +impl_ppi_channel!(PPI_CH27, 27); +impl_ppi_channel!(PPI_CH28, 28); +impl_ppi_channel!(PPI_CH29, 29); +impl_ppi_channel!(PPI_CH30, 30); +impl_ppi_channel!(PPI_CH31, 31); + pub mod irqs { use crate::pac::Interrupt as InterruptEnum; use embassy_macros::interrupt_declare as declare; diff --git a/embassy-nrf/src/chips/nrf52810.rs b/embassy-nrf/src/chips/nrf52810.rs index caef3e7e..d3241364 100644 --- a/embassy-nrf/src/chips/nrf52810.rs +++ b/embassy-nrf/src/chips/nrf52810.rs @@ -164,6 +164,39 @@ impl_pin!(P0_29, 0, 29); impl_pin!(P0_30, 0, 30); impl_pin!(P0_31, 0, 31); +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); +impl_ppi_channel!(PPI_CH21, 21); +impl_ppi_channel!(PPI_CH22, 22); +impl_ppi_channel!(PPI_CH23, 23); +impl_ppi_channel!(PPI_CH24, 24); +impl_ppi_channel!(PPI_CH25, 25); +impl_ppi_channel!(PPI_CH26, 26); +impl_ppi_channel!(PPI_CH27, 27); +impl_ppi_channel!(PPI_CH28, 28); +impl_ppi_channel!(PPI_CH29, 29); +impl_ppi_channel!(PPI_CH30, 30); +impl_ppi_channel!(PPI_CH31, 31); + pub mod irqs { use crate::pac::Interrupt as InterruptEnum; use embassy_macros::interrupt_declare as declare; diff --git a/embassy-nrf/src/chips/nrf52811.rs b/embassy-nrf/src/chips/nrf52811.rs index cbf14df2..1231ae62 100644 --- a/embassy-nrf/src/chips/nrf52811.rs +++ b/embassy-nrf/src/chips/nrf52811.rs @@ -165,6 +165,39 @@ impl_pin!(P0_29, 0, 29); impl_pin!(P0_30, 0, 30); impl_pin!(P0_31, 0, 31); +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); +impl_ppi_channel!(PPI_CH21, 21); +impl_ppi_channel!(PPI_CH22, 22); +impl_ppi_channel!(PPI_CH23, 23); +impl_ppi_channel!(PPI_CH24, 24); +impl_ppi_channel!(PPI_CH25, 25); +impl_ppi_channel!(PPI_CH26, 26); +impl_ppi_channel!(PPI_CH27, 27); +impl_ppi_channel!(PPI_CH28, 28); +impl_ppi_channel!(PPI_CH29, 29); +impl_ppi_channel!(PPI_CH30, 30); +impl_ppi_channel!(PPI_CH31, 31); + pub mod irqs { use crate::pac::Interrupt as InterruptEnum; use embassy_macros::interrupt_declare as declare; diff --git a/embassy-nrf/src/chips/nrf52820.rs b/embassy-nrf/src/chips/nrf52820.rs index e434c009..fc7a367e 100644 --- a/embassy-nrf/src/chips/nrf52820.rs +++ b/embassy-nrf/src/chips/nrf52820.rs @@ -160,6 +160,39 @@ impl_pin!(P0_29, 0, 29); impl_pin!(P0_30, 0, 30); impl_pin!(P0_31, 0, 31); +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); +impl_ppi_channel!(PPI_CH21, 21); +impl_ppi_channel!(PPI_CH22, 22); +impl_ppi_channel!(PPI_CH23, 23); +impl_ppi_channel!(PPI_CH24, 24); +impl_ppi_channel!(PPI_CH25, 25); +impl_ppi_channel!(PPI_CH26, 26); +impl_ppi_channel!(PPI_CH27, 27); +impl_ppi_channel!(PPI_CH28, 28); +impl_ppi_channel!(PPI_CH29, 29); +impl_ppi_channel!(PPI_CH30, 30); +impl_ppi_channel!(PPI_CH31, 31); + pub mod irqs { use crate::pac::Interrupt as InterruptEnum; use embassy_macros::interrupt_declare as declare; diff --git a/embassy-nrf/src/chips/nrf52832.rs b/embassy-nrf/src/chips/nrf52832.rs index b95aa604..9bbef543 100644 --- a/embassy-nrf/src/chips/nrf52832.rs +++ b/embassy-nrf/src/chips/nrf52832.rs @@ -178,6 +178,39 @@ impl_pin!(P0_29, 0, 29); impl_pin!(P0_30, 0, 30); impl_pin!(P0_31, 0, 31); +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); +impl_ppi_channel!(PPI_CH21, 21); +impl_ppi_channel!(PPI_CH22, 22); +impl_ppi_channel!(PPI_CH23, 23); +impl_ppi_channel!(PPI_CH24, 24); +impl_ppi_channel!(PPI_CH25, 25); +impl_ppi_channel!(PPI_CH26, 26); +impl_ppi_channel!(PPI_CH27, 27); +impl_ppi_channel!(PPI_CH28, 28); +impl_ppi_channel!(PPI_CH29, 29); +impl_ppi_channel!(PPI_CH30, 30); +impl_ppi_channel!(PPI_CH31, 31); + pub mod irqs { use crate::pac::Interrupt as InterruptEnum; use embassy_macros::interrupt_declare as declare; diff --git a/embassy-nrf/src/chips/nrf52833.rs b/embassy-nrf/src/chips/nrf52833.rs index 570e4b10..d9495dd9 100644 --- a/embassy-nrf/src/chips/nrf52833.rs +++ b/embassy-nrf/src/chips/nrf52833.rs @@ -218,6 +218,39 @@ impl_pin!(P1_13, 1, 13); impl_pin!(P1_14, 1, 14); impl_pin!(P1_15, 1, 15); +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); +impl_ppi_channel!(PPI_CH21, 21); +impl_ppi_channel!(PPI_CH22, 22); +impl_ppi_channel!(PPI_CH23, 23); +impl_ppi_channel!(PPI_CH24, 24); +impl_ppi_channel!(PPI_CH25, 25); +impl_ppi_channel!(PPI_CH26, 26); +impl_ppi_channel!(PPI_CH27, 27); +impl_ppi_channel!(PPI_CH28, 28); +impl_ppi_channel!(PPI_CH29, 29); +impl_ppi_channel!(PPI_CH30, 30); +impl_ppi_channel!(PPI_CH31, 31); + pub mod irqs { use crate::pac::Interrupt as InterruptEnum; use embassy_macros::interrupt_declare as declare; diff --git a/embassy-nrf/src/chips/nrf52840.rs b/embassy-nrf/src/chips/nrf52840.rs index 1221f23b..ad89afbc 100644 --- a/embassy-nrf/src/chips/nrf52840.rs +++ b/embassy-nrf/src/chips/nrf52840.rs @@ -223,6 +223,39 @@ impl_pin!(P1_13, 1, 13); impl_pin!(P1_14, 1, 14); impl_pin!(P1_15, 1, 15); +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); +impl_ppi_channel!(PPI_CH21, 21); +impl_ppi_channel!(PPI_CH22, 22); +impl_ppi_channel!(PPI_CH23, 23); +impl_ppi_channel!(PPI_CH24, 24); +impl_ppi_channel!(PPI_CH25, 25); +impl_ppi_channel!(PPI_CH26, 26); +impl_ppi_channel!(PPI_CH27, 27); +impl_ppi_channel!(PPI_CH28, 28); +impl_ppi_channel!(PPI_CH29, 29); +impl_ppi_channel!(PPI_CH30, 30); +impl_ppi_channel!(PPI_CH31, 31); + pub mod irqs { use crate::pac::Interrupt as InterruptEnum; use embassy_macros::interrupt_declare as declare; diff --git a/embassy-nrf/src/ppi.rs b/embassy-nrf/src/ppi.rs index a18dec12..1b12b1e9 100644 --- a/embassy-nrf/src/ppi.rs +++ b/embassy-nrf/src/ppi.rs @@ -1,3 +1,5 @@ +#![macro_use] + //! HAL interface for the PPI peripheral. //! //! The Programmable Peripheral Interconnect interface allows for an autonomous interoperability @@ -109,7 +111,7 @@ impl Event { } } -mod sealed { +pub(crate) mod sealed { pub trait ConfigurableChannel {} pub trait Channel {} pub trait Group {} @@ -167,15 +169,15 @@ impl Channel for AnyConfigurableChannel { } } -macro_rules! impl_channel { +macro_rules! impl_ppi_channel { ($type:ident, $number:expr, configurable) => { - impl_channel!($type, $number); - impl sealed::ConfigurableChannel for peripherals::$type {} - impl ConfigurableChannel for peripherals::$type {} + impl_ppi_channel!($type, $number); + impl crate::ppi::sealed::ConfigurableChannel for peripherals::$type {} + impl crate::ppi::ConfigurableChannel for peripherals::$type {} }; ($type:ident, $number:expr) => { - impl sealed::Channel for peripherals::$type {} - impl Channel for peripherals::$type { + impl crate::ppi::sealed::Channel for peripherals::$type {} + impl crate::ppi::Channel for peripherals::$type { fn number(&self) -> usize { $number } @@ -183,43 +185,6 @@ macro_rules! impl_channel { }; } -impl_channel!(PPI_CH0, 0, configurable); -impl_channel!(PPI_CH1, 1, configurable); -impl_channel!(PPI_CH2, 2, configurable); -impl_channel!(PPI_CH3, 3, configurable); -impl_channel!(PPI_CH4, 4, configurable); -impl_channel!(PPI_CH5, 5, configurable); -impl_channel!(PPI_CH6, 6, configurable); -impl_channel!(PPI_CH7, 7, configurable); -impl_channel!(PPI_CH8, 8, configurable); -impl_channel!(PPI_CH9, 9, configurable); -impl_channel!(PPI_CH10, 10, configurable); -impl_channel!(PPI_CH11, 11, configurable); -impl_channel!(PPI_CH12, 12, configurable); -impl_channel!(PPI_CH13, 13, configurable); -impl_channel!(PPI_CH14, 14, configurable); -impl_channel!(PPI_CH15, 15, configurable); -#[cfg(not(feature = "nrf51"))] -impl_channel!(PPI_CH16, 16, configurable); -#[cfg(not(feature = "nrf51"))] -impl_channel!(PPI_CH17, 17, configurable); -#[cfg(not(feature = "nrf51"))] -impl_channel!(PPI_CH18, 18, configurable); -#[cfg(not(feature = "nrf51"))] -impl_channel!(PPI_CH19, 19, configurable); -impl_channel!(PPI_CH20, 20); -impl_channel!(PPI_CH21, 21); -impl_channel!(PPI_CH22, 22); -impl_channel!(PPI_CH23, 23); -impl_channel!(PPI_CH24, 24); -impl_channel!(PPI_CH25, 25); -impl_channel!(PPI_CH26, 26); -impl_channel!(PPI_CH27, 27); -impl_channel!(PPI_CH28, 28); -impl_channel!(PPI_CH29, 29); -impl_channel!(PPI_CH30, 30); -impl_channel!(PPI_CH31, 31); - // ====================== // groups