embedded_sdmmc

Struct SdMmcSpi

Source
pub struct SdMmcSpi<SPI, CS>
where SPI: FullDuplex<u8>, CS: OutputPin, <SPI as FullDuplex<u8>>::Error: Debug,
{ /* private fields */ }
Expand description

Represents an SD Card interface built from an SPI peripheral and a Chip Select pin. We need Chip Select to be separate so we can clock out some bytes without Chip Select asserted (which puts the card into SPI mode).

Implementations§

Source§

impl<SPI, CS> SdMmcSpi<SPI, CS>
where SPI: FullDuplex<u8>, CS: OutputPin, <SPI as FullDuplex<u8>>::Error: Debug,

Source

pub fn new(spi: SPI, cs: CS) -> SdMmcSpi<SPI, CS>

Create a new SD/MMC controller using a raw SPI interface.

Source

pub fn spi(&mut self) -> RefMut<'_, SPI>

Get a temporary borrow on the underlying SPI device. Useful if you need to re-clock the SPI after performing init().

Source

pub fn init(&mut self) -> Result<(), Error>

This routine must be performed with an SPI clock speed of around 100 - 400 kHz. Afterwards you may increase the SPI clock speed.

Source

pub fn deinit(&mut self)

De-init the card so it can’t be used

Source

pub fn card_size_bytes(&self) -> Result<u64, Error>

Return the usable size of this SD card in bytes.

Source

pub fn erase( &mut self, _first_block: BlockIdx, _last_block: BlockIdx, ) -> Result<(), Error>

Erase some blocks on the card.

Source

pub fn erase_single_block_enabled(&self) -> Result<bool, Error>

Can this card erase single blocks?

Trait Implementations§

Source§

impl<SPI, CS> BlockDevice for SdMmcSpi<SPI, CS>
where SPI: FullDuplex<u8>, <SPI as FullDuplex<u8>>::Error: Debug, CS: OutputPin,

Source§

fn read( &self, blocks: &mut [Block], start_block_idx: BlockIdx, _reason: &str, ) -> Result<(), Self::Error>

Read one or more blocks, starting at the given block index.

Source§

fn write( &self, blocks: &[Block], start_block_idx: BlockIdx, ) -> Result<(), Self::Error>

Write one or more blocks, starting at the given block index.

Source§

fn num_blocks(&self) -> Result<BlockCount, Self::Error>

Determine how many blocks this device can hold.

Source§

type Error = Error

The errors that the BlockDevice can return. Must be debug formattable.

Auto Trait Implementations§

§

impl<SPI, CS> !Freeze for SdMmcSpi<SPI, CS>

§

impl<SPI, CS> !RefUnwindSafe for SdMmcSpi<SPI, CS>

§

impl<SPI, CS> Send for SdMmcSpi<SPI, CS>
where SPI: Send, CS: Send,

§

impl<SPI, CS> !Sync for SdMmcSpi<SPI, CS>

§

impl<SPI, CS> Unpin for SdMmcSpi<SPI, CS>
where SPI: Unpin, CS: Unpin,

§

impl<SPI, CS> UnwindSafe for SdMmcSpi<SPI, CS>
where SPI: UnwindSafe, CS: 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.