From 6d347af9fae3a9c594e13900796ec57537c402e6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Alse=CC=81r?= Date: Tue, 30 Aug 2022 06:50:58 +0200 Subject: [PATCH] transfer_in_place --- embassy-rp/src/spi.rs | 15 ++++++++------- examples/rp/src/bin/spi_display.rs | 2 +- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/embassy-rp/src/spi.rs b/embassy-rp/src/spi.rs index be639504f..11aad6305 100644 --- a/embassy-rp/src/spi.rs +++ b/embassy-rp/src/spi.rs @@ -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> + '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) } } } diff --git a/examples/rp/src/bin/spi_display.rs b/examples/rp/src/bin/spi_display.rs index d0fbd6847..23cd4355e 100644 --- a/examples/rp/src/bin/spi_display.rs +++ b/examples/rp/src/bin/spi_display.rs @@ -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;