diff options
| author | Dario Nieuwenhuis <[email protected]> | 2022-04-26 23:57:26 +0200 |
|---|---|---|
| committer | Dario Nieuwenhuis <[email protected]> | 2022-04-27 01:16:14 +0200 |
| commit | 009bb8e4e1b7afbe9d9d7d89135f8d4dd3c4e808 (patch) | |
| tree | d734f3e82f9fb3c22b7517a70e1f47969624d248 /embassy-stm32/src/dma/mod.rs | |
| parent | a39d796c3de9c96ea4df6b9da525cb0d5ef60fc0 (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.rs | 29 |
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; | |||
| 4 | pub(crate) mod dma; | 4 | pub(crate) mod dma; |
| 5 | #[cfg(dmamux)] | 5 | #[cfg(dmamux)] |
| 6 | mod dmamux; | 6 | mod dmamux; |
| 7 | #[cfg(gpdma)] | ||
| 8 | mod gpdma; | ||
| 7 | 9 | ||
| 8 | #[cfg(dmamux)] | 10 | #[cfg(dmamux)] |
| 9 | pub use dmamux::*; | 11 | pub use dmamux::*; |
| @@ -24,9 +26,9 @@ pub mod low_level { | |||
| 24 | 26 | ||
| 25 | pub(crate) use transfers::*; | 27 | pub(crate) use transfers::*; |
| 26 | 28 | ||
| 27 | #[cfg(any(bdma_v2, dma_v2, dmamux))] | 29 | #[cfg(any(bdma_v2, dma_v2, dmamux, gpdma))] |
| 28 | pub type Request = u8; | 30 | pub type Request = u8; |
| 29 | #[cfg(not(any(bdma_v2, dma_v2, dmamux)))] | 31 | #[cfg(not(any(bdma_v2, dma_v2, dmamux, gpdma)))] |
| 30 | pub type Request = (); | 32 | pub type Request = (); |
| 31 | 33 | ||
| 32 | pub(crate) mod sealed { | 34 | pub(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))] | ||
| 121 | pub enum WordSize { | 125 | pub enum WordSize { |
| 122 | OneByte, | 126 | OneByte, |
| 123 | TwoBytes, | 127 | TwoBytes, |
| 124 | FourBytes, | 128 | FourBytes, |
| 125 | } | 129 | } |
| 130 | |||
| 131 | impl 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 | |||
| 126 | pub trait Word: sealed::Word { | 141 | pub 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))] | ||
| 152 | pub enum Burst { | 168 | pub 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))] | ||
| 164 | pub enum FlowControl { | 181 | pub 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))] | ||
| 171 | pub struct TransferOptions { | 190 | pub 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 |
