aboutsummaryrefslogtreecommitdiff
path: root/embassy-stm32/src/dma/mod.rs
diff options
context:
space:
mode:
authorDario Nieuwenhuis <[email protected]>2022-04-26 23:57:26 +0200
committerDario Nieuwenhuis <[email protected]>2022-04-27 01:16:14 +0200
commit009bb8e4e1b7afbe9d9d7d89135f8d4dd3c4e808 (patch)
treed734f3e82f9fb3c22b7517a70e1f47969624d248 /embassy-stm32/src/dma/mod.rs
parenta39d796c3de9c96ea4df6b9da525cb0d5ef60fc0 (diff)
stm32: add stm32u5 GPDMA, SPIv4 support, add HIL tests.
Diffstat (limited to 'embassy-stm32/src/dma/mod.rs')
-rw-r--r--embassy-stm32/src/dma/mod.rs29
1 files changed, 25 insertions, 4 deletions
diff --git a/embassy-stm32/src/dma/mod.rs b/embassy-stm32/src/dma/mod.rs
index f96ccbf6e..c19f7b3c7 100644
--- a/embassy-stm32/src/dma/mod.rs
+++ b/embassy-stm32/src/dma/mod.rs
@@ -4,6 +4,8 @@ pub(crate) mod bdma;
4pub(crate) mod dma; 4pub(crate) mod dma;
5#[cfg(dmamux)] 5#[cfg(dmamux)]
6mod dmamux; 6mod dmamux;
7#[cfg(gpdma)]
8mod gpdma;
7 9
8#[cfg(dmamux)] 10#[cfg(dmamux)]
9pub use dmamux::*; 11pub use dmamux::*;
@@ -24,9 +26,9 @@ pub mod low_level {
24 26
25pub(crate) use transfers::*; 27pub(crate) use transfers::*;
26 28
27#[cfg(any(bdma_v2, dma_v2, dmamux))] 29#[cfg(any(bdma_v2, dma_v2, dmamux, gpdma))]
28pub type Request = u8; 30pub type Request = u8;
29#[cfg(not(any(bdma_v2, dma_v2, dmamux)))] 31#[cfg(not(any(bdma_v2, dma_v2, dmamux, gpdma)))]
30pub type Request = (); 32pub type Request = ();
31 33
32pub(crate) mod sealed { 34pub(crate) mod sealed {
@@ -118,11 +120,24 @@ pub(crate) mod sealed {
118 } 120 }
119} 121}
120 122
123#[derive(Debug, Copy, Clone, PartialEq, Eq)]
124#[cfg_attr(feature = "defmt", derive(defmt::Format))]
121pub enum WordSize { 125pub enum WordSize {
122 OneByte, 126 OneByte,
123 TwoBytes, 127 TwoBytes,
124 FourBytes, 128 FourBytes,
125} 129}
130
131impl WordSize {
132 pub fn bytes(&self) -> usize {
133 match self {
134 Self::OneByte => 1,
135 Self::TwoBytes => 2,
136 Self::FourBytes => 4,
137 }
138 }
139}
140
126pub trait Word: sealed::Word { 141pub trait Word: sealed::Word {
127 fn bits() -> WordSize; 142 fn bits() -> WordSize;
128} 143}
@@ -148,7 +163,8 @@ impl Word for u32 {
148 } 163 }
149} 164}
150 165
151#[derive(Debug, PartialEq)] 166#[derive(Debug, Copy, Clone, PartialEq, Eq)]
167#[cfg_attr(feature = "defmt", derive(defmt::Format))]
152pub enum Burst { 168pub enum Burst {
153 /// Single transfer 169 /// Single transfer
154 Single, 170 Single,
@@ -160,7 +176,8 @@ pub enum Burst {
160 Incr16, 176 Incr16,
161} 177}
162 178
163#[derive(Debug, PartialEq)] 179#[derive(Debug, Copy, Clone, PartialEq, Eq)]
180#[cfg_attr(feature = "defmt", derive(defmt::Format))]
164pub enum FlowControl { 181pub enum FlowControl {
165 /// Flow control by DMA 182 /// Flow control by DMA
166 Dma, 183 Dma,
@@ -168,6 +185,8 @@ pub enum FlowControl {
168 Peripheral, 185 Peripheral,
169} 186}
170 187
188#[derive(Debug, Copy, Clone, PartialEq, Eq)]
189#[cfg_attr(feature = "defmt", derive(defmt::Format))]
171pub struct TransferOptions { 190pub struct TransferOptions {
172 /// Peripheral burst transfer configuration 191 /// Peripheral burst transfer configuration
173 pub pburst: Burst, 192 pub pburst: Burst,
@@ -299,6 +318,8 @@ pub(crate) unsafe fn init() {
299 dma::init(); 318 dma::init();
300 #[cfg(dmamux)] 319 #[cfg(dmamux)]
301 dmamux::init(); 320 dmamux::init();
321 #[cfg(gpdma)]
322 gpdma::init();
302} 323}
303 324
304// TODO: replace transmutes with core::ptr::metadata once it's stable 325// TODO: replace transmutes with core::ptr::metadata once it's stable