From 62eb675a3f3c8edeae7b0da1f9171b36d6d2509e Mon Sep 17 00:00:00 2001 From: Grant Miller Date: Tue, 18 Oct 2022 23:28:39 -0500 Subject: [PATCH] stm32/dma: Remove channel index tracking --- embassy-stm32/build.rs | 27 +++------------------------ embassy-stm32/src/dma/bdma.rs | 4 ++-- embassy-stm32/src/dma/dma.rs | 2 +- embassy-stm32/src/dma/dmamux.rs | 2 +- embassy-stm32/src/dma/gpdma.rs | 2 +- 5 files changed, 8 insertions(+), 29 deletions(-) diff --git a/embassy-stm32/build.rs b/embassy-stm32/build.rs index a4709f4c..f31b6e35 100644 --- a/embassy-stm32/build.rs +++ b/embassy-stm32/build.rs @@ -602,29 +602,15 @@ fn main() { } } - let mut dma_channel_count: usize = 0; - let mut bdma_channel_count: usize = 0; - let mut gpdma_channel_count: usize = 0; - for ch in METADATA.dma_channels { let mut row = Vec::new(); let dma_peri = METADATA.peripherals.iter().find(|p| p.name == ch.dma).unwrap(); let bi = dma_peri.registers.as_ref().unwrap(); - let num; match bi.kind { - "dma" => { - num = dma_channel_count; - dma_channel_count += 1; - } - "bdma" => { - num = bdma_channel_count; - bdma_channel_count += 1; - } - "gpdma" => { - num = gpdma_channel_count; - gpdma_channel_count += 1; - } + "dma" => {} + "bdma" => {} + "gpdma" => {} _ => panic!("bad dma channel kind {}", bi.kind), } @@ -632,7 +618,6 @@ fn main() { row.push(ch.dma.to_string()); row.push(bi.kind.to_string()); row.push(ch.channel.to_string()); - row.push(num.to_string()); if let Some(dmamux) = &ch.dmamux { let dmamux_channel = ch.dmamux_channel.unwrap(); row.push(format!("{{dmamux: {}, dmamux_channel: {}}}", dmamux, dmamux_channel)); @@ -643,12 +628,6 @@ fn main() { dma_channels_table.push(row); } - g.extend(quote! { - pub(crate) const DMA_CHANNEL_COUNT: usize = #dma_channel_count; - pub(crate) const BDMA_CHANNEL_COUNT: usize = #bdma_channel_count; - pub(crate) const GPDMA_CHANNEL_COUNT: usize = #gpdma_channel_count; - }); - for irq in METADATA.interrupts { let name = irq.name.to_ascii_uppercase(); interrupts_table.push(vec![name.clone()]); diff --git a/embassy-stm32/src/dma/bdma.rs b/embassy-stm32/src/dma/bdma.rs index 94c15811..7dce789d 100644 --- a/embassy-stm32/src/dma/bdma.rs +++ b/embassy-stm32/src/dma/bdma.rs @@ -32,10 +32,10 @@ pub(crate) unsafe fn init() { } foreach_dma_channel! { - ($channel_peri:ident, BDMA1, bdma, $channel_num:expr, $index:expr, $dmamux:tt) => { + ($channel_peri:ident, BDMA1, bdma, $channel_num:expr, $dmamux:tt) => { // BDMA1 in H7 doesn't use DMAMUX, which breaks }; - ($channel_peri:ident, $dma_peri:ident, bdma, $channel_num:expr, $index:expr, $dmamux:tt) => { + ($channel_peri:ident, $dma_peri:ident, bdma, $channel_num:expr, $dmamux:tt) => { impl crate::peripherals::$channel_peri { fn waker() -> &'static AtomicWaker { static WAKER: AtomicWaker = AtomicWaker::new(); diff --git a/embassy-stm32/src/dma/dma.rs b/embassy-stm32/src/dma/dma.rs index 825c4a5d..353a11cd 100644 --- a/embassy-stm32/src/dma/dma.rs +++ b/embassy-stm32/src/dma/dma.rs @@ -49,7 +49,7 @@ pub(crate) unsafe fn init() { } foreach_dma_channel! { - ($channel_peri:ident, $dma_peri:ident, dma, $channel_num:expr, $index:expr, $dmamux:tt) => { + ($channel_peri:ident, $dma_peri:ident, dma, $channel_num:expr, $dmamux:tt) => { impl crate::peripherals::$channel_peri { fn waker() -> &'static AtomicWaker { static WAKER: AtomicWaker = AtomicWaker::new(); diff --git a/embassy-stm32/src/dma/dmamux.rs b/embassy-stm32/src/dma/dmamux.rs index e9967e34..06887e62 100644 --- a/embassy-stm32/src/dma/dmamux.rs +++ b/embassy-stm32/src/dma/dmamux.rs @@ -31,7 +31,7 @@ pub trait MuxChannel: sealed::MuxChannel + super::Channel { } foreach_dma_channel! { - ($channel_peri:ident, $dma_peri:ident, $version:ident, $channel_num:expr, $index:expr, {dmamux: $dmamux:ident, dmamux_channel: $dmamux_channel:expr}) => { + ($channel_peri:ident, $dma_peri:ident, $version:ident, $channel_num:expr, {dmamux: $dmamux:ident, dmamux_channel: $dmamux_channel:expr}) => { impl sealed::MuxChannel for peripherals::$channel_peri { const DMAMUX_CH_NUM: u8 = $dmamux_channel; const DMAMUX_REGS: pac::dmamux::Dmamux = pac::$dmamux; diff --git a/embassy-stm32/src/dma/gpdma.rs b/embassy-stm32/src/dma/gpdma.rs index 1103d0d3..fa8fce38 100644 --- a/embassy-stm32/src/dma/gpdma.rs +++ b/embassy-stm32/src/dma/gpdma.rs @@ -29,7 +29,7 @@ pub(crate) unsafe fn init() { } foreach_dma_channel! { - ($channel_peri:ident, $dma_peri:ident, gpdma, $channel_num:expr, $index:expr, $dmamux:tt) => { + ($channel_peri:ident, $dma_peri:ident, gpdma, $channel_num:expr, $dmamux:tt) => { impl crate::peripherals::$channel_peri { fn waker() -> &'static AtomicWaker { static WAKER: AtomicWaker = AtomicWaker::new();