Skip to main content

Slot

Struct Slot 

Source
pub struct Slot<'d, const S: u8, Dm: DriverMode> { /* private fields */ }
Expand description

A configured card slot, generic over the slot index and driver mode.

Implementations§

Source§

impl<'d, const S: u8, Dm: DriverMode> Slot<'d, S, Dm>

Source

pub fn with_clk(self, clk: impl SlotClk<'d, S>) -> Self

Connects the card clock output.

Source

pub fn with_cmd(self, cmd: impl SlotCmd<'d, S>) -> Self

Connects the bidirectional command line.

Source

pub fn with_data0(self, d0: impl SlotData<'d, S, 0>) -> Self

Connects data line 0 (required for any transfer).

Source

pub fn with_data1(self, d1: impl SlotData<'d, S, 1>) -> Self

Connects data line 1.

Source

pub fn with_data2(self, d2: impl SlotData<'d, S, 2>) -> Self

Connects data line 2.

Source

pub fn with_data3(self, d3: impl SlotData<'d, S, 3>) -> Self

Connects data line 3 (completes the 4-bit bus).

Source

pub fn with_data4(self, d4: impl SlotData<'d, S, 4>) -> Self

Connects data line 4.

Source

pub fn with_data5(self, d5: impl SlotData<'d, S, 5>) -> Self

Connects data line 5.

Source

pub fn with_data6(self, d6: impl SlotData<'d, S, 6>) -> Self

Connects data line 6.

Source

pub fn with_data7(self, d7: impl SlotData<'d, S, 7>) -> Self

Connects data line 7 (completes the 8-bit bus).

Source

pub fn with_card_detect(self, cd: impl PeripheralInput<'d>) -> Self

Connects the card-detect input.

Source

pub fn with_write_protect(self, wp: impl PeripheralInput<'d>) -> Self

Connects the write-protect input.

Source

pub fn with_power_enable(self, power: impl PeripheralOutput<'d>) -> Self

Connects a GPIO used to switch card power. Driven high here.

Source

pub fn is_card_present(&self) -> bool

Returns true if a card is detected, or if no card-detect pin is wired (assume present).

Source

pub fn is_write_protected(&self) -> bool

Returns true if the card reports write protection. Returns false if no write-protect pin is wired. Polarity follows SlotConfig::with_wp_active_high.

Source

pub fn set_bus_low_level( &mut self, width: BusWidth, hz: u32, ) -> Result<(), Error>

Caches bus width and card clock; HW is programmed on the next engine op.

Source

pub fn send_init_sequence(&mut self) -> Result<(), BlockingError>

Issues the 80-clock SD init sequence (no command index).

Source

pub fn command_blocking( &mut self, index: u8, arg: u32, resp_len: ResponseLen, check_crc: bool, flags: CommandFlags, ) -> Result<[u32; 4], BlockingError>

Issues a no-data command and returns its raw response words.

Source

pub fn read_blocks_blocking( &mut self, cmd_index: u8, arg: u32, buf: DmaAlignedMut<'_, [u8]>, block_size: u16, block_count: u32, ) -> Result<[u32; 4], BlockingError>

Reads block_count blocks into a DMA-capable buffer (CMD17/CMD18).

Source

pub fn write_blocks_blocking( &mut self, cmd_index: u8, arg: u32, buf: DmaAlignedMut<'_, [u8]>, block_size: u16, block_count: u32, ) -> Result<[u32; 4], BlockingError>

Writes block_count blocks from a DMA-capable buffer (CMD24/CMD25).

Source§

impl<'d, const S: u8> Slot<'d, S, Blocking>

Source

pub fn into_async(self) -> Slot<'d, S, Async>

Reconfigures the slot to operate in Async mode.

Binds the SDHOST interrupt handler and enables interrupt delivery.

Source§

impl<'d, const S: u8> Slot<'d, S, Async>

Source

pub fn into_blocking(self) -> Slot<'d, S, Blocking>

Reconfigures the slot back to Blocking mode.

Source

pub fn wait_for_sdio_interrupt(&mut self) -> impl Future<Output = ()>

Waits for the SDIO card interrupt (card pulls DAT1 low).

Trait Implementations§

Source§

impl<'d, const S: u8> MmcBus for Slot<'d, S, Async>

Available on crate feature unstable only.
Source§

async fn wait_for_event(&mut self) -> Result<(), MmcError>

Wait for DAT1 to be pulled low.
Source§

async fn send_command<'a, C>(&mut self, cmd: C) -> Result<C::Resp<'a>, MmcError>
where C: ControlCommand + 'a,

Send a command that has no data transfer (e.g., CMD0, CMD8, CMD55). Read more
Source§

async fn read_blocks<'a, C>( &mut self, cmd: C, auto_stop: bool, ) -> Result<C::Resp<'a>, MmcError>
where C: BlockReadCommand + 'a,

Read N blocks of fixed size (CMD17, CMD18, CMD53 block mode). Read more
Source§

async fn write_blocks<'a, C>( &mut self, cmd: C, auto_stop: bool, ) -> Result<C::Resp<'a>, MmcError>
where C: BlockWriteCommand + 'a,

Write N blocks of fixed size (CMD24, CMD25, CMD53 block mode). Read more
Source§

async fn read_bytes<'a, C>(&mut self, cmd: C) -> Result<C::Resp<'a>, MmcError>
where C: ByteReadCommand + 'a,

Read an arbitrary number of bytes (CMD53 byte mode, SPI multi-byte).
Source§

async fn write_bytes<'a, C>(&mut self, cmd: C) -> Result<C::Resp<'a>, MmcError>
where C: ByteWriteCommand + 'a,

Write an arbitrary number of bytes (CMD53 byte mode, SPI multi-byte).
Source§

async fn init_idle(&mut self, hz: u32) -> Result<(), MmcError>

Initialize the bus in one-bit mode at 3.3v and the requested frequency. Read more
Source§

fn set_bus(&mut self, width: BusWidth, hz: u32) -> Result<(), MmcError>

Configure bus width and frequency. Read more
Source§

fn supports_mmc(&self) -> bool

Optional: whether the host supports native MMC mode. Otherwise, SPI mode is used.
Source§

fn supports_auto_stop(&self) -> bool

Optional: whether the host supports the ‘auto stop’ feature.
Source§

fn supports_bus_width(&self) -> BusWidth

Optional: the maximum bus width available to the host
Source§

fn supports_frequency(&self) -> u32

Optional: the maximum frequency supported by this bus. Defaults to 25Mhz
Source§

fn tune_bus<O>( &mut self, width: BusWidth, hz: u32, op: O, ) -> impl Future<Output = Result<(), MmcError>>
where O: TuningOp,

Tune the bus, if required. Called after the bus is set to the target frequency; needed for uhs.
Source§

fn supports_1v8(&self) -> bool

Optional: whether the host supports 1.8v. If true, send_command will be called with CMD11.

Auto Trait Implementations§

§

impl<'d, const S: u8, Dm> !UnwindSafe for Slot<'d, S, Dm>

§

impl<'d, const S: u8, Dm> Freeze for Slot<'d, S, Dm>
where PhantomData<(&'d mut (), Dm)>: Freeze,

§

impl<'d, const S: u8, Dm> RefUnwindSafe for Slot<'d, S, Dm>
where PhantomData<(&'d mut (), Dm)>: RefUnwindSafe,

§

impl<'d, const S: u8, Dm> Send for Slot<'d, S, Dm>
where PhantomData<(&'d mut (), Dm)>: Send,

§

impl<'d, const S: u8, Dm> Sync for Slot<'d, S, Dm>
where PhantomData<(&'d mut (), Dm)>: Sync,

§

impl<'d, const S: u8, Dm> Unpin for Slot<'d, S, Dm>
where PhantomData<(&'d mut (), Dm)>: Unpin,

§

impl<'d, const S: u8, Dm> UnsafeUnpin for Slot<'d, S, Dm>
where PhantomData<(&'d mut (), Dm)>: UnsafeUnpin,

Blanket Implementations§

§

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

§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

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

§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
§

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

§

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

Mutably borrows from an owned value. Read more
§

impl<T> From<T> for T

§

fn from(t: T) -> T

Returns the argument unchanged.

§

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

§

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> Same for T

Source§

type Output = T

Should always be Self
§

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

§

type Error = Infallible

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

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

Performs the conversion.
§

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

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

Performs the conversion.