aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--embassy-stm32/src/dma/dma_bdma.rs91
1 files changed, 39 insertions, 52 deletions
diff --git a/embassy-stm32/src/dma/dma_bdma.rs b/embassy-stm32/src/dma/dma_bdma.rs
index 5b3243de7..7b5b3cf58 100644
--- a/embassy-stm32/src/dma/dma_bdma.rs
+++ b/embassy-stm32/src/dma/dma_bdma.rs
@@ -10,8 +10,7 @@ use super::ringbuffer::{DmaCtrl, OverrunError, ReadableDmaRingBuffer, WritableDm
10use super::word::{Word, WordSize}; 10use super::word::{Word, WordSize};
11use super::{AnyChannel, Channel, Dir, Request, STATE}; 11use super::{AnyChannel, Channel, Dir, Request, STATE};
12use crate::interrupt::typelevel::Interrupt; 12use crate::interrupt::typelevel::Interrupt;
13use crate::interrupt; 13use crate::{interrupt, pac};
14use crate::pac;
15 14
16pub(crate) struct ChannelInfo { 15pub(crate) struct ChannelInfo {
17 pub(crate) dma: DmaInfo, 16 pub(crate) dma: DmaInfo,
@@ -78,6 +77,44 @@ impl Default for TransferOptions {
78 } 77 }
79} 78}
80 79
80/// DMA request priority
81#[derive(Debug, Copy, Clone, PartialEq, Eq)]
82#[cfg_attr(feature = "defmt", derive(defmt::Format))]
83pub enum Priority {
84 /// Low Priority
85 Low,
86 /// Medium Priority
87 Medium,
88 /// High Priority
89 High,
90 /// Very High Priority
91 VeryHigh,
92}
93
94#[cfg(dma)]
95impl From<Priority> for pac::dma::vals::Pl {
96 fn from(value: Priority) -> Self {
97 match value {
98 Priority::Low => pac::dma::vals::Pl::LOW,
99 Priority::Medium => pac::dma::vals::Pl::MEDIUM,
100 Priority::High => pac::dma::vals::Pl::HIGH,
101 Priority::VeryHigh => pac::dma::vals::Pl::VERYHIGH,
102 }
103 }
104}
105
106#[cfg(bdma)]
107impl From<Priority> for pac::bdma::vals::Pl {
108 fn from(value: Priority) -> Self {
109 match value {
110 Priority::Low => pac::bdma::vals::Pl::LOW,
111 Priority::Medium => pac::bdma::vals::Pl::MEDIUM,
112 Priority::High => pac::bdma::vals::Pl::HIGH,
113 Priority::VeryHigh => pac::bdma::vals::Pl::VERYHIGH,
114 }
115 }
116}
117
81#[cfg(dma)] 118#[cfg(dma)]
82pub use dma_only::*; 119pub use dma_only::*;
83#[cfg(dma)] 120#[cfg(dma)]
@@ -173,31 +210,6 @@ mod dma_only {
173 } 210 }
174 } 211 }
175 } 212 }
176
177 /// DMA request priority
178 #[derive(Debug, Copy, Clone, PartialEq, Eq)]
179 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
180 pub enum Priority {
181 /// Low Priority
182 Low,
183 /// Medium Priority
184 Medium,
185 /// High Priority
186 High,
187 /// Very High Priority
188 VeryHigh,
189 }
190
191 impl From<Priority> for vals::Pl {
192 fn from(value: Priority) -> Self {
193 match value {
194 Priority::Low => vals::Pl::LOW,
195 Priority::Medium => vals::Pl::MEDIUM,
196 Priority::High => vals::Pl::HIGH,
197 Priority::VeryHigh => vals::Pl::VERYHIGH,
198 }
199 }
200 }
201} 213}
202 214
203#[cfg(bdma)] 215#[cfg(bdma)]
@@ -224,31 +236,6 @@ mod bdma_only {
224 } 236 }
225 } 237 }
226 } 238 }
227
228 /// DMA request priority
229 #[derive(Debug, Copy, Clone, PartialEq, Eq)]
230 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
231 pub enum Priority {
232 /// Low Priority
233 Low,
234 /// Medium Priority
235 Medium,
236 /// High Priority
237 High,
238 /// Very High Priority
239 VeryHigh,
240 }
241
242 impl From<Priority> for vals::Pl {
243 fn from(value: Priority) -> Self {
244 match value {
245 Priority::Low => vals::Pl::LOW,
246 Priority::Medium => vals::Pl::MEDIUM,
247 Priority::High => vals::Pl::HIGH,
248 Priority::VeryHigh => vals::Pl::VERYHIGH,
249 }
250 }
251 }
252} 239}
253 240
254pub(crate) struct ChannelState { 241pub(crate) struct ChannelState {