diff --git a/esp-hal/src/dma/gdma.rs b/esp-hal/src/dma/gdma.rs index 96a599e15c0..14afac47089 100644 --- a/esp-hal/src/dma/gdma.rs +++ b/esp-hal/src/dma/gdma.rs @@ -277,7 +277,7 @@ impl RegisterAccess for Channel { result } - fn out_interrupts() -> EnumSet { + fn pending_out_interrupts() -> EnumSet { let mut result = EnumSet::new(); let int_raw = Self::out_int().raw().read(); @@ -364,7 +364,7 @@ impl RegisterAccess for Channel { result } - fn in_interrupts() -> EnumSet { + fn pending_in_interrupts() -> EnumSet { let mut result = EnumSet::new(); let int_raw = Self::in_int().raw().read(); diff --git a/esp-hal/src/dma/mod.rs b/esp-hal/src/dma/mod.rs index b723a8d2682..8375b85d87b 100644 --- a/esp-hal/src/dma/mod.rs +++ b/esp-hal/src/dma/mod.rs @@ -1030,7 +1030,10 @@ impl TxCircularState { where T: TxPrivate, { - if channel.out_interrupts().contains(DmaTxInterrupt::Eof) { + if channel + .pending_out_interrupts() + .contains(DmaTxInterrupt::Eof) + { channel.clear_out(DmaTxInterrupt::Eof); let descr_address = channel.last_out_dscr_address() as *mut DmaDescriptor; @@ -1282,22 +1285,23 @@ pub trait RxPrivate: crate::private::Sealed { fn clear_in(&self, interrupts: impl Into>); - fn in_interrupts(&self) -> EnumSet; + fn pending_in_interrupts(&self) -> EnumSet; fn is_done(&self) -> bool; fn has_error(&self) -> bool { - self.in_interrupts() + self.pending_in_interrupts() .contains(DmaRxInterrupt::DescriptorError) } fn has_dscr_empty_error(&self) -> bool { - self.in_interrupts() + self.pending_in_interrupts() .contains(DmaRxInterrupt::DescriptorEmpty) } fn has_eof_error(&self) -> bool { - self.in_interrupts().contains(DmaRxInterrupt::ErrorEof) + self.pending_in_interrupts() + .contains(DmaRxInterrupt::ErrorEof) } fn clear_interrupts(&self); @@ -1337,7 +1341,7 @@ where fn start_transfer(&mut self) -> Result<(), DmaError> { R::start_in(); - if R::in_interrupts().contains(DmaRxInterrupt::DescriptorError) { + if R::pending_in_interrupts().contains(DmaRxInterrupt::DescriptorError) { Err(DmaError::DescriptorError) } else { Ok(()) @@ -1467,12 +1471,13 @@ where CH::Channel::clear_in(interrupts); } - fn in_interrupts(&self) -> EnumSet { - CH::Channel::in_interrupts() + fn pending_in_interrupts(&self) -> EnumSet { + CH::Channel::pending_in_interrupts() } fn is_done(&self) -> bool { - self.in_interrupts().contains(DmaRxInterrupt::SuccessfulEof) + self.pending_in_interrupts() + .contains(DmaRxInterrupt::SuccessfulEof) } fn init_channel(&mut self) { @@ -1515,7 +1520,7 @@ pub trait TxPrivate: crate::private::Sealed { fn clear_out(&self, interrupts: impl Into>); - fn out_interrupts(&self) -> EnumSet; + fn pending_out_interrupts(&self) -> EnumSet; fn start_transfer(&mut self) -> Result<(), DmaError>; @@ -1523,11 +1528,12 @@ pub trait TxPrivate: crate::private::Sealed { fn set_ext_mem_block_size(&self, size: DmaExtMemBKSize); fn is_done(&self) -> bool { - self.out_interrupts().contains(DmaTxInterrupt::TotalEof) + self.pending_out_interrupts() + .contains(DmaTxInterrupt::TotalEof) } fn has_error(&self) -> bool { - self.out_interrupts() + self.pending_out_interrupts() .contains(DmaTxInterrupt::DescriptorError) } @@ -1566,7 +1572,7 @@ where fn start_transfer(&mut self) -> Result<(), DmaError> { R::start_out(); - if R::out_interrupts().contains(DmaTxInterrupt::DescriptorError) { + if R::pending_out_interrupts().contains(DmaTxInterrupt::DescriptorError) { Err(DmaError::DescriptorError) } else { Ok(()) @@ -1585,8 +1591,8 @@ where fn clear_out(&self, interrupts: impl Into>) { R::clear_out(interrupts) } - fn out_interrupts(&self) -> EnumSet { - R::out_interrupts() + fn pending_out_interrupts(&self) -> EnumSet { + R::pending_out_interrupts() } fn waker() -> &'static embassy_sync::waitqueue::AtomicWaker; @@ -1693,8 +1699,8 @@ where CH::Channel::clear_out(interrupts); } - fn out_interrupts(&self) -> EnumSet { - CH::Channel::out_interrupts() + fn pending_out_interrupts(&self) -> EnumSet { + CH::Channel::pending_out_interrupts() } fn waker() -> &'static embassy_sync::waitqueue::AtomicWaker { @@ -1729,13 +1735,13 @@ pub trait RegisterAccess: crate::private::Sealed { fn unlisten_out(interrupts: impl Into>); fn is_listening_out() -> EnumSet; fn clear_out(interrupts: impl Into>); - fn out_interrupts() -> EnumSet; + fn pending_out_interrupts() -> EnumSet; fn listen_in(interrupts: impl Into>); fn unlisten_in(interrupts: impl Into>); fn is_listening_in() -> EnumSet; fn clear_in(interrupts: impl Into>); - fn in_interrupts() -> EnumSet; + fn pending_in_interrupts() -> EnumSet; fn last_out_dscr_address() -> usize; @@ -2551,7 +2557,7 @@ where if self .instance .tx() - .out_interrupts() + .pending_out_interrupts() .contains(DmaTxInterrupt::DescriptorError) { Err(DmaError::DescriptorError) @@ -2604,7 +2610,7 @@ where if self .instance .rx() - .in_interrupts() + .pending_in_interrupts() .contains(DmaRxInterrupt::DescriptorError) { Err(DmaError::DescriptorError) @@ -2658,12 +2664,12 @@ where if self .instance .tx() - .out_interrupts() + .pending_out_interrupts() .contains(DmaTxInterrupt::DescriptorError) || self .instance .rx() - .in_interrupts() + .pending_in_interrupts() .contains(DmaRxInterrupt::DescriptorError) { Err(DmaError::DescriptorError) @@ -2741,7 +2747,7 @@ where if self .instance .tx() - .out_interrupts() + .pending_out_interrupts() .contains(DmaTxInterrupt::DescriptorError) { Err(DmaError::DescriptorError) @@ -2855,7 +2861,7 @@ pub(crate) mod asynch { Poll::Ready(Ok(())) } else if self .tx - .out_interrupts() + .pending_out_interrupts() .contains(DmaTxInterrupt::DescriptorError) { self.tx.clear_interrupts(); @@ -2909,7 +2915,7 @@ pub(crate) mod asynch { if self.rx.is_done() { self.rx.clear_interrupts(); Poll::Ready(Ok(())) - } else if !self.rx.in_interrupts().is_disjoint( + } else if !self.rx.pending_in_interrupts().is_disjoint( DmaRxInterrupt::DescriptorError | DmaRxInterrupt::DescriptorEmpty | DmaRxInterrupt::ErrorEof, @@ -2972,12 +2978,16 @@ pub(crate) mod asynch { cx: &mut core::task::Context<'_>, ) -> Poll { TX::waker().register(cx.waker()); - if self.tx.out_interrupts().contains(DmaTxInterrupt::Done) { + if self + .tx + .pending_out_interrupts() + .contains(DmaTxInterrupt::Done) + { self.tx.clear_out(DmaTxInterrupt::Done); Poll::Ready(Ok(())) } else if self .tx - .out_interrupts() + .pending_out_interrupts() .contains(DmaTxInterrupt::DescriptorError) { self.tx.clear_interrupts(); @@ -3032,10 +3042,14 @@ pub(crate) mod asynch { cx: &mut core::task::Context<'_>, ) -> Poll { RX::waker().register(cx.waker()); - if self.rx.in_interrupts().contains(DmaRxInterrupt::Done) { + if self + .rx + .pending_in_interrupts() + .contains(DmaRxInterrupt::Done) + { self.rx.clear_in(DmaRxInterrupt::Done); Poll::Ready(Ok(())) - } else if !self.rx.in_interrupts().is_disjoint( + } else if !self.rx.pending_in_interrupts().is_disjoint( DmaRxInterrupt::DescriptorError | DmaRxInterrupt::DescriptorEmpty | DmaRxInterrupt::ErrorEof, @@ -3070,7 +3084,7 @@ pub(crate) mod asynch { } fn handle_interrupt, Tx: TxChannel>() { - if Channel::in_interrupts().is_disjoint( + if Channel::pending_in_interrupts().is_disjoint( DmaRxInterrupt::DescriptorError | DmaRxInterrupt::DescriptorEmpty | DmaRxInterrupt::ErrorEof, @@ -3085,31 +3099,31 @@ pub(crate) mod asynch { Rx::waker().wake() } - if Channel::out_interrupts().contains(DmaTxInterrupt::DescriptorError) { + if Channel::pending_out_interrupts().contains(DmaTxInterrupt::DescriptorError) { Channel::unlisten_out( DmaTxInterrupt::DescriptorError | DmaTxInterrupt::TotalEof | DmaTxInterrupt::Done, ); Tx::waker().wake() } - if Channel::in_interrupts().contains(DmaRxInterrupt::SuccessfulEof) { + if Channel::pending_in_interrupts().contains(DmaRxInterrupt::SuccessfulEof) { Channel::unlisten_in(DmaRxInterrupt::SuccessfulEof); Rx::waker().wake() } - if Channel::in_interrupts().contains(DmaRxInterrupt::Done) { + if Channel::pending_in_interrupts().contains(DmaRxInterrupt::Done) { Channel::unlisten_in(DmaRxInterrupt::Done); Rx::waker().wake() } - if Channel::out_interrupts().contains(DmaTxInterrupt::TotalEof) + if Channel::pending_out_interrupts().contains(DmaTxInterrupt::TotalEof) && Channel::is_listening_out().contains(DmaTxInterrupt::TotalEof) { Channel::unlisten_out(DmaTxInterrupt::TotalEof); Tx::waker().wake() } - if Channel::out_interrupts().contains(DmaTxInterrupt::Done) { + if Channel::pending_out_interrupts().contains(DmaTxInterrupt::Done) { Channel::unlisten_out(DmaTxInterrupt::Done); Tx::waker().wake() } diff --git a/esp-hal/src/dma/pdma.rs b/esp-hal/src/dma/pdma.rs index d46ce062eec..f53c1c44e4a 100644 --- a/esp-hal/src/dma/pdma.rs +++ b/esp-hal/src/dma/pdma.rs @@ -187,7 +187,7 @@ macro_rules! ImplSpiChannel { result } - fn out_interrupts() -> EnumSet { + fn pending_out_interrupts() -> EnumSet { let mut result = EnumSet::new(); let spi = unsafe { &*crate::peripherals::[]::PTR }; @@ -279,7 +279,7 @@ macro_rules! ImplSpiChannel { result } - fn in_interrupts() -> EnumSet { + fn pending_in_interrupts() -> EnumSet { let mut result = EnumSet::new(); let spi = unsafe { &*crate::peripherals::[]::PTR }; @@ -571,7 +571,7 @@ macro_rules! ImplI2sChannel { result } - fn out_interrupts() -> EnumSet { + fn pending_out_interrupts() -> EnumSet { let mut result = EnumSet::new(); let reg_block = unsafe { &*crate::peripherals::[<$peripheral>]::PTR }; @@ -663,7 +663,7 @@ macro_rules! ImplI2sChannel { result } - fn in_interrupts() -> EnumSet { + fn pending_in_interrupts() -> EnumSet { let mut result = EnumSet::new(); let reg_block = unsafe { &*crate::peripherals::[<$peripheral>]::PTR };