From 4291a092bedb0f45d236a1847a9b85fd093d3af9 Mon Sep 17 00:00:00 2001 From: etiennecollin Date: Mon, 25 Aug 2025 21:10:59 +0200 Subject: fix: moved channel configuration from new() to start() See this PR comment explaining why configuration in `new()` is a bad idea: https://github.com/embassy-rs/embassy/pull/3923#issuecomment-2889193736 --- embassy-stm32/src/dma/gpdma/ringbuffered.rs | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/embassy-stm32/src/dma/gpdma/ringbuffered.rs b/embassy-stm32/src/dma/gpdma/ringbuffered.rs index 3a7ceb292..359bc83b3 100644 --- a/embassy-stm32/src/dma/gpdma/ringbuffered.rs +++ b/embassy-stm32/src/dma/gpdma/ringbuffered.rs @@ -79,9 +79,6 @@ impl<'a, W: Word> ReadableRingBuffer<'a, W> { ]; let table = Table::new(items); - // Apply the default configuration to the channel. - unsafe { channel.configure_linked_list(&table, options) }; - Self { channel, ringbuf: ReadableDmaRingBuffer::new(buffer), @@ -92,6 +89,8 @@ impl<'a, W: Word> ReadableRingBuffer<'a, W> { /// Start the ring buffer operation. pub fn start(&mut self) { + // Apply the default configuration to the channel. + unsafe { self.channel.configure_linked_list(&self.table, self.options) }; self.table.link(RunMode::Circular); self.channel.start(); } @@ -231,9 +230,6 @@ impl<'a, W: Word> WritableRingBuffer<'a, W> { ]; let table = Table::new(items); - // Apply the default configuration to the channel. - unsafe { channel.configure_linked_list(&table, options) }; - let this = Self { channel, ringbuf: WritableDmaRingBuffer::new(buffer), @@ -246,6 +242,8 @@ impl<'a, W: Word> WritableRingBuffer<'a, W> { /// Start the ring buffer operation. pub fn start(&mut self) { + // Apply the default configuration to the channel. + unsafe { self.channel.configure_linked_list(&self.table, self.options) }; self.table.link(RunMode::Circular); self.channel.start(); } -- cgit