Refactor _from_ram methods to use more readable copy operation
This commit is contained in:
parent
3f2d9cfe0a
commit
993428e2d4
@ -274,9 +274,9 @@ impl<'d, T: Instance> Spim<'d, T> {
|
||||
Ok(_) => Ok(()),
|
||||
Err(Error::DMABufferNotInDataMemory) => {
|
||||
trace!("Copying SPIM tx buffer into RAM for DMA");
|
||||
let mut tx_buf = [0u8; FORCE_COPY_BUFFER_SIZE];
|
||||
tx_buf[..tx.len()].copy_from_slice(tx);
|
||||
self.blocking_inner_from_ram(rx, &tx_buf[..tx.len()])
|
||||
let tx_ram_buf = &mut [0; FORCE_COPY_BUFFER_SIZE][..tx.len()];
|
||||
tx_ram_buf.copy_from_slice(tx);
|
||||
self.blocking_inner_from_ram(rx, tx_ram_buf)
|
||||
}
|
||||
Err(error) => Err(error),
|
||||
}
|
||||
@ -306,9 +306,9 @@ impl<'d, T: Instance> Spim<'d, T> {
|
||||
Ok(_) => Ok(()),
|
||||
Err(Error::DMABufferNotInDataMemory) => {
|
||||
trace!("Copying SPIM tx buffer into RAM for DMA");
|
||||
let mut tx_buf = [0u8; FORCE_COPY_BUFFER_SIZE];
|
||||
tx_buf[..tx.len()].copy_from_slice(tx);
|
||||
self.async_inner_from_ram(rx, &tx_buf[..tx.len()]).await
|
||||
let tx_ram_buf = &mut [0; FORCE_COPY_BUFFER_SIZE][..tx.len()];
|
||||
tx_ram_buf.copy_from_slice(tx);
|
||||
self.async_inner_from_ram(rx, tx_ram_buf).await
|
||||
}
|
||||
Err(error) => Err(error),
|
||||
}
|
||||
|
@ -398,14 +398,9 @@ impl<'d, T: Instance> Twim<'d, T> {
|
||||
Ok(_) => Ok(()),
|
||||
Err(Error::DMABufferNotInDataMemory) => {
|
||||
trace!("Copying TWIM tx buffer into RAM for DMA");
|
||||
let mut tx_buf = [0u8; FORCE_COPY_BUFFER_SIZE];
|
||||
tx_buf[..wr_buffer.len()].copy_from_slice(wr_buffer);
|
||||
self.setup_write_read_from_ram(
|
||||
address,
|
||||
&tx_buf[..wr_buffer.len()],
|
||||
rd_buffer,
|
||||
inten,
|
||||
)
|
||||
let tx_ram_buf = &mut [0; FORCE_COPY_BUFFER_SIZE][..wr_buffer.len()];
|
||||
tx_ram_buf.copy_from_slice(wr_buffer);
|
||||
self.setup_write_read_from_ram(address, &tx_ram_buf, rd_buffer, inten)
|
||||
}
|
||||
Err(error) => Err(error),
|
||||
}
|
||||
@ -416,9 +411,9 @@ impl<'d, T: Instance> Twim<'d, T> {
|
||||
Ok(_) => Ok(()),
|
||||
Err(Error::DMABufferNotInDataMemory) => {
|
||||
trace!("Copying TWIM tx buffer into RAM for DMA");
|
||||
let mut tx_buf = [0u8; FORCE_COPY_BUFFER_SIZE];
|
||||
tx_buf[..wr_buffer.len()].copy_from_slice(wr_buffer);
|
||||
self.setup_write_from_ram(address, &tx_buf[..wr_buffer.len()], inten)
|
||||
let tx_ram_buf = &mut [0; FORCE_COPY_BUFFER_SIZE][..wr_buffer.len()];
|
||||
tx_ram_buf.copy_from_slice(wr_buffer);
|
||||
self.setup_write_from_ram(address, &tx_ram_buf, inten)
|
||||
}
|
||||
Err(error) => Err(error),
|
||||
}
|
||||
|
@ -247,9 +247,9 @@ impl<'d, T: Instance> UarteTx<'d, T> {
|
||||
Ok(_) => Ok(()),
|
||||
Err(Error::DMABufferNotInDataMemory) => {
|
||||
trace!("Copying UARTE tx buffer into RAM for DMA");
|
||||
let mut tx_buf = [0u8; FORCE_COPY_BUFFER_SIZE];
|
||||
tx_buf[..buffer.len()].copy_from_slice(buffer);
|
||||
self.write_from_ram(&tx_buf[..buffer.len()]).await
|
||||
let ram_buf = &mut [0; FORCE_COPY_BUFFER_SIZE][..buffer.len()];
|
||||
ram_buf.copy_from_slice(buffer);
|
||||
self.write_from_ram(&ram_buf).await
|
||||
}
|
||||
Err(error) => Err(error),
|
||||
}
|
||||
@ -314,9 +314,9 @@ impl<'d, T: Instance> UarteTx<'d, T> {
|
||||
Ok(_) => Ok(()),
|
||||
Err(Error::DMABufferNotInDataMemory) => {
|
||||
trace!("Copying UARTE tx buffer into RAM for DMA");
|
||||
let mut tx_buf = [0u8; FORCE_COPY_BUFFER_SIZE];
|
||||
tx_buf[..buffer.len()].copy_from_slice(buffer);
|
||||
self.blocking_write_from_ram(&tx_buf[..buffer.len()])
|
||||
let ram_buf = &mut [0; FORCE_COPY_BUFFER_SIZE][..buffer.len()];
|
||||
ram_buf.copy_from_slice(buffer);
|
||||
self.blocking_write_from_ram(&ram_buf)
|
||||
}
|
||||
Err(error) => Err(error),
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user