pub struct SdMmcSpi<SPI, CS>{ /* 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>
impl<SPI, CS> SdMmcSpi<SPI, CS>
Sourcepub fn new(spi: SPI, cs: CS) -> SdMmcSpi<SPI, CS>
pub fn new(spi: SPI, cs: CS) -> SdMmcSpi<SPI, CS>
Create a new SD/MMC controller using a raw SPI interface.
Sourcepub fn spi(&mut self) -> RefMut<'_, SPI>
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()
.
Sourcepub fn init(&mut self) -> Result<(), Error>
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.
Sourcepub fn card_size_bytes(&self) -> Result<u64, Error>
pub fn card_size_bytes(&self) -> Result<u64, Error>
Return the usable size of this SD card in bytes.
Sourcepub fn erase(
&mut self,
_first_block: BlockIdx,
_last_block: BlockIdx,
) -> Result<(), Error>
pub fn erase( &mut self, _first_block: BlockIdx, _last_block: BlockIdx, ) -> Result<(), Error>
Erase some blocks on the card.
Sourcepub fn erase_single_block_enabled(&self) -> Result<bool, Error>
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>
impl<SPI, CS> BlockDevice for SdMmcSpi<SPI, CS>
Source§fn read(
&self,
blocks: &mut [Block],
start_block_idx: BlockIdx,
_reason: &str,
) -> Result<(), Self::Error>
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>
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>
fn num_blocks(&self) -> Result<BlockCount, Self::Error>
Determine how many blocks this device can hold.