aboutsummaryrefslogtreecommitdiff
path: root/embassy-stm32/src/dma/mod.rs
diff options
context:
space:
mode:
Diffstat (limited to 'embassy-stm32/src/dma/mod.rs')
-rw-r--r--embassy-stm32/src/dma/mod.rs44
1 files changed, 18 insertions, 26 deletions
diff --git a/embassy-stm32/src/dma/mod.rs b/embassy-stm32/src/dma/mod.rs
index efb324fa6..05d9c2e51 100644
--- a/embassy-stm32/src/dma/mod.rs
+++ b/embassy-stm32/src/dma/mod.rs
@@ -25,7 +25,7 @@ pub(crate) use util::*;
25pub(crate) mod ringbuffer; 25pub(crate) mod ringbuffer;
26pub mod word; 26pub mod word;
27 27
28use embassy_hal_internal::{Peri, PeripheralType, impl_peripheral}; 28use embassy_hal_internal::{PeripheralType, impl_peripheral};
29 29
30use crate::interrupt; 30use crate::interrupt;
31use crate::rcc::StoppablePeripheral; 31use crate::rcc::StoppablePeripheral;
@@ -47,21 +47,10 @@ pub type Request = u8;
47#[cfg(not(any(dma_v2, bdma_v2, gpdma, dmamux)))] 47#[cfg(not(any(dma_v2, bdma_v2, gpdma, dmamux)))]
48pub type Request = (); 48pub type Request = ();
49 49
50impl<'a> StoppablePeripheral for Peri<'a, AnyChannel> { 50pub(crate) trait SealedChannel: StoppablePeripheral {
51 #[cfg(feature = "low-power")]
52 fn stop_mode(&self) -> crate::rcc::StopMode {
53 self.stop_mode
54 }
55}
56
57pub(crate) trait SealedChannel {
58 #[cfg(not(stm32n6))]
59 fn id(&self) -> u8; 51 fn id(&self) -> u8;
60 #[cfg(feature = "low-power")]
61 fn stop_mode(&self) -> crate::rcc::StopMode;
62} 52}
63 53
64#[cfg(not(stm32n6))]
65pub(crate) trait ChannelInterrupt { 54pub(crate) trait ChannelInterrupt {
66 #[cfg_attr(not(feature = "rt"), allow(unused))] 55 #[cfg_attr(not(feature = "rt"), allow(unused))]
67 unsafe fn on_irq(); 56 unsafe fn on_irq();
@@ -71,19 +60,21 @@ pub(crate) trait ChannelInterrupt {
71#[allow(private_bounds)] 60#[allow(private_bounds)]
72pub trait Channel: SealedChannel + PeripheralType + Into<AnyChannel> + 'static {} 61pub trait Channel: SealedChannel + PeripheralType + Into<AnyChannel> + 'static {}
73 62
74#[cfg(not(stm32n6))]
75macro_rules! dma_channel_impl { 63macro_rules! dma_channel_impl {
76 ($channel_peri:ident, $index:expr, $stop_mode:ident) => { 64 ($channel_peri:ident, $index:expr, $stop_mode:ident) => {
77 impl crate::dma::SealedChannel for crate::peripherals::$channel_peri { 65 impl crate::rcc::StoppablePeripheral for crate::peripherals::$channel_peri {
78 fn id(&self) -> u8 {
79 $index
80 }
81
82 #[cfg(feature = "low-power")] 66 #[cfg(feature = "low-power")]
83 fn stop_mode(&self) -> crate::rcc::StopMode { 67 fn stop_mode(&self) -> crate::rcc::StopMode {
84 crate::rcc::StopMode::$stop_mode 68 crate::rcc::StopMode::$stop_mode
85 } 69 }
86 } 70 }
71
72 impl crate::dma::SealedChannel for crate::peripherals::$channel_peri {
73 fn id(&self) -> u8 {
74 $index
75 }
76 }
77
87 impl crate::dma::ChannelInterrupt for crate::peripherals::$channel_peri { 78 impl crate::dma::ChannelInterrupt for crate::peripherals::$channel_peri {
88 unsafe fn on_irq() { 79 unsafe fn on_irq() {
89 crate::dma::AnyChannel { 80 crate::dma::AnyChannel {
@@ -102,7 +93,7 @@ macro_rules! dma_channel_impl {
102 Self { 93 Self {
103 id: crate::dma::SealedChannel::id(&val), 94 id: crate::dma::SealedChannel::id(&val),
104 #[cfg(feature = "low-power")] 95 #[cfg(feature = "low-power")]
105 stop_mode: crate::dma::SealedChannel::stop_mode(&val), 96 stop_mode: crate::rcc::StoppablePeripheral::stop_mode(&val),
106 } 97 }
107 } 98 }
108 } 99 }
@@ -123,17 +114,18 @@ impl AnyChannel {
123 } 114 }
124} 115}
125 116
126impl SealedChannel for AnyChannel { 117impl StoppablePeripheral for AnyChannel {
127 #[cfg(not(stm32n6))]
128 fn id(&self) -> u8 {
129 self.id
130 }
131
132 #[cfg(feature = "low-power")] 118 #[cfg(feature = "low-power")]
133 fn stop_mode(&self) -> crate::rcc::StopMode { 119 fn stop_mode(&self) -> crate::rcc::StopMode {
134 self.stop_mode 120 self.stop_mode
135 } 121 }
136} 122}
123
124impl SealedChannel for AnyChannel {
125 fn id(&self) -> u8 {
126 self.id
127 }
128}
137impl Channel for AnyChannel {} 129impl Channel for AnyChannel {}
138 130
139const CHANNEL_COUNT: usize = crate::_generated::DMA_CHANNELS.len(); 131const CHANNEL_COUNT: usize = crate::_generated::DMA_CHANNELS.len();