aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorelagil <[email protected]>2025-08-25 21:10:59 +0200
committerDario Nieuwenhuis <[email protected]>2025-09-05 14:43:29 +0200
commit1541f1e0c2c3b2f8d5e5764966393eedac95ebf0 (patch)
tree6f3b6cb620bebb13eab445d08fce7d8095f94dc8
parentbe881875917b93a8cdb7a4ab07876e1239fbe1be (diff)
chore: clean up transfer options
-rw-r--r--embassy-stm32/src/dma/gpdma/linked_list.rs18
-rw-r--r--embassy-stm32/src/dma/gpdma/mod.rs2
-rw-r--r--embassy-stm32/src/dma/gpdma/ringbuffered.rs22
3 files changed, 6 insertions, 36 deletions
diff --git a/embassy-stm32/src/dma/gpdma/linked_list.rs b/embassy-stm32/src/dma/gpdma/linked_list.rs
index b0c0dffad..b0cf96f96 100644
--- a/embassy-stm32/src/dma/gpdma/linked_list.rs
+++ b/embassy-stm32/src/dma/gpdma/linked_list.rs
@@ -4,7 +4,6 @@
4use stm32_metapac::gpdma::regs; 4use stm32_metapac::gpdma::regs;
5use stm32_metapac::gpdma::vals::Dreq; 5use stm32_metapac::gpdma::vals::Dreq;
6 6
7use super::TransferOptions;
8use crate::dma::word::{Word, WordSize}; 7use crate::dma::word::{Word, WordSize};
9use crate::dma::{Dir, Request}; 8use crate::dma::{Dir, Request};
10 9
@@ -42,12 +41,7 @@ pub struct LinearItem {
42 41
43impl LinearItem { 42impl LinearItem {
44 /// Create a new read DMA transfer (peripheral to memory). 43 /// Create a new read DMA transfer (peripheral to memory).
45 pub unsafe fn new_read<'d, W: Word>( 44 pub unsafe fn new_read<'d, W: Word>(request: Request, peri_addr: *mut W, buf: &'d mut [W]) -> Self {
46 request: Request,
47 peri_addr: *mut W,
48 buf: &'d mut [W],
49 options: TransferOptions,
50 ) -> Self {
51 Self::new_inner( 45 Self::new_inner(
52 request, 46 request,
53 Dir::PeripheralToMemory, 47 Dir::PeripheralToMemory,
@@ -57,17 +51,11 @@ impl LinearItem {
57 true, 51 true,
58 W::size(), 52 W::size(),
59 W::size(), 53 W::size(),
60 options,
61 ) 54 )
62 } 55 }
63 56
64 /// Create a new write DMA transfer (memory to peripheral). 57 /// Create a new write DMA transfer (memory to peripheral).
65 pub unsafe fn new_write<'d, MW: Word, PW: Word>( 58 pub unsafe fn new_write<'d, MW: Word, PW: Word>(request: Request, buf: &'d [MW], peri_addr: *mut PW) -> Self {
66 request: Request,
67 buf: &'d [MW],
68 peri_addr: *mut PW,
69 options: TransferOptions,
70 ) -> Self {
71 Self::new_inner( 59 Self::new_inner(
72 request, 60 request,
73 Dir::MemoryToPeripheral, 61 Dir::MemoryToPeripheral,
@@ -77,7 +65,6 @@ impl LinearItem {
77 true, 65 true,
78 MW::size(), 66 MW::size(),
79 PW::size(), 67 PW::size(),
80 options,
81 ) 68 )
82 } 69 }
83 70
@@ -90,7 +77,6 @@ impl LinearItem {
90 incr_mem: bool, 77 incr_mem: bool,
91 data_size: WordSize, 78 data_size: WordSize,
92 dst_size: WordSize, 79 dst_size: WordSize,
93 _options: TransferOptions,
94 ) -> Self { 80 ) -> Self {
95 // BNDT is specified as bytes, not as number of transfers. 81 // BNDT is specified as bytes, not as number of transfers.
96 let Ok(bndt) = (mem_len * data_size.bytes()).try_into() else { 82 let Ok(bndt) = (mem_len * data_size.bytes()).try_into() else {
diff --git a/embassy-stm32/src/dma/gpdma/mod.rs b/embassy-stm32/src/dma/gpdma/mod.rs
index b23c22dfb..e906c7559 100644
--- a/embassy-stm32/src/dma/gpdma/mod.rs
+++ b/embassy-stm32/src/dma/gpdma/mod.rs
@@ -284,8 +284,6 @@ impl AnyChannel {
284 } 284 }
285 285
286 /// Configure a linked-list transfer. 286 /// Configure a linked-list transfer.
287 ///
288 /// Transfer options apply only to the base register transfer, not the linked-list items.
289 unsafe fn configure_linked_list<const ITEM_COUNT: usize>( 287 unsafe fn configure_linked_list<const ITEM_COUNT: usize>(
290 &self, 288 &self,
291 table: &Table<ITEM_COUNT>, 289 table: &Table<ITEM_COUNT>,
diff --git a/embassy-stm32/src/dma/gpdma/ringbuffered.rs b/embassy-stm32/src/dma/gpdma/ringbuffered.rs
index a5b127d08..9bee12d99 100644
--- a/embassy-stm32/src/dma/gpdma/ringbuffered.rs
+++ b/embassy-stm32/src/dma/gpdma/ringbuffered.rs
@@ -222,14 +222,12 @@ pub struct WritableRingBuffer<'a, W: Word> {
222 222
223impl<'a, W: Word> WritableRingBuffer<'a, W> { 223impl<'a, W: Word> WritableRingBuffer<'a, W> {
224 /// Create a new ring buffer. 224 /// Create a new ring buffer.
225 ///
226 /// Transfer options are applied to the individual linked list items.
227 pub unsafe fn new( 225 pub unsafe fn new(
228 channel: impl Peripheral<P = impl Channel> + 'a, 226 channel: impl Peripheral<P = impl Channel> + 'a,
229 request: Request, 227 request: Request,
230 peri_addr: *mut W, 228 peri_addr: *mut W,
231 buffer: &'a mut [W], 229 buffer: &'a mut [W],
232 mut options: TransferOptions, 230 _options: TransferOptions,
233 ) -> Self { 231 ) -> Self {
234 into_ref!(channel); 232 into_ref!(channel);
235 let channel: PeripheralRef<'a, AnyChannel> = channel.map_into(); 233 let channel: PeripheralRef<'a, AnyChannel> = channel.map_into();
@@ -237,12 +235,9 @@ impl<'a, W: Word> WritableRingBuffer<'a, W> {
237 let half_len = buffer.len() / 2; 235 let half_len = buffer.len() / 2;
238 assert_eq!(half_len * 2, buffer.len()); 236 assert_eq!(half_len * 2, buffer.len());
239 237
240 options.half_transfer_ir = false;
241 options.complete_transfer_ir = true;
242
243 let items = [ 238 let items = [
244 LinearItem::new_write(request, &mut buffer[..half_len], peri_addr, options), 239 LinearItem::new_write(request, &mut buffer[..half_len], peri_addr),
245 LinearItem::new_write(request, &mut buffer[half_len..], peri_addr, options), 240 LinearItem::new_write(request, &mut buffer[half_len..], peri_addr),
246 ]; 241 ];
247 let table = Table::new(items); 242 let table = Table::new(items);
248 243
@@ -279,16 +274,7 @@ impl<'a, W: Word> WritableRingBuffer<'a, W> {
279 /// 274 ///
280 /// You must call this after creating it for it to work. 275 /// You must call this after creating it for it to work.
281 pub fn start(&mut self) { 276 pub fn start(&mut self) {
282 unsafe { 277 unsafe { self.channel.configure_linked_list(&self.table, Default::default()) };
283 self.channel.configure_linked_list(
284 &self.table,
285 TransferOptions {
286 half_transfer_ir: false,
287 complete_transfer_ir: true,
288 ..Default::default()
289 },
290 )
291 };
292 self.table.link(RunMode::Repeat); 278 self.table.link(RunMode::Repeat);
293 self.channel.start(); 279 self.channel.start();
294 } 280 }