pub struct R1Response {
pub raw: u32,
}Expand description
R1: Standard response — contains status bits
Fields§
§raw: u32Implementations§
Source§impl R1Response
impl R1Response
Sourcepub fn from_native_raw(raw: u32) -> Result<Self, Error>
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.
Sourcepub fn from_spi_byte(byte: u8) -> Result<Self, Error>
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.
Sourcepub fn spi_card_error(&self) -> Option<CardError>
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.
Sourcepub fn from_raw(raw: u32) -> Result<Self, Error>
👎Deprecated: use from_native_raw or from_spi_byte instead
pub fn from_raw(raw: u32) -> Result<Self, Error>
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).
Sourcepub fn erase_reset(&self) -> bool
pub fn erase_reset(&self) -> bool
Erase reset
Sourcepub fn illegal_command(&self) -> bool
pub fn illegal_command(&self) -> bool
Illegal command
Sourcepub fn command_crc_failed(&self) -> bool
pub fn command_crc_failed(&self) -> bool
Command CRC failed
Sourcepub fn current_state(&self) -> CardState
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.
Sourcepub fn card_is_locked(&self) -> bool
pub fn card_is_locked(&self) -> bool
Card is locked (native R1 only)
Sourcepub fn ready_for_data(&self) -> bool
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.
Sourcepub fn switch_error(&self) -> bool
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
impl Clone for R1Response
Source§fn clone(&self) -> R1Response
fn clone(&self) -> R1Response
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for R1Response
impl Debug for R1Response
Source§impl PartialEq for R1Response
impl PartialEq for R1Response
Source§fn eq(&self, other: &R1Response) -> bool
fn eq(&self, other: &R1Response) -> bool
self and other values to be equal, and is used by ==.