aboutsummaryrefslogtreecommitdiff
path: root/embassy-mcxa
diff options
context:
space:
mode:
authorJames Munns <[email protected]>2025-12-09 17:53:45 +0100
committerJames Munns <[email protected]>2025-12-09 17:53:45 +0100
commit3e7de3a5d81e32e77aeb5232e5a7f512ce39db0e (patch)
treebefaf3ba75b41ba4352bf00e6e0003a304e242ce /embassy-mcxa
parent2dd5229c8c4fea6de7a7d52cedc6b6490d567ecf (diff)
Change transfer to return a result
Diffstat (limited to 'embassy-mcxa')
-rw-r--r--embassy-mcxa/src/dma.rs14
1 files changed, 9 insertions, 5 deletions
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<C: Channel> DmaChannel<C> {
773 /// 773 ///
774 /// The source and destination buffers must remain valid for the 774 /// The source and destination buffers must remain valid for the
775 /// duration of the transfer. 775 /// duration of the transfer.
776 pub fn mem_to_mem<W: Word>(&self, src: &[W], dst: &mut [W], options: TransferOptions) -> Transfer<'_> { 776 pub fn mem_to_mem<W: Word>(&self, src: &[W], dst: &mut [W], options: TransferOptions) -> Result<Transfer<'_>, Error> {
777 assert!(!src.is_empty()); 777 let mut invalid = false;
778 assert!(dst.len() >= src.len()); 778 invalid |= src.is_empty();
779 assert!(src.len() <= 0x7fff); 779 invalid |= src.len() > dst.len();
780 invalid |= src.len() > 0x7fff;
781 if invalid {
782 return Err(Error::Configuration);
783 }
780 784
781 let size = W::size(); 785 let size = W::size();
782 let byte_count = (src.len() * size.bytes()) as u32; 786 let byte_count = (src.len() * size.bytes()) as u32;
@@ -837,7 +841,7 @@ impl<C: Channel> DmaChannel<C> {
837 .set_bit() // Start the channel 841 .set_bit() // Start the channel
838 }); 842 });
839 843
840 Transfer::new(self.as_any()) 844 Ok(Transfer::new(self.as_any()))
841 } 845 }
842 846
843 /// Fill a memory buffer with a pattern value (memset). 847 /// Fill a memory buffer with a pattern value (memset).