Struct SpiFlash

Source
pub struct SpiFlash<'a, SPI: Spi<'a>> {
    spi: SPI,
    cs: fn(active: bool),
    pub manufacturer: Manufacturer,
    pub size: FlashSize,
    pub page_count: u32,
    pub sector_count: u32,
    pub block_count: u32,
    four_byte_addr: bool,
    busy: bool,
    _phantom: PhantomData<&'a ()>,
}
Expand description

Flash device configuration/handle.

Fields§

§spi: SPI§cs: fn(active: bool)§manufacturer: Manufacturer§size: FlashSize§page_count: u32§sector_count: u32§block_count: u32§four_byte_addr: bool§busy: bool§_phantom: PhantomData<&'a ()>

Implementations§

Source§

impl<'a, SPI: Spi<'a>> SpiFlash<'a, SPI>

Source

pub fn new(spi: SPI, cs: fn(active: bool)) -> Self

Source

fn select(&self)

Pull CS low

Source

fn deselect(&self)

Pull CS high

Source

fn cmd( &mut self, cmd: u8, addr: Option<u32>, tx_data: Option<&[u8]>, rx_data: Option<&mut [u8]>, ) -> Result<(), i32>

Send command and optional address/data; optionally read.

Source

pub fn find_chip(&mut self) -> Result<(), i32>

Source

fn write_enable(&mut self) -> Result<(), i32>

Source

fn write_disable(&mut self) -> Result<(), i32>

Source

fn read_status(&mut self) -> Result<u8, i32>

Source

pub fn wait_ready( &mut self, timeout: u32, delay: impl FnMut(u32), ) -> Result<(), i32>

Source

pub fn erase_chip(&mut self, delay: impl FnMut(u32)) -> Result<(), i32>

Source

pub fn erase_sector( &mut self, sector: u32, delay: impl FnMut(u32), ) -> Result<(), i32>

Source

pub fn erase_block( &mut self, block: u32, delay: impl FnMut(u32), ) -> Result<(), i32>

Source

pub fn write_address( &mut self, address: u32, data: &[u8], delay: impl FnMut(u32), ) -> Result<(), i32>

Write array to address, splits across pages as needed.

Source

pub fn write_page( &mut self, page: u32, data: &[u8], offset: usize, delay: &mut impl FnMut(u32), ) -> Result<(), i32>

Write a partial page (up to 256-offset).

Source

pub fn read_address(&mut self, address: u32, data: &mut [u8]) -> Result<(), i32>

Read array from arbitrary address, splits if needed.

Source

pub fn read_page( &mut self, page: u32, data: &mut [u8], offset: usize, ) -> Result<(), i32>

Read portion of a page

Source

pub fn write_sector( &mut self, sector: u32, data: &[u8], offset: usize, delay: impl FnMut(u32), ) -> Result<(), i32>

Source

pub fn read_sector( &mut self, sector: u32, data: &mut [u8], offset: usize, ) -> Result<(), i32>

Source

pub fn write_block( &mut self, block: u32, data: &[u8], offset: usize, delay: impl FnMut(u32), ) -> Result<(), i32>

Source

pub fn read_block( &mut self, block: u32, data: &mut [u8], offset: usize, ) -> Result<(), i32>

Source

pub fn is_busy(&self) -> bool

Auto Trait Implementations§

§

impl<'a, SPI> Freeze for SpiFlash<'a, SPI>
where SPI: Freeze,

§

impl<'a, SPI> RefUnwindSafe for SpiFlash<'a, SPI>
where SPI: RefUnwindSafe,

§

impl<'a, SPI> Send for SpiFlash<'a, SPI>
where SPI: Send,

§

impl<'a, SPI> Sync for SpiFlash<'a, SPI>
where SPI: Sync,

§

impl<'a, SPI> Unpin for SpiFlash<'a, SPI>
where SPI: Unpin,

§

impl<'a, SPI> UnwindSafe for SpiFlash<'a, SPI>
where SPI: 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>,

Source§

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>,

Source§

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.