aboutsummaryrefslogtreecommitdiff
path: root/embassy-stm32/src/dma/mod.rs
diff options
context:
space:
mode:
authorDario Nieuwenhuis <[email protected]>2025-03-26 16:01:37 +0100
committerDario Nieuwenhuis <[email protected]>2025-03-27 15:18:06 +0100
commitd41eeeae79388f219bf6a84e2f7bde9f6b532516 (patch)
tree678b6fc732216e529dc38e6f65b72a309917ac32 /embassy-stm32/src/dma/mod.rs
parent9edf5b7f049f95742b60b041e4443967d8a6b708 (diff)
Remove Peripheral trait, rename PeripheralRef->Peri.
Diffstat (limited to 'embassy-stm32/src/dma/mod.rs')
-rw-r--r--embassy-stm32/src/dma/mod.rs20
1 files changed, 6 insertions, 14 deletions
diff --git a/embassy-stm32/src/dma/mod.rs b/embassy-stm32/src/dma/mod.rs
index ac4a0f98e..d3b070a6d 100644
--- a/embassy-stm32/src/dma/mod.rs
+++ b/embassy-stm32/src/dma/mod.rs
@@ -22,7 +22,7 @@ pub(crate) use util::*;
22pub(crate) mod ringbuffer; 22pub(crate) mod ringbuffer;
23pub mod word; 23pub mod word;
24 24
25use embassy_hal_internal::{impl_peripheral, Peripheral}; 25use embassy_hal_internal::{impl_peripheral, PeripheralType};
26 26
27use crate::interrupt; 27use crate::interrupt;
28 28
@@ -51,17 +51,7 @@ pub(crate) trait ChannelInterrupt {
51 51
52/// DMA channel. 52/// DMA channel.
53#[allow(private_bounds)] 53#[allow(private_bounds)]
54pub trait Channel: SealedChannel + Peripheral<P = Self> + Into<AnyChannel> + 'static { 54pub trait Channel: SealedChannel + PeripheralType + Into<AnyChannel> + 'static {}
55 /// Type-erase (degrade) this pin into an `AnyChannel`.
56 ///
57 /// This converts DMA channel singletons (`DMA1_CH3`, `DMA2_CH1`, ...), which
58 /// are all different types, into the same type. It is useful for
59 /// creating arrays of channels, or avoiding generics.
60 #[inline]
61 fn degrade(self) -> AnyChannel {
62 AnyChannel { id: self.id() }
63 }
64}
65 55
66macro_rules! dma_channel_impl { 56macro_rules! dma_channel_impl {
67 ($channel_peri:ident, $index:expr) => { 57 ($channel_peri:ident, $index:expr) => {
@@ -79,8 +69,10 @@ macro_rules! dma_channel_impl {
79 impl crate::dma::Channel for crate::peripherals::$channel_peri {} 69 impl crate::dma::Channel for crate::peripherals::$channel_peri {}
80 70
81 impl From<crate::peripherals::$channel_peri> for crate::dma::AnyChannel { 71 impl From<crate::peripherals::$channel_peri> for crate::dma::AnyChannel {
82 fn from(x: crate::peripherals::$channel_peri) -> Self { 72 fn from(val: crate::peripherals::$channel_peri) -> Self {
83 crate::dma::Channel::degrade(x) 73 Self {
74 id: crate::dma::SealedChannel::id(&val),
75 }
84 } 76 }
85 } 77 }
86 }; 78 };