Module stm32h7xx_hal::sdmmc

source ·
Available on crate feature sdmmc only.
Expand description

§SD MultiMediaCard interface (SDMMC)

For HDHC / SDXC / SDUC cards. SDSC cards are not supported.

The H7 has two SDMMC peripherals, SDMMC1 and SDMMC2.

§Examples

§IO Setup

For high speed signaling (bus clock > 16MHz), the IO speed needs to be increased from the default.

use stm32h7xx_hal::gpio::Speed;

let d0 = d0.set_speed(Speed::VeryHigh);

§Usage

By default the SDMMC bus clock is derived from the pll1_q_ck. This can be set when initialising the RCC.

let ccdr = rcc
    .pll1_q_ck(100.MHz())
    .freeze(pwrcfg, &dp.SYSCFG);

There is an extension trait implemented for the SDMMC1 and SDMMC2 peripherals for easy initialisation.

// Create SDMMC
let mut sdmmc = dp.SDMMC1.sdmmc(
    (clk, cmd, d0, d1, d2, d3),
    ccdr.peripheral.SDMMC1,
    &ccdr.clocks,
);

The next step is to initialise a card. The bus speed is also set.

if let Err(err) = sdmmc.init(10.MHz()) {
    info!("Init err: {:?}", err);
}

The card() method returns useful information about the card.

let card = sdmmc.card();
if let Some(card) = sdmmc.card() {
    info!("SD Card Connected: {:?}", card);
}

§High Speed Signaling - SD Card

Up to 25MHz supported

TODO

§High Speed Signaling - eMMC

The following signaling modes are supported for eMMC, assuming that the eMMC device itself supports them

Signaling ModeMaximum FrequencyBus Width
Default Speed (DS)26MHz1-bit, 4-bit or 8-bit
High Speed (HS)52MHz1-bit, 4-bit or 8-bit
DDR5252MHz4-bit or 8-bit

The initialisation routine always uses Default Speed (DS) and thus the specified frequency must be 26MHz or less. For higher frequencies, call set_bus to increase the signalling mode.

sdmmc1.init(26.MHz())?;
sdmmc1.set_bus(Buswidth::Eight, 52.MHz(), EmmcSignaling::DDR52)?;

Structs§

Enums§

  • Possible bus widths
  • Signaling mode for communicating with eMMC. Refer to RM0433 Rev 7 Table 465.
  • Errors
  • Signaling mode for communicating with Sd Cards. Refer to RM0433 Rev 7 Table 465.

Traits§