Only copy through RAM when needed
This commit is contained in:
parent
d7b1f8ca57
commit
46bafecb2a
@ -20,6 +20,7 @@ pub use embassy_usb;
|
|||||||
|
|
||||||
use crate::interrupt::Interrupt;
|
use crate::interrupt::Interrupt;
|
||||||
use crate::pac;
|
use crate::pac;
|
||||||
|
use crate::util::slice_in_ram;
|
||||||
|
|
||||||
const NEW_AW: AtomicWaker = AtomicWaker::new();
|
const NEW_AW: AtomicWaker = AtomicWaker::new();
|
||||||
static BUS_WAKER: AtomicWaker = NEW_AW;
|
static BUS_WAKER: AtomicWaker = NEW_AW;
|
||||||
@ -408,10 +409,15 @@ unsafe fn write_dma<T: Instance>(i: usize, buf: &[u8]) -> Result<(), WriteError>
|
|||||||
return Err(WriteError::BufferOverflow);
|
return Err(WriteError::BufferOverflow);
|
||||||
}
|
}
|
||||||
|
|
||||||
// EasyDMA can't read FLASH, so we copy through RAM
|
|
||||||
let mut ram_buf: MaybeUninit<[u8; 64]> = MaybeUninit::uninit();
|
let mut ram_buf: MaybeUninit<[u8; 64]> = MaybeUninit::uninit();
|
||||||
|
let ptr = if !slice_in_ram(buf) {
|
||||||
|
// EasyDMA can't read FLASH, so we copy through RAM
|
||||||
let ptr = ram_buf.as_mut_ptr() as *mut u8;
|
let ptr = ram_buf.as_mut_ptr() as *mut u8;
|
||||||
core::ptr::copy_nonoverlapping(buf.as_ptr(), ptr, buf.len());
|
core::ptr::copy_nonoverlapping(buf.as_ptr(), ptr, buf.len());
|
||||||
|
ptr
|
||||||
|
} else {
|
||||||
|
buf.as_ptr()
|
||||||
|
};
|
||||||
|
|
||||||
let epin = [
|
let epin = [
|
||||||
®s.epin0,
|
®s.epin0,
|
||||||
|
Loading…
Reference in New Issue
Block a user