From 27cfd967180d6163a082ffe1ded17a6932cac75c Mon Sep 17 00:00:00 2001 From: xoviat Date: Tue, 9 Dec 2025 19:35:26 -0600 Subject: dma: add functions --- embassy-stm32/src/dma/util.rs | 58 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) diff --git a/embassy-stm32/src/dma/util.rs b/embassy-stm32/src/dma/util.rs index 3245887c1..304268963 100644 --- a/embassy-stm32/src/dma/util.rs +++ b/embassy-stm32/src/dma/util.rs @@ -20,6 +20,16 @@ impl<'d> ChannelAndRequest<'d> { Transfer::new_read(self.channel.reborrow(), self.request, peri_addr, buf, options) } + #[allow(dead_code)] + pub unsafe fn read_unchecked<'a, W: Word>( + &'a self, + peri_addr: *mut W, + buf: &'a mut [W], + options: TransferOptions, + ) -> Transfer<'a> { + Transfer::new_read(self.channel.clone_unchecked(), self.request, peri_addr, buf, options) + } + pub unsafe fn read_raw<'a, MW: Word, PW: Word>( &'a mut self, peri_addr: *mut PW, @@ -29,6 +39,16 @@ impl<'d> ChannelAndRequest<'d> { Transfer::new_read_raw(self.channel.reborrow(), self.request, peri_addr, buf, options) } + #[allow(dead_code)] + pub unsafe fn read_raw_unchecked<'a, MW: Word, PW: Word>( + &'a self, + peri_addr: *mut PW, + buf: *mut [MW], + options: TransferOptions, + ) -> Transfer<'a> { + Transfer::new_read_raw(self.channel.clone_unchecked(), self.request, peri_addr, buf, options) + } + pub unsafe fn write<'a, W: Word>( &'a mut self, buf: &'a [W], @@ -38,6 +58,16 @@ impl<'d> ChannelAndRequest<'d> { Transfer::new_write(self.channel.reborrow(), self.request, buf, peri_addr, options) } + #[allow(dead_code)] + pub unsafe fn write_unchecked<'a, W: Word>( + &'a self, + buf: &'a [W], + peri_addr: *mut W, + options: TransferOptions, + ) -> Transfer<'a> { + Transfer::new_write(self.channel.clone_unchecked(), self.request, buf, peri_addr, options) + } + pub unsafe fn write_raw<'a, MW: Word, PW: Word>( &'a mut self, buf: *const [MW], @@ -47,6 +77,16 @@ impl<'d> ChannelAndRequest<'d> { Transfer::new_write_raw(self.channel.reborrow(), self.request, buf, peri_addr, options) } + #[allow(dead_code)] + pub unsafe fn write_raw_unchecked<'a, MW: Word, PW: Word>( + &'a self, + buf: *const [MW], + peri_addr: *mut PW, + options: TransferOptions, + ) -> Transfer<'a> { + Transfer::new_write_raw(self.channel.clone_unchecked(), self.request, buf, peri_addr, options) + } + #[allow(dead_code)] pub unsafe fn write_repeated<'a, W: Word>( &'a mut self, @@ -64,4 +104,22 @@ impl<'d> ChannelAndRequest<'d> { options, ) } + + #[allow(dead_code)] + pub unsafe fn write_repeated_unchecked<'a, W: Word>( + &'a self, + repeated: &'a W, + count: usize, + peri_addr: *mut W, + options: TransferOptions, + ) -> Transfer<'a> { + Transfer::new_write_repeated( + self.channel.clone_unchecked(), + self.request, + repeated, + count, + peri_addr, + options, + ) + } } -- cgit