diff --git a/esp-hal/src/dma/gdma.rs b/esp-hal/src/dma/gdma.rs index 298a139f5..0cf281cf5 100644 --- a/esp-hal/src/dma/gdma.rs +++ b/esp-hal/src/dma/gdma.rs @@ -458,16 +458,6 @@ impl LcdCamPeripheral for SuitablePeripheral {} macro_rules! impl_channel { ($num: literal, $async_handler: path, $($interrupt: ident),* ) => { paste::paste! { - impl ChannelTypes for Channel<$num> { - fn set_isr(handler: $crate::interrupt::InterruptHandler) { - let mut dma = unsafe { crate::peripherals::DMA::steal() }; - $( - dma.[< bind_ $interrupt:lower _interrupt >](handler.handler()); - $crate::interrupt::enable($crate::peripherals::Interrupt::$interrupt, handler.priority()).unwrap(); - )* - } - } - /// A description of a GDMA channel #[non_exhaustive] pub struct [] {} @@ -479,6 +469,14 @@ macro_rules! impl_channel { type Rx = ChannelRxImpl<$num>; type Tx = ChannelTxImpl<$num>; type P = SuitablePeripheral<$num>; + + fn set_isr(handler: $crate::interrupt::InterruptHandler) { + let mut dma = unsafe { crate::peripherals::DMA::steal() }; + $( + dma.[< bind_ $interrupt:lower _interrupt >](handler.handler()); + $crate::interrupt::enable($crate::peripherals::Interrupt::$interrupt, handler.priority()).unwrap(); + )* + } } impl ChannelCreator<$num> { @@ -523,7 +521,7 @@ macro_rules! impl_channel { ) -> crate::dma::Channel<'a, [], $crate::Async> { let this = self.do_configure(burst_mode, priority); - as ChannelTypes>::set_isr($async_handler); + []::set_isr($async_handler); this } diff --git a/esp-hal/src/dma/mod.rs b/esp-hal/src/dma/mod.rs index f000c46f4..5c802036e 100644 --- a/esp-hal/src/dma/mod.rs +++ b/esp-hal/src/dma/mod.rs @@ -1238,7 +1238,7 @@ impl RxCircularState { /// A description of a DMA Channel. pub trait DmaChannel: crate::private::Sealed { #[doc(hidden)] - type Channel: ChannelTypes + RegisterAccess; + type Channel: RegisterAccess; /// A description of the RX half of a DMA Channel. type Rx: RxChannel; @@ -1248,6 +1248,9 @@ pub trait DmaChannel: crate::private::Sealed { /// A suitable peripheral for this DMA channel. type P: PeripheralMarker; + + #[doc(hidden)] + fn set_isr(handler: InterruptHandler); } /// The functions here are not meant to be used outside the HAL @@ -1743,11 +1746,6 @@ pub trait RegisterAccess: crate::private::Sealed { fn start_in(); } -#[doc(hidden)] -pub trait ChannelTypes: crate::private::Sealed { - fn set_isr(handler: InterruptHandler); -} - /// DMA Channel pub struct Channel<'d, CH, MODE> where @@ -1770,7 +1768,7 @@ where /// /// Interrupts are not enabled at the peripheral level here. pub fn set_interrupt_handler(&mut self, handler: InterruptHandler) { - ::set_isr(handler); + C::set_isr(handler); } /// Listen for the given interrupts diff --git a/esp-hal/src/dma/pdma.rs b/esp-hal/src/dma/pdma.rs index 9222ead50..96c50bf5a 100644 --- a/esp-hal/src/dma/pdma.rs +++ b/esp-hal/src/dma/pdma.rs @@ -29,11 +29,7 @@ macro_rules! ImplSpiChannel { type Rx = []; type Tx = []; type P = []; - } - impl $crate::private::Sealed for [] {} - - impl ChannelTypes for [] { fn set_isr(handler: $crate::interrupt::InterruptHandler) { let mut spi = unsafe { $crate::peripherals::[< SPI $num >]::steal() }; spi.[< bind_spi $num _dma_interrupt>](handler.handler()); @@ -41,6 +37,8 @@ macro_rules! ImplSpiChannel { } } + impl $crate::private::Sealed for [] {} + impl RegisterAccess for [] { fn set_out_burstmode(burst_mode: bool) { let spi = unsafe { &*crate::peripherals::[]::PTR }; @@ -390,7 +388,7 @@ macro_rules! ImplSpiChannel { ) -> Channel<'a, [], $crate::Async> { let this = Self::do_configure(self, burst_mode, priority); - <[] as ChannelTypes>::set_isr(super::asynch::interrupt::[< interrupt_handler_spi $num _dma >]); + []::set_isr(super::asynch::interrupt::[< interrupt_handler_spi $num _dma >]); this } @@ -412,9 +410,7 @@ macro_rules! ImplI2sChannel { type Rx = []; type Tx = []; type P = []; - } - impl ChannelTypes for [] { fn set_isr(handler: $crate::interrupt::InterruptHandler) { let mut i2s = unsafe { $crate::peripherals::[< I2S $num >]::steal() }; i2s.[< bind_i2s $num _interrupt>](handler.handler()); @@ -767,7 +763,7 @@ macro_rules! ImplI2sChannel { ) -> Channel<'a, [], $crate::Async> { let this = Self::do_configure(self, burst_mode, priority); - <[] as ChannelTypes>::set_isr(super::asynch::interrupt::[< interrupt_handler_i2s $num >]); + []::set_isr(super::asynch::interrupt::[< interrupt_handler_i2s $num >]); this }