Struct esp32_hal::FlashSafeDma

source ·
pub struct FlashSafeDma<T, const SIZE: usize> { /* private fields */ }
Expand description

FlashSafeDma

The embedded-hal traits make no guarantees about where the buffers are placed. The DMA implementation in Espressif chips has a limitation in that it can only access the RAM address space, meaning data to be transmitted from the flash address space must be copied into RAM first.

This wrapper struct should be used when a peripheral using the DMA engine needs to transmit data from flash (ROM) via the embedded-hal traits. This is often a const variable.

Example usage using spi::master::dma::SpiDma

const ARRAY_IN_FLASH = [0xAA; 128]

let spi = SpiDma::new(/* */);

spi.write(&ARRAY_IN_FLASH[..]).unwrap(); // error when transmission starts

let spi = FlashSafeDma::new(spi);

spi.write(&ARRAY_IN_FLASH[..]).unwrap(); // success

Implementations§

source§

impl<T, const SIZE: usize> FlashSafeDma<T, SIZE>

source

pub fn new(inner: T) -> FlashSafeDma<T, SIZE>

source

pub fn inner_mut(&mut self) -> &mut T

source

pub fn inner(&self) -> &T

source

pub fn free(self) -> T

Trait Implementations§

source§

impl<T, const SIZE: usize> Transfer<u8> for FlashSafeDma<T, SIZE>
where T: Transfer<u8>,

§

type Error = <T as Transfer<u8>>::Error

Error type
source§

fn transfer<'w>( &mut self, words: &'w mut [u8] ) -> Result<&'w [u8], <FlashSafeDma<T, SIZE> as Transfer<u8>>::Error>

Sends words to the slave. Returns the words received from the slave
source§

impl<T, const SIZE: usize> Write<u8> for FlashSafeDma<T, SIZE>
where T: Write<u8>,

§

type Error = <T as Write<u8>>::Error

Error type
source§

fn write( &mut self, words: &[u8] ) -> Result<(), <FlashSafeDma<T, SIZE> as Write<u8>>::Error>

Sends words to the slave, ignoring all the incoming words
source§

impl<T, const SIZE: usize> FullDuplex<u8> for FlashSafeDma<T, SIZE>
where T: FullDuplex<u8>, FlashSafeDma<T, SIZE>: Transfer<u8, Error = <T as FullDuplex<u8>>::Error> + Write<u8, Error = <T as FullDuplex<u8>>::Error>,

§

type Error = <T as FullDuplex<u8>>::Error

An enumeration of SPI errors
source§

fn read( &mut self ) -> Result<u8, Error<<FlashSafeDma<T, SIZE> as FullDuplex<u8>>::Error>>

Reads the word stored in the shift register Read more
source§

fn send( &mut self, word: u8 ) -> Result<(), Error<<FlashSafeDma<T, SIZE> as FullDuplex<u8>>::Error>>

Sends a word to the slave

Auto Trait Implementations§

§

impl<T, const SIZE: usize> RefUnwindSafe for FlashSafeDma<T, SIZE>
where T: RefUnwindSafe,

§

impl<T, const SIZE: usize> Send for FlashSafeDma<T, SIZE>
where T: Send,

§

impl<T, const SIZE: usize> Sync for FlashSafeDma<T, SIZE>
where T: Sync,

§

impl<T, const SIZE: usize> Unpin for FlashSafeDma<T, SIZE>
where T: Unpin,

§

impl<T, const SIZE: usize> UnwindSafe for FlashSafeDma<T, SIZE>
where T: UnwindSafe,

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.