1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
//! `no_std` SD/MMC protocol building blocks for embedded systems.
//!
//! This crate provides protocol-level types and driver skeletons for SD,
//! MMC and SDIO cards. It is transport-agnostic at the trait level and
//! brings its own SPI-mode driver plus an SDIO host-controller abstraction.
//!
//! # What you get
//!
//! - [`cmd::Command`] / [`cmd::DataDirection`]: SD/MMC command opcodes,
//! argument encoding and per-command data direction.
//! - [`response::Response`] and friends ([`response::CidResponse`],
//! [`response::CsdResponse`], [`response::SwitchStatus`], ...): typed
//! parsers for the response formats defined in the SD spec.
//! - [`error::Error`]: a single error enum the drivers and parsers return.
//! - [`spi`] *(feature `spi`, on by default)*: a [`spi::SpiTransport`] trait
//! plus the [`spi::SpiSdmmc`] driver for SPI-mode SD cards. Includes a
//! thin [`spi::SpiDeviceWrapper`] adapter for `embedded-hal` 1.0
//! `SpiDevice<u8>` implementations.
//! - [`sdio`] *(feature `sdio`)*: a [`sdio::SdioHost`] trait that abstracts
//! a host controller and the [`sdio::SdioSdmmc`] driver that drives it
//! through card initialization, block I/O and bus-speed selection.
//!
//! # Cargo features
//!
//! | Feature | Default | Purpose |
//! |----------|---------|-------------------------------------------------|
//! | `spi` | yes | Enables [`spi::SpiTransport`] and [`spi::SpiSdmmc`]. |
//! | `sdio` | no | Enables the host trait and submit/poll data-command contract. |
//!
//! Diagnostic output goes through the [`log`] crate; configure a logger in
//! your application to capture it.
//!
//! # Example
//!
//! ```rust,ignore
//! use embedded_hal::delay::DelayNs;
//! use sdmmc_protocol::{
//! Error,
//! spi::{SpiSdmmc, SpiTransport},
//! };
//!
//! struct MySpi;
//!
//! impl SpiTransport for MySpi {
//! fn transfer_byte(&mut self, byte: u8) -> Result<u8, Error> {
//! # let _ = byte;
//! # Ok(0)
//! }
//! }
//!
//! fn boot<D: DelayNs>(spi: MySpi, delay: D) -> Result<(), Error> {
//! let mut card = SpiSdmmc::new(spi, delay);
//! let _info = card.init()?;
//! let mut block = [0u8; 512];
//! card.read_block(0, &mut block)?;
//! Ok(())
//! }
//! ```
//!
//! # Maturity
//!
//! The SPI path has protocol-level unit tests and basic block read/write
//! support. The SDIO path is a host abstraction skeleton and needs
//! platform-specific validation before use on real hardware.
//!
//! # MSRV
//!
//! Rust 1.85 (the first stable to ship edition 2024).
pub use ;
pub use ;
pub use ;
pub use ;