Skip to main content

R1Response

Struct R1Response 

Source
pub struct R1Response {
    pub raw: u32,
}
Expand description

R1: Standard response — contains status bits

Fields§

§raw: u32

Implementations§

Source§

impl R1Response

Source

pub fn from_native_raw(raw: u32) -> Result<Self, Error>

Parse a native (SDIO/SDHCI) 32-bit R1 response.

Card error bits live in bits 19..=24. If any error bit is set this returns Err(Error::CardError(..)). Otherwise the raw value is preserved.

Source

pub fn from_spi_byte(byte: u8) -> Result<Self, Error>

Parse a single-byte SPI R1 response.

SPI R1 has a fixed 0 start bit (the high bit must be clear). The remaining bits encode informational state (idle, erase reset) and soft error flags (illegal command, CRC error, …). Because some flags — especially illegal_command — are expected during initialization (e.g. CMD8 on SD v1 cards), this function does NOT itself convert flag bits into Err. Callers should inspect the helpers (R1Response::illegal_command etc.) to decide what to do.

Returns Err(Error::BadResponse(_)) when the high bit is set, which indicates a malformed response or that no R1 byte arrived.

Source

pub fn spi_card_error(&self) -> Option<CardError>

Decode error flag bits in a SPI R1 response into a CardError.

Returns None when no error bits are set. Only meaningful for values produced by R1Response::from_spi_byte; native R1 layouts use a different bit mapping and report errors directly through R1Response::from_native_raw.

Source

pub fn from_raw(raw: u32) -> Result<Self, Error>

👎Deprecated:

use from_native_raw or from_spi_byte instead

Backwards-compatible parser. Prefer R1Response::from_native_raw for SDIO/native transports and R1Response::from_spi_byte for SPI mode.

This is retained because external code may still call it. The behavior matches from_native_raw for values larger than 0xFF and treats smaller values as raw SPI bytes (decoding their error bits as such).

Source

pub fn idle(&self) -> bool

Card is in idle state

Source

pub fn erase_reset(&self) -> bool

Erase reset

Source

pub fn illegal_command(&self) -> bool

Illegal command

Source

pub fn command_crc_failed(&self) -> bool

Command CRC failed

Source

pub fn current_state(&self) -> CardState

Current state of the card state machine (bits 12:15).

Only meaningful for native (SDIO) R1 responses; SPI R1 bytes do not encode card state.

Source

pub fn card_is_locked(&self) -> bool

Card is locked (native R1 only)

Source

pub fn ready_for_data(&self) -> bool

READY_FOR_DATA (bit 8): card buffer is empty and the next data transfer can be issued. Used after R1b commands (CMD7, CMD12, MMC CMD6 SWITCH) to know when the busy line has cleared.

Only meaningful for native (SDIO) R1 responses.

Source

pub fn switch_error(&self) -> bool

SWITCH_ERROR (bit 7): the previous MMC CMD6 SWITCH was rejected (e.g. invalid EXT_CSD field, value out of range). Surfaces here because CMD6 itself returns R1b with this bit, but most error reporters hide bits 0..15.

Trait Implementations§

Source§

impl Clone for R1Response

Source§

fn clone(&self) -> R1Response

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 R1Response

Source§

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

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

impl PartialEq for R1Response

Source§

fn eq(&self, other: &R1Response) -> 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 R1Response

Source§

impl Eq for R1Response

Source§

impl StructuralPartialEq for R1Response

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.