From 52c500a4e54bc2c9f08ae91558523d13f935c01e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?D=C3=A1niel=20Buga?= Date: Mon, 7 Oct 2024 23:08:41 +0200 Subject: [PATCH] Remove AnyPdmaChannel --- esp-hal/src/dma/pdma.rs | 213 ---------------------------------------- 1 file changed, 213 deletions(-) diff --git a/esp-hal/src/dma/pdma.rs b/esp-hal/src/dma/pdma.rs index 88e81aefcba..1a238dbea46 100644 --- a/esp-hal/src/dma/pdma.rs +++ b/esp-hal/src/dma/pdma.rs @@ -37,29 +37,11 @@ pub struct SpiDmaRxChannelImpl(C); impl crate::private::Sealed for SpiDmaRxChannelImpl {} -impl SpiDmaRxChannelImpl -where - AnyPdmaRxChannel: From, -{ - fn degrade(self) -> AnyPdmaRxChannelImpl { - AnyPdmaRxChannelImpl(AnyPdmaRxChannel::from(self)) - } -} - #[doc(hidden)] pub struct SpiDmaTxChannelImpl(C); impl crate::private::Sealed for SpiDmaTxChannelImpl {} -impl SpiDmaTxChannelImpl -where - AnyPdmaTxChannel: From, -{ - fn degrade(self) -> AnyPdmaTxChannelImpl { - AnyPdmaTxChannelImpl(AnyPdmaTxChannel::from(self)) - } -} - impl> RegisterAccess for SpiDmaTxChannelImpl { fn reset(&self) { let spi = self.0.register_block(); @@ -347,14 +329,6 @@ macro_rules! ImplSpiChannel { type Tx = SpiDmaTxChannelImpl; } - impl DmaChannelConvert for [] { - fn degrade_rx(rx: Self::Rx) -> AnyPdmaRxChannelImpl { - rx.degrade() - } - fn degrade_tx(tx: Self::Tx) -> AnyPdmaTxChannelImpl { - tx.degrade() - } - } impl PeripheralDmaChannel for [] { type P = crate::peripherals::[]; } @@ -469,29 +443,11 @@ pub struct I2sDmaRxChannelImpl(C); impl crate::private::Sealed for I2sDmaRxChannelImpl {} -impl I2sDmaRxChannelImpl -where - AnyPdmaRxChannel: From, -{ - fn degrade(self) -> AnyPdmaRxChannelImpl { - AnyPdmaRxChannelImpl(AnyPdmaRxChannel::from(self)) - } -} - #[doc(hidden)] pub struct I2sDmaTxChannelImpl(C); impl crate::private::Sealed for I2sDmaTxChannelImpl {} -impl I2sDmaTxChannelImpl -where - AnyPdmaTxChannel: From, -{ - fn degrade(self) -> AnyPdmaTxChannelImpl { - AnyPdmaTxChannelImpl(AnyPdmaTxChannel::from(self)) - } -} - impl> RegisterAccess for I2sDmaTxChannelImpl { fn set_burst_mode(&self, burst_mode: bool) { let reg_block = self.0.register_block(); @@ -790,14 +746,6 @@ macro_rules! ImplI2sChannel { type Tx = I2sDmaTxChannelImpl; } - impl DmaChannelConvert for [] { - fn degrade_rx(rx: Self::Rx) -> AnyPdmaRxChannelImpl { - rx.degrade() - } - fn degrade_tx(tx: Self::Tx) -> AnyPdmaTxChannelImpl { - tx.degrade() - } - } impl PeripheralDmaChannel for [] { type P = crate::peripherals::[]; } @@ -944,167 +892,6 @@ impl<'d> Dma<'d> { } } -macro_rules! define_enum { - ( - $(#[$meta:meta])* - $vis:vis enum $ty:ident { - $($(#[$cfg:meta])? - $variant:ident($inner:ty),)* - } - ) => { - $(#[$meta])* - $vis enum $ty { - $( - $(#[$cfg])? - $variant($inner), - )* - } - - $( - $(#[$cfg])? - impl From<$inner> for $ty { - fn from(inner: $inner) -> Self { - Self::$variant(inner) - } - } - )* - } -} - -/// An arbitrary PDMA channel. -// NOTE: this is unused currently (peripherals prescribe a specific channel) but type-erased -// peripherals will require type-erased channels. -#[non_exhaustive] -pub struct AnyPdmaChannel; -impl crate::private::Sealed for AnyPdmaChannel {} - -impl DmaChannel for AnyPdmaChannel { - type Rx = AnyPdmaRxChannelImpl; - type Tx = AnyPdmaTxChannelImpl; -} - -define_enum! { - #[doc(hidden)] - pub enum AnyPdmaRxChannel { - Spi2(SpiDmaRxChannelImpl), - Spi3(SpiDmaRxChannelImpl), - I2s0(I2sDmaRxChannelImpl), - #[cfg(i2s1)] - I2s1(I2sDmaRxChannelImpl), - } -} - -#[doc(hidden)] -pub struct AnyPdmaRxChannelImpl(AnyPdmaRxChannel); - -impl crate::private::Sealed for AnyPdmaRxChannelImpl {} -impl InterruptAccess for AnyPdmaRxChannelImpl { - delegate::delegate! { - to match &self.0 { - AnyPdmaRxChannel::Spi2(channel) => channel, - AnyPdmaRxChannel::Spi3(channel) => channel, - AnyPdmaRxChannel::I2s0(channel) => channel, - #[cfg(i2s1)] - AnyPdmaRxChannel::I2s1(channel) => channel, - } { - fn enable_listen(&self, interrupts: EnumSet, enable: bool); - fn is_listening(&self) -> EnumSet; - fn clear(&self, interrupts: impl Into>); - fn pending_interrupts(&self) -> EnumSet; - fn waker(&self) -> &'static AtomicWaker; - } - } -} -impl RegisterAccess for AnyPdmaRxChannelImpl { - delegate::delegate! { - to match &self.0 { - AnyPdmaRxChannel::Spi2(channel) => channel, - AnyPdmaRxChannel::Spi3(channel) => channel, - AnyPdmaRxChannel::I2s0(channel) => channel, - #[cfg(i2s1)] - AnyPdmaRxChannel::I2s1(channel) => channel, - } { - fn set_burst_mode(&self, burst_mode: bool); - fn set_priority(&self, priority: DmaPriority); - fn reset(&self); - fn set_link_addr(&self, address: u32); - fn set_peripheral(&self, peripheral: u8); - fn start(&self); - fn stop(&self); - fn restart(&self); - fn is_compatible_with(&self, peripheral: &impl PeripheralMarker) -> bool; - } - } -} -impl RxRegisterAccess for AnyPdmaRxChannelImpl {} - -define_enum! { - #[doc(hidden)] - pub enum AnyPdmaTxChannel { - Spi2(SpiDmaTxChannelImpl), - Spi3(SpiDmaTxChannelImpl), - I2s0(I2sDmaTxChannelImpl), - #[cfg(i2s1)] - I2s1(I2sDmaTxChannelImpl), - } -} - -#[doc(hidden)] -pub struct AnyPdmaTxChannelImpl(AnyPdmaTxChannel); - -impl crate::private::Sealed for AnyPdmaTxChannelImpl {} -impl InterruptAccess for AnyPdmaTxChannelImpl { - delegate::delegate! { - to match &self.0 { - AnyPdmaTxChannel::Spi2(channel) => channel, - AnyPdmaTxChannel::Spi3(channel) => channel, - AnyPdmaTxChannel::I2s0(channel) => channel, - #[cfg(i2s1)] - AnyPdmaTxChannel::I2s1(channel) => channel, - } { - fn enable_listen(&self, interrupts: EnumSet, enable: bool); - fn is_listening(&self) -> EnumSet; - fn clear(&self, interrupts: impl Into>); - fn pending_interrupts(&self) -> EnumSet; - fn waker(&self) -> &'static AtomicWaker; - } - } -} -impl RegisterAccess for AnyPdmaTxChannelImpl { - delegate::delegate! { - to match &self.0 { - AnyPdmaTxChannel::Spi2(channel) => channel, - AnyPdmaTxChannel::Spi3(channel) => channel, - AnyPdmaTxChannel::I2s0(channel) => channel, - #[cfg(i2s1)] - AnyPdmaTxChannel::I2s1(channel) => channel, - } { - fn set_burst_mode(&self, burst_mode: bool); - fn set_priority(&self, priority: DmaPriority); - fn reset(&self); - fn set_link_addr(&self, address: u32); - fn set_peripheral(&self, peripheral: u8); - fn start(&self); - fn stop(&self); - fn restart(&self); - fn is_compatible_with(&self, peripheral: &impl PeripheralMarker) -> bool; - } - } -} -impl TxRegisterAccess for AnyPdmaTxChannelImpl { - delegate::delegate! { - to match &self.0 { - AnyPdmaTxChannel::Spi2(channel) => channel, - AnyPdmaTxChannel::Spi3(channel) => channel, - AnyPdmaTxChannel::I2s0(channel) => channel, - #[cfg(i2s1)] - AnyPdmaTxChannel::I2s1(channel) => channel, - } { - fn last_dscr_address(&self) -> usize; - } - } -} - impl<'d, C, M: Mode> Channel<'d, C, M> where C: DmaChannel,