aboutsummaryrefslogtreecommitdiff
path: root/embassy-imxrt/src/dma.rs
diff options
context:
space:
mode:
authorFelipe Balbi <[email protected]>2025-12-17 16:28:24 +0000
committerGitHub <[email protected]>2025-12-17 16:28:24 +0000
commit10630047153a8246573191d53d5ac571a3750117 (patch)
treecdeec5808132a07edc2c856398ed02fd991fda98 /embassy-imxrt/src/dma.rs
parentcade3b5396fc91e41551d6a95d3393523c730c90 (diff)
parent772c9f951b5ee292089670d9b489314d75f8a92a (diff)
Merge pull request #5092 from felipebalbi/imxrt/dma
[iMXRT] dma: fix potential underflow bug
Diffstat (limited to 'embassy-imxrt/src/dma.rs')
-rw-r--r--embassy-imxrt/src/dma.rs8
1 files changed, 5 insertions, 3 deletions
diff --git a/embassy-imxrt/src/dma.rs b/embassy-imxrt/src/dma.rs
index e71a27e0e..eaa09870d 100644
--- a/embassy-imxrt/src/dma.rs
+++ b/embassy-imxrt/src/dma.rs
@@ -16,6 +16,8 @@ use crate::peripherals::DMA0;
16use crate::sealed::Sealed; 16use crate::sealed::Sealed;
17use crate::{BitIter, interrupt, pac, peripherals}; 17use crate::{BitIter, interrupt, pac, peripherals};
18 18
19pub(crate) const MAX_CHUNK_SIZE: usize = 1024;
20
19#[cfg(feature = "rt")] 21#[cfg(feature = "rt")]
20#[interrupt] 22#[interrupt]
21fn DMA0() { 23fn DMA0() {
@@ -69,7 +71,7 @@ pub(crate) unsafe fn init() {
69/// 71///
70/// SAFETY: Slice must point to a valid location reachable by DMA. 72/// SAFETY: Slice must point to a valid location reachable by DMA.
71pub unsafe fn read<'a, C: Channel, W: Word>(ch: Peri<'a, C>, from: *const W, to: *mut [W]) -> Transfer<'a, C> { 73pub unsafe fn read<'a, C: Channel, W: Word>(ch: Peri<'a, C>, from: *const W, to: *mut [W]) -> Transfer<'a, C> {
72 let count = ((to.len() / W::size() as usize) - 1) as isize; 74 let count = (to.len().div_ceil(W::size() as usize) - 1) as isize;
73 75
74 copy_inner( 76 copy_inner(
75 ch, 77 ch,
@@ -87,7 +89,7 @@ pub unsafe fn read<'a, C: Channel, W: Word>(ch: Peri<'a, C>, from: *const W, to:
87/// 89///
88/// SAFETY: Slice must point to a valid location reachable by DMA. 90/// SAFETY: Slice must point to a valid location reachable by DMA.
89pub unsafe fn write<'a, C: Channel, W: Word>(ch: Peri<'a, C>, from: *const [W], to: *mut W) -> Transfer<'a, C> { 91pub unsafe fn write<'a, C: Channel, W: Word>(ch: Peri<'a, C>, from: *const [W], to: *mut W) -> Transfer<'a, C> {
90 let count = ((from.len() / W::size() as usize) - 1) as isize; 92 let count = (from.len().div_ceil(W::size() as usize) - 1) as isize;
91 93
92 copy_inner( 94 copy_inner(
93 ch, 95 ch,
@@ -109,7 +111,7 @@ pub unsafe fn copy<'a, C: Channel, W: Word>(ch: Peri<'a, C>, from: &[W], to: &mu
109 let to_len = to.len(); 111 let to_len = to.len();
110 assert_eq!(from_len, to_len); 112 assert_eq!(from_len, to_len);
111 113
112 let count = ((from_len / W::size() as usize) - 1) as isize; 114 let count = (from_len.div_ceil(W::size() as usize) - 1) as isize;
113 115
114 copy_inner( 116 copy_inner(
115 ch, 117 ch,