Skip to content

Commit

Permalink
Rename type-erased dma channel
Browse files Browse the repository at this point in the history
  • Loading branch information
bugadani committed Oct 19, 2024
1 parent 909dfb8 commit 572fb23
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 14 deletions.
26 changes: 13 additions & 13 deletions esp-hal/src/dma/pdma.rs
Original file line number Diff line number Diff line change
Expand Up @@ -366,11 +366,11 @@ macro_rules! ImplSpiChannel {
}
}

impl DmaChannelConvert<AnyPdmaSpiChannel> for [<Spi $num DmaChannel>] {
fn degrade_rx(rx: SpiDmaRxChannelImpl<Self>) -> SpiDmaRxChannelImpl<AnySpiDmaChannel> {
impl DmaChannelConvert<AnySpiDmaChannel> for [<Spi $num DmaChannel>] {
fn degrade_rx(rx: SpiDmaRxChannelImpl<Self>) -> SpiDmaRxChannelImpl<AnySpiDmaChannelInner> {
SpiDmaRxChannelImpl(rx.0.into())
}
fn degrade_tx(tx: SpiDmaTxChannelImpl<Self>) -> SpiDmaTxChannelImpl<AnySpiDmaChannel> {
fn degrade_tx(tx: SpiDmaTxChannelImpl<Self>) -> SpiDmaTxChannelImpl<AnySpiDmaChannelInner> {
SpiDmaTxChannelImpl(tx.0.into())
}
}
Expand Down Expand Up @@ -908,32 +908,32 @@ where
}

/// A marker for SPI-compatible type-erased DMA channels.
pub struct AnyPdmaSpiChannel;
pub struct AnySpiDmaChannel;

impl crate::private::Sealed for AnyPdmaSpiChannel {}
impl crate::private::Sealed for AnySpiDmaChannel {}

impl DmaChannel for AnyPdmaSpiChannel {
type Rx = SpiDmaRxChannelImpl<AnySpiDmaChannel>;
type Tx = SpiDmaTxChannelImpl<AnySpiDmaChannel>;
impl DmaChannel for AnySpiDmaChannel {
type Rx = SpiDmaRxChannelImpl<AnySpiDmaChannelInner>;
type Tx = SpiDmaTxChannelImpl<AnySpiDmaChannelInner>;
}

crate::any_enum! {
#[doc(hidden)]
pub enum AnySpiDmaChannel {
pub enum AnySpiDmaChannelInner {
Spi2(Spi2DmaChannel),
Spi3(Spi3DmaChannel),
}
}

impl crate::private::Sealed for AnySpiDmaChannel {}
impl crate::private::Sealed for AnySpiDmaChannelInner {}

impl PdmaChannel for AnySpiDmaChannel {
impl PdmaChannel for AnySpiDmaChannelInner {
type RegisterBlock = SpiRegisterBlock;

delegate::delegate! {
to match self {
AnySpiDmaChannel::Spi2(channel) => channel,
AnySpiDmaChannel::Spi3(channel) => channel,
AnySpiDmaChannelInner::Spi2(channel) => channel,
AnySpiDmaChannelInner::Spi3(channel) => channel,
} {
fn register_block(&self) -> &SpiRegisterBlock;
fn tx_waker(&self) -> &'static AtomicWaker;
Expand Down
2 changes: 1 addition & 1 deletion esp-hal/src/spi/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ impl DmaEligible for AnySpi {
#[cfg(gdma)]
type Dma = crate::dma::AnyGdmaChannel;
#[cfg(pdma)]
type Dma = crate::dma::AnyPdmaSpiChannel;
type Dma = crate::dma::AnySpiDmaChannel;

fn dma_peripheral(&self) -> crate::dma::DmaPeripheral {
match &self.0 {
Expand Down

0 comments on commit 572fb23

Please sign in to comment.