SD Card pin numbers for use with SPI
| LilyGo Pin Name | GPIO # | SPI |
|---|
| SDMMC_D0 | 14 | MISO |
| SDMMC_D1 | 17 | |
| SDMMC_D2 | 21 | |
| SDMMC_D3 | 18 | CS |
| SDMMC_CLK | 12 | SCK |
| SDMMC_CMD | 16 | MOSI |
Example
let spi_bus = Spi::new(
peripherals.SPI2,
spi::master::Config::default()
.with_frequency(Rate::from_khz(400))
.with_mode(spi::Mode::_0),
)
.unwrap()
.with_sck(peripherals.GPIO12) // clk
.with_mosi(peripherals.GPIO16) // cmd
.with_miso(peripherals.GPIO14) // d0
.into_async();
let sd_cs = Output::new(
peripherals.GPIO18, // d3
Level::High,
OutputConfig::default().with_pull(Pull::Up),
);
let spi_dev = ExclusiveDevice::new(spi_bus, sd_cs, Delay).unwrap();
let sdcard = SdCard::new(spi_dev, Delay);