Skip to content

Commit e2a03d2

Browse files
committed
fix: revert accidental deletion
1 parent 12dbfe9 commit e2a03d2

File tree

2 files changed

+61
-0
lines changed

2 files changed

+61
-0
lines changed

esp-hal/src/dma/mod.rs

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2745,6 +2745,63 @@ pub(crate) mod asynch {
27452745

27462746
use super::*;
27472747

2748+
#[must_use = "futures do nothing unless you `.await` or poll them"]
2749+
pub struct DmaTxFuture<'a, CH>
2750+
where
2751+
CH: DmaTxChannel,
2752+
{
2753+
pub(crate) tx: &'a mut ChannelTx<Async, CH>,
2754+
}
2755+
2756+
impl<'a, CH> DmaTxFuture<'a, CH>
2757+
where
2758+
CH: DmaTxChannel,
2759+
{
2760+
#[cfg_attr(esp32c2, allow(dead_code))]
2761+
pub fn new(tx: &'a mut ChannelTx<Async, CH>) -> Self {
2762+
Self { tx }
2763+
}
2764+
}
2765+
2766+
impl<CH> core::future::Future for DmaTxFuture<'_, CH>
2767+
where
2768+
CH: DmaTxChannel,
2769+
{
2770+
type Output = Result<(), DmaError>;
2771+
2772+
fn poll(
2773+
self: core::pin::Pin<&mut Self>,
2774+
cx: &mut core::task::Context<'_>,
2775+
) -> Poll<Self::Output> {
2776+
if self.tx.is_done() {
2777+
self.tx.clear_interrupts();
2778+
Poll::Ready(Ok(()))
2779+
} else if self
2780+
.tx
2781+
.pending_out_interrupts()
2782+
.contains(DmaTxInterrupt::DescriptorError)
2783+
{
2784+
self.tx.clear_interrupts();
2785+
Poll::Ready(Err(DmaError::DescriptorError))
2786+
} else {
2787+
self.tx.waker().register(cx.waker());
2788+
self.tx
2789+
.listen_out(DmaTxInterrupt::TotalEof | DmaTxInterrupt::DescriptorError);
2790+
Poll::Pending
2791+
}
2792+
}
2793+
}
2794+
2795+
impl<CH> Drop for DmaTxFuture<'_, CH>
2796+
where
2797+
CH: DmaTxChannel,
2798+
{
2799+
fn drop(&mut self) {
2800+
self.tx
2801+
.unlisten_out(DmaTxInterrupt::TotalEof | DmaTxInterrupt::DescriptorError);
2802+
}
2803+
}
2804+
27482805
#[must_use = "futures do nothing unless you `.await` or poll them"]
27492806
pub struct DmaRxFuture<'a, CH>
27502807
where

esp-hal/src/i2s/master.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -435,6 +435,7 @@ where
435435
self.i2s.reset_tx();
436436

437437
// Enable corresponding interrupts if needed
438+
#[cfg(not(any(esp32, esp32s2)))]
438439
self.i2s.listen(I2sInterrupt::TxDone);
439440

440441
// configure DMA outlink
@@ -497,6 +498,7 @@ where
497498
self.i2s.reset_rx();
498499

499500
// Enable corresponding interrupts if needed
501+
#[cfg(not(any(esp32, esp32s2)))]
500502
self.i2s.listen(I2sInterrupt::RxDone);
501503

502504
// configure DMA inlink
@@ -558,6 +560,7 @@ impl<'d, Dm: DriverMode, BUFFER: DmaTxBuffer> I2sWriteDmaTransfer<'d, Dm, BUFFER
558560
}
559561

560562
/// Checks if the DMA transfer is done.
563+
#[cfg(not(any(esp32, esp32s2)))]
561564
pub fn is_done(&self) -> bool {
562565
self.i2s_tx.i2s.interrupts().contains(I2sInterrupt::TxDone)
563566
}
@@ -633,6 +636,7 @@ impl<'d, Dm: DriverMode, BUFFER: DmaRxBuffer> I2sReadDmaTransfer<'d, Dm, BUFFER>
633636
}
634637

635638
/// Returns true if the transfer is done.
639+
#[cfg(not(any(esp32, esp32s2)))]
636640
pub fn is_done(&self) -> bool {
637641
self.i2s_rx.i2s.interrupts().contains(I2sInterrupt::RxDone)
638642
}

0 commit comments

Comments
 (0)