Skip to main content

Command

Struct Command 

Source
pub struct Command {
    pub cmd: u8,
    pub arg: u32,
    pub resp_type: ResponseType,
}
Expand description

SD/MMC command definitions

Fields§

§cmd: u8§arg: u32§resp_type: ResponseType

Implementations§

Source§

impl Command

Source

pub const fn new(cmd: u8, arg: u32, resp_type: ResponseType) -> Self

Source

pub const fn with_resp_type(self, resp_type: ResponseType) -> Self

Return a copy of this command with resp_type overridden.

Useful when the same command index has different response types depending on the transport (e.g. ACMD41 returns R3 in native mode but the OCR is not available in SPI mode where only an R1 byte is returned).

Source

pub fn index(&self) -> u8

Command index (0–63)

Source

pub fn argument(&self) -> u32

32-bit argument

Source

pub const fn data_direction(&self) -> DataDirection

Direction of the data phase that follows this command.

Note: SDIO CMD53 carries its direction in the argument; this helper returns None for it. CMD6 is also returned as None because the same command index is reused for ACMD6 (SET_BUS_WIDTH, no data phase) and CMD6 SWITCH_FUNC (64-byte read). Drivers that issue SWITCH_FUNC choose the read-data submit path explicitly.

Source

pub const fn data_block_size(&self) -> Option<u32>

Size (in bytes) of the data block this command transfers, when the answer is unambiguous from the command index alone.

Returns None for commands without a data phase, for commands whose block size depends on host configuration (e.g. CMD16-controlled SDSC blocks), and for indices that are reused across commands with different data shapes (e.g. CMD6).

Source

pub fn crc7(&self) -> u8

Compute the 7-bit CRC for SPI mode transmission

Source

pub fn to_spi_bytes(&self) -> [u8; 6]

Build the 6-byte SPI command packet

Trait Implementations§

Source§

impl Clone for Command

Source§

fn clone(&self) -> Command

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Command

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl PartialEq for Command

Source§

fn eq(&self, other: &Command) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Copy for Command

Source§

impl Eq for Command

Source§

impl StructuralPartialEq for Command

Auto Trait Implementations§

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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.