aboutsummaryrefslogtreecommitdiff
path: root/embassy-stm32/src/dma/mod.rs
diff options
context:
space:
mode:
authorBob McWhirter <[email protected]>2021-06-03 14:53:48 -0400
committerBob McWhirter <[email protected]>2021-06-03 14:53:48 -0400
commitb4dca64e206dfc01fde98b6b4cc2b0a05245bc0d (patch)
tree4fe9829d6807dee273e11f776f03bee0d07802d7 /embassy-stm32/src/dma/mod.rs
parent240616aa7238941afb0c663e3adfab3950257538 (diff)
Move most of DMA out of gen.py.
Diffstat (limited to 'embassy-stm32/src/dma/mod.rs')
-rw-r--r--embassy-stm32/src/dma/mod.rs29
1 files changed, 27 insertions, 2 deletions
diff --git a/embassy-stm32/src/dma/mod.rs b/embassy-stm32/src/dma/mod.rs
index aef31ce74..773cdc8b8 100644
--- a/embassy-stm32/src/dma/mod.rs
+++ b/embassy-stm32/src/dma/mod.rs
@@ -8,6 +8,7 @@ mod _version;
8pub use _version::*; 8pub use _version::*;
9 9
10use crate::pac; 10use crate::pac;
11use crate::peripherals;
11 12
12pub(crate) mod sealed { 13pub(crate) mod sealed {
13 use super::*; 14 use super::*;
@@ -31,8 +32,8 @@ pub trait Channel: sealed::Channel + Sized {}
31 32
32macro_rules! impl_dma_channel { 33macro_rules! impl_dma_channel {
33 ($type:ident, $dma_num:expr, $ch_num:expr) => { 34 ($type:ident, $dma_num:expr, $ch_num:expr) => {
34 impl crate::dma::Channel for peripherals::$type {} 35 impl Channel for peripherals::$type {}
35 impl crate::dma::sealed::Channel for peripherals::$type { 36 impl sealed::Channel for peripherals::$type {
36 #[inline] 37 #[inline]
37 fn num(&self) -> u8 { 38 fn num(&self) -> u8 {
38 $dma_num * 8 + $ch_num 39 $dma_num * 8 + $ch_num
@@ -40,3 +41,27 @@ macro_rules! impl_dma_channel {
40 } 41 }
41 }; 42 };
42} 43}
44
45crate::pac::peripherals!(
46 (dma,DMA1) => {
47 impl_dma_channel!(DMA1_CH0, 0, 0);
48 impl_dma_channel!(DMA1_CH1, 0, 1);
49 impl_dma_channel!(DMA1_CH2, 0, 2);
50 impl_dma_channel!(DMA1_CH3, 0, 3);
51 impl_dma_channel!(DMA1_CH4, 0, 4);
52 impl_dma_channel!(DMA1_CH5, 0, 5);
53 impl_dma_channel!(DMA1_CH6, 0, 6);
54 impl_dma_channel!(DMA1_CH7, 0, 7);
55 };
56
57 (dma,DMA2) => {
58 impl_dma_channel!(DMA2_CH0, 1, 0);
59 impl_dma_channel!(DMA2_CH1, 1, 1);
60 impl_dma_channel!(DMA2_CH2, 1, 2);
61 impl_dma_channel!(DMA2_CH3, 1, 3);
62 impl_dma_channel!(DMA2_CH4, 1, 4);
63 impl_dma_channel!(DMA2_CH5, 1, 5);
64 impl_dma_channel!(DMA2_CH6, 1, 6);
65 impl_dma_channel!(DMA2_CH7, 1, 7);
66 };
67);