[][src]Struct embedded_sdmmc::SdMmcSpi

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

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).

Methods

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

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

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

pub fn spi(&mut self) -> &mut SPI[src]

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

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

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

pub fn deinit(&mut self)[src]

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

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

Return the usable size of this SD card in bytes.

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

Erase some blocks on the card.

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

Can this card erase single blocks?

Trait Implementations

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

type Error = Error

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

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

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

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

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

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

Determine how many blocks this device can hold.

Auto Trait Implementations

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

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

Blanket Implementations

impl<T> From for T[src]

impl<T, U> TryFrom for T where
    U: Into<T>, 
[src]

type Error = !

🔬 This is a nightly-only experimental API. (try_from)

The type returned in the event of a conversion error.

impl<T, U> TryInto for T where
    U: TryFrom<T>, 
[src]

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

🔬 This is a nightly-only experimental API. (try_from)

The type returned in the event of a conversion error.

impl<T, U> Into for T where
    U: From<T>, 
[src]

impl<T> Borrow for T where
    T: ?Sized
[src]

impl<T> BorrowMut for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]