diff options
Diffstat (limited to 'embassy-mcxa/src')
| -rw-r--r-- | embassy-mcxa/src/dma.rs | 14 |
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). |
