From 3e7de3a5d81e32e77aeb5232e5a7f512ce39db0e Mon Sep 17 00:00:00 2001 From: James Munns Date: Tue, 9 Dec 2025 17:53:45 +0100 Subject: Change transfer to return a result --- embassy-mcxa/src/dma.rs | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'embassy-mcxa/src') diff --git a/embassy-mcxa/src/dma.rs b/embassy-mcxa/src/dma.rs index ff9ebeb05..ffe816469 100644 --- a/embassy-mcxa/src/dma.rs +++ b/embassy-mcxa/src/dma.rs @@ -773,10 +773,14 @@ impl DmaChannel { /// /// The source and destination buffers must remain valid for the /// duration of the transfer. - pub fn mem_to_mem(&self, src: &[W], dst: &mut [W], options: TransferOptions) -> Transfer<'_> { - assert!(!src.is_empty()); - assert!(dst.len() >= src.len()); - assert!(src.len() <= 0x7fff); + pub fn mem_to_mem(&self, src: &[W], dst: &mut [W], options: TransferOptions) -> Result, Error> { + let mut invalid = false; + invalid |= src.is_empty(); + invalid |= src.len() > dst.len(); + invalid |= src.len() > 0x7fff; + if invalid { + return Err(Error::Configuration); + } let size = W::size(); let byte_count = (src.len() * size.bytes()) as u32; @@ -837,7 +841,7 @@ impl DmaChannel { .set_bit() // Start the channel }); - Transfer::new(self.as_any()) + Ok(Transfer::new(self.as_any())) } /// Fill a memory buffer with a pattern value (memset). -- cgit