fix(stm32): Fix write buffer lifetime for repeated writes

This commit is contained in:
Rasmus Melchior Jacobsen 2022-12-23 09:32:18 +01:00
parent 1bd6c954c2
commit da9ee83756
4 changed files with 8 additions and 11 deletions

View File

@ -78,8 +78,7 @@ foreach_dma_channel! {
); );
} }
unsafe fn start_write_repeated<W: Word>(&mut self, _request: Request, repeated: W, count: usize, reg_addr: *mut W, options: TransferOptions) { unsafe fn start_write_repeated<W: Word>(&mut self, _request: Request, repeated: &[W; 1], count: usize, reg_addr: *mut W, options: TransferOptions) {
let buf = [repeated];
low_level_api::start_transfer( low_level_api::start_transfer(
pac::$dma_peri, pac::$dma_peri,
$channel_num, $channel_num,
@ -87,7 +86,7 @@ foreach_dma_channel! {
_request, _request,
vals::Dir::FROMMEMORY, vals::Dir::FROMMEMORY,
reg_addr as *const u32, reg_addr as *const u32,
buf.as_ptr() as *mut u32, repeated.as_ptr() as *mut u32,
count, count,
false, false,
vals::Size::from(W::bits()), vals::Size::from(W::bits()),

View File

@ -102,15 +102,14 @@ foreach_dma_channel! {
) )
} }
unsafe fn start_write_repeated<W: Word>(&mut self, request: Request, repeated: W, count: usize, reg_addr: *mut W, options: TransferOptions) { unsafe fn start_write_repeated<W: Word>(&mut self, request: Request, repeated: &[W; 1], count: usize, reg_addr: *mut W, options: TransferOptions) {
let buf = [repeated];
low_level_api::start_transfer( low_level_api::start_transfer(
pac::$dma_peri, pac::$dma_peri,
$channel_num, $channel_num,
request, request,
vals::Dir::MEMORYTOPERIPHERAL, vals::Dir::MEMORYTOPERIPHERAL,
reg_addr as *const u32, reg_addr as *const u32,
buf.as_ptr() as *mut u32, repeated.as_ptr() as *mut u32,
count, count,
false, false,
vals::Size::from(W::bits()), vals::Size::from(W::bits()),

View File

@ -75,15 +75,14 @@ foreach_dma_channel! {
) )
} }
unsafe fn start_write_repeated<W: Word>(&mut self, request: Request, repeated: W, count: usize, reg_addr: *mut W, options: TransferOptions) { unsafe fn start_write_repeated<W: Word>(&mut self, request: Request, repeated: &[W; 1], count: usize, reg_addr: *mut W, options: TransferOptions) {
let buf = [repeated];
low_level_api::start_transfer( low_level_api::start_transfer(
pac::$dma_peri, pac::$dma_peri,
$channel_num, $channel_num,
request, request,
low_level_api::Dir::MemoryToPeripheral, low_level_api::Dir::MemoryToPeripheral,
reg_addr as *const u32, reg_addr as *const u32,
buf.as_ptr() as *mut u32, repeated.as_ptr() as *mut u32,
count, count,
false, false,
W::bits(), W::bits(),

View File

@ -59,7 +59,7 @@ pub(crate) mod sealed {
unsafe fn start_write_repeated<W: super::Word>( unsafe fn start_write_repeated<W: super::Word>(
&mut self, &mut self,
request: Request, request: Request,
repeated: W, repeated: &[W; 1],
count: usize, count: usize,
reg_addr: *mut W, reg_addr: *mut W,
options: TransferOptions, options: TransferOptions,
@ -246,7 +246,7 @@ mod transfers {
pub fn write_repeated<'a, W: Word>( pub fn write_repeated<'a, W: Word>(
channel: impl Peripheral<P = impl Channel> + 'a, channel: impl Peripheral<P = impl Channel> + 'a,
request: Request, request: Request,
repeated: W, repeated: &[W; 1],
count: usize, count: usize,
reg_addr: *mut W, reg_addr: *mut W,
) -> impl Future<Output = ()> + 'a { ) -> impl Future<Output = ()> + 'a {