mirror of
https://github.com/embassy-rs/embassy.git
synced 2024-11-22 06:42:32 +00:00
transfer_in_place
This commit is contained in:
parent
c8ecc55710
commit
6d347af9fa
@ -334,6 +334,12 @@ impl<'d, T: Instance> Spi<'d, T, Async> {
|
||||
join(tx_transfer, rx_transfer).await;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub async fn transfer_in_place(&mut self, words: &mut [u8]) -> Result<(), Error> {
|
||||
let (ptr, len) = crate::dma::slice_ptr_parts(words);
|
||||
let tx_buffer = unsafe { core::slice::from_raw_parts(ptr as *const _, len) };
|
||||
self.transfer(words, tx_buffer).await
|
||||
}
|
||||
}
|
||||
|
||||
mod sealed {
|
||||
@ -521,13 +527,8 @@ cfg_if::cfg_if! {
|
||||
|
||||
type TransferInPlaceFuture<'a> = impl Future<Output = Result<(), Self::Error>> + 'a where Self: 'a;
|
||||
|
||||
fn transfer_in_place<'a>(
|
||||
&'a mut self,
|
||||
words: &'a mut [u8],
|
||||
) -> Self::TransferInPlaceFuture<'a> {
|
||||
let (ptr, len) = crate::dma::slice_ptr_parts(words);
|
||||
let tx_buffer = unsafe { core::slice::from_raw_parts(ptr as *const _, len) };
|
||||
self.transfer(words, tx_buffer)
|
||||
fn transfer_in_place<'a>(&'a mut self, words: &'a mut [u8]) -> Self::TransferInPlaceFuture<'a> {
|
||||
self.transfer_in_place(words)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -8,7 +8,7 @@ use defmt::*;
|
||||
use embassy_executor::Spawner;
|
||||
use embassy_rp::gpio::{Level, Output};
|
||||
use embassy_rp::spi;
|
||||
use embassy_rp::spi::{Spi, Blocking};
|
||||
use embassy_rp::spi::{Blocking, Spi};
|
||||
use embassy_time::Delay;
|
||||
use embedded_graphics::image::{Image, ImageRawLE};
|
||||
use embedded_graphics::mono_font::ascii::FONT_10X20;
|
||||
|
Loading…
Reference in New Issue
Block a user