Remove ChannelTypes trait (#2220)

Co-authored-by: Dominic Fischer <git@dominicfischer.me>
This commit is contained in:
Dominic Fischer 2024-09-24 16:01:11 +01:00 committed by GitHub
parent 4534ee13ae
commit 826754c482
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 18 additions and 26 deletions

View File

@ -458,16 +458,6 @@ impl<const N: u8> LcdCamPeripheral for SuitablePeripheral<N> {}
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 [<DmaChannel $num>] {}
@ -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, [<DmaChannel $num>], $crate::Async> {
let this = self.do_configure(burst_mode, priority);
<Channel<$num> as ChannelTypes>::set_isr($async_handler);
[<DmaChannel $num>]::set_isr($async_handler);
this
}

View File

@ -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<Self::Channel>;
@ -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) {
<C::Channel as ChannelTypes>::set_isr(handler);
C::set_isr(handler);
}
/// Listen for the given interrupts

View File

@ -29,11 +29,7 @@ macro_rules! ImplSpiChannel {
type Rx = [<Spi $num DmaChannelRxImpl>];
type Tx = [<Spi $num DmaChannelTxImpl>];
type P = [<Spi $num DmaSuitablePeripheral>];
}
impl $crate::private::Sealed for [<Spi $num DmaChannel>] {}
impl ChannelTypes for [<Spi $num DmaChannel>] {
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 [<Spi $num DmaChannel>] {}
impl RegisterAccess for [<Spi $num DmaChannel>] {
fn set_out_burstmode(burst_mode: bool) {
let spi = unsafe { &*crate::peripherals::[<SPI $num>]::PTR };
@ -390,7 +388,7 @@ macro_rules! ImplSpiChannel {
) -> Channel<'a, [<Spi $num DmaChannel>], $crate::Async> {
let this = Self::do_configure(self, burst_mode, priority);
<[<Spi $num DmaChannel>] as ChannelTypes>::set_isr(super::asynch::interrupt::[< interrupt_handler_spi $num _dma >]);
[<Spi $num DmaChannel>]::set_isr(super::asynch::interrupt::[< interrupt_handler_spi $num _dma >]);
this
}
@ -412,9 +410,7 @@ macro_rules! ImplI2sChannel {
type Rx = [<I2s $num DmaChannelRxImpl>];
type Tx = [<I2s $num DmaChannelTxImpl>];
type P = [<I2s $num DmaSuitablePeripheral>];
}
impl ChannelTypes for [<I2s $num DmaChannel>] {
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, [<I2s $num DmaChannel>], $crate::Async> {
let this = Self::do_configure(self, burst_mode, priority);
<[<I2s $num DmaChannel>] as ChannelTypes>::set_isr(super::asynch::interrupt::[< interrupt_handler_i2s $num >]);
[<I2s $num DmaChannel>]::set_isr(super::asynch::interrupt::[< interrupt_handler_i2s $num >]);
this
}