Skip to content

Commit

Permalink
Reset channel async status when re-creating
Browse files Browse the repository at this point in the history
  • Loading branch information
bugadani committed Nov 14, 2024
1 parent 30532f6 commit 06cf7df
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
14 changes: 14 additions & 0 deletions esp-hal/src/dma/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1679,6 +1679,13 @@ where
// channel was previously used for a mem2mem transfer.
rx_impl.set_mem2mem_mode(false);

if let Some(interrupt) = rx_impl.peripheral_interrupt() {
for cpu in Cpu::all() {
crate::interrupt::disable(cpu, interrupt);
}
}
rx_impl.set_async(false);

Self {
burst_mode: false,
rx_impl,
Expand Down Expand Up @@ -1962,6 +1969,13 @@ where
CH: DmaChannel,
{
fn new(tx_impl: CH::Tx) -> Self {
if let Some(interrupt) = tx_impl.peripheral_interrupt() {
for cpu in Cpu::all() {
crate::interrupt::disable(cpu, interrupt);
}
}
tx_impl.set_async(false);

Self {
burst_mode: false,
tx_impl,
Expand Down
12 changes: 12 additions & 0 deletions esp-hal/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -398,6 +398,18 @@ impl Cpu {
}
}
}

/// Returns an iterator over all cores.
#[inline(always)]
pub fn all() -> impl Iterator<Item = Self> {
cfg_if::cfg_if! {
if #[cfg(multi_core)] {
[Cpu::ProCpu, Cpu::AppCpu].into_iter()
} else {
[Cpu::ProCpu].into_iter()
}
}
}
}

/// Returns the raw value of the mhartid register.
Expand Down

0 comments on commit 06cf7df

Please sign in to comment.