aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRasmus Melchior Jacobsen <[email protected]>2022-12-23 09:32:18 +0100
committerRasmus Melchior Jacobsen <[email protected]>2022-12-23 09:32:18 +0100
commitda9ee837561694a7749e17d727e56da7ddb3e9b2 (patch)
tree70d93a7f115a9191c21089c0864abb2e3baf26dc
parent1bd6c954c23b16041b382243a844a53727f6cc9c (diff)
fix(stm32): Fix write buffer lifetime for repeated writes
-rw-r--r--embassy-stm32/src/dma/bdma.rs5
-rw-r--r--embassy-stm32/src/dma/dma.rs5
-rw-r--r--embassy-stm32/src/dma/gpdma.rs5
-rw-r--r--embassy-stm32/src/dma/mod.rs4
4 files changed, 8 insertions, 11 deletions
diff --git a/embassy-stm32/src/dma/bdma.rs b/embassy-stm32/src/dma/bdma.rs
index e6ce05b7b..7da22ec12 100644
--- a/embassy-stm32/src/dma/bdma.rs
+++ b/embassy-stm32/src/dma/bdma.rs
@@ -78,8 +78,7 @@ foreach_dma_channel! {
78 ); 78 );
79 } 79 }
80 80
81 unsafe fn start_write_repeated<W: Word>(&mut self, _request: Request, repeated: W, count: usize, reg_addr: *mut W, options: TransferOptions) { 81 unsafe fn start_write_repeated<W: Word>(&mut self, _request: Request, repeated: &[W; 1], count: usize, reg_addr: *mut W, options: TransferOptions) {
82 let buf = [repeated];
83 low_level_api::start_transfer( 82 low_level_api::start_transfer(
84 pac::$dma_peri, 83 pac::$dma_peri,
85 $channel_num, 84 $channel_num,
@@ -87,7 +86,7 @@ foreach_dma_channel! {
87 _request, 86 _request,
88 vals::Dir::FROMMEMORY, 87 vals::Dir::FROMMEMORY,
89 reg_addr as *const u32, 88 reg_addr as *const u32,
90 buf.as_ptr() as *mut u32, 89 repeated.as_ptr() as *mut u32,
91 count, 90 count,
92 false, 91 false,
93 vals::Size::from(W::bits()), 92 vals::Size::from(W::bits()),
diff --git a/embassy-stm32/src/dma/dma.rs b/embassy-stm32/src/dma/dma.rs
index 97a3df088..45a38dda4 100644
--- a/embassy-stm32/src/dma/dma.rs
+++ b/embassy-stm32/src/dma/dma.rs
@@ -102,15 +102,14 @@ foreach_dma_channel! {
102 ) 102 )
103 } 103 }
104 104
105 unsafe fn start_write_repeated<W: Word>(&mut self, request: Request, repeated: W, count: usize, reg_addr: *mut W, options: TransferOptions) { 105 unsafe fn start_write_repeated<W: Word>(&mut self, request: Request, repeated: &[W; 1], count: usize, reg_addr: *mut W, options: TransferOptions) {
106 let buf = [repeated];
107 low_level_api::start_transfer( 106 low_level_api::start_transfer(
108 pac::$dma_peri, 107 pac::$dma_peri,
109 $channel_num, 108 $channel_num,
110 request, 109 request,
111 vals::Dir::MEMORYTOPERIPHERAL, 110 vals::Dir::MEMORYTOPERIPHERAL,
112 reg_addr as *const u32, 111 reg_addr as *const u32,
113 buf.as_ptr() as *mut u32, 112 repeated.as_ptr() as *mut u32,
114 count, 113 count,
115 false, 114 false,
116 vals::Size::from(W::bits()), 115 vals::Size::from(W::bits()),
diff --git a/embassy-stm32/src/dma/gpdma.rs b/embassy-stm32/src/dma/gpdma.rs
index bde8c3ef3..46d8715b9 100644
--- a/embassy-stm32/src/dma/gpdma.rs
+++ b/embassy-stm32/src/dma/gpdma.rs
@@ -75,15 +75,14 @@ foreach_dma_channel! {
75 ) 75 )
76 } 76 }
77 77
78 unsafe fn start_write_repeated<W: Word>(&mut self, request: Request, repeated: W, count: usize, reg_addr: *mut W, options: TransferOptions) { 78 unsafe fn start_write_repeated<W: Word>(&mut self, request: Request, repeated: &[W; 1], count: usize, reg_addr: *mut W, options: TransferOptions) {
79 let buf = [repeated];
80 low_level_api::start_transfer( 79 low_level_api::start_transfer(
81 pac::$dma_peri, 80 pac::$dma_peri,
82 $channel_num, 81 $channel_num,
83 request, 82 request,
84 low_level_api::Dir::MemoryToPeripheral, 83 low_level_api::Dir::MemoryToPeripheral,
85 reg_addr as *const u32, 84 reg_addr as *const u32,
86 buf.as_ptr() as *mut u32, 85 repeated.as_ptr() as *mut u32,
87 count, 86 count,
88 false, 87 false,
89 W::bits(), 88 W::bits(),
diff --git a/embassy-stm32/src/dma/mod.rs b/embassy-stm32/src/dma/mod.rs
index 74bce6aa9..31f55b868 100644
--- a/embassy-stm32/src/dma/mod.rs
+++ b/embassy-stm32/src/dma/mod.rs
@@ -59,7 +59,7 @@ pub(crate) mod sealed {
59 unsafe fn start_write_repeated<W: super::Word>( 59 unsafe fn start_write_repeated<W: super::Word>(
60 &mut self, 60 &mut self,
61 request: Request, 61 request: Request,
62 repeated: W, 62 repeated: &[W; 1],
63 count: usize, 63 count: usize,
64 reg_addr: *mut W, 64 reg_addr: *mut W,
65 options: TransferOptions, 65 options: TransferOptions,
@@ -246,7 +246,7 @@ mod transfers {
246 pub fn write_repeated<'a, W: Word>( 246 pub fn write_repeated<'a, W: Word>(
247 channel: impl Peripheral<P = impl Channel> + 'a, 247 channel: impl Peripheral<P = impl Channel> + 'a,
248 request: Request, 248 request: Request,
249 repeated: W, 249 repeated: &[W; 1],
250 count: usize, 250 count: usize,
251 reg_addr: *mut W, 251 reg_addr: *mut W,
252 ) -> impl Future<Output = ()> + 'a { 252 ) -> impl Future<Output = ()> + 'a {