Current repo contains the examples of usage of the embedded-sdmmc library with esp32 with no-std and std approaches. The no-std example is located at /examples/esp-hal and the std one at /examples/esp-idf-hal WIP
Look at the embedded_sdmmc docs to better understand why in the
SpiDevicetheDummyCsPinis used rather then the actualpspin (inesp-halexample)
esp-halprovides only theSpi-driver and it implements only the SpiBus, but theSdCardrequires SpiDevice trait implemented, so we need the embedded-hal-bus. More info at esp-hal
Inspired by this example but it uses older versions of the esp-hal and embedded-sdmmc
WIP
Both examples were tested on the esp-wroom-32 dev-board. There is a good page with information about ESP32 SPI communication. Generally encouraged to read through it before running the examples for better understanding.
For the sake of brevity, esp32 has 2 spi interfaces available for usage in projects: spi2 (aka HSPI) and spi3 (aka VSPI). I chose to use the VSPI interface (pins are more conveniently located), so the following pins are used:
- MOSI (serial_out): GPIO23
- MISO (serial_in): GPIO19
- SCLK (sclk): GPIO18
- CS (cs): GPIO5
Connect the
VCCpin of thesd-card moduleto the 5V source. In case of 3.3V thesdcard won't respond to any command and you will get an errorTimeoutACommand. But actually you should check the datasheet of yoursd-card moduleto check the appropriate voltage. VCC (vcc): 5V
The spi bus can be used exclusively or can be shared among different devices. So, examples are implemented for both situations.
To run specific example move to the appropriate directory (examples/esp-hal for the no-std or examples/esp-idf-hal for the std WIP) and run the following command:
cargo run --release -F exclusive
or
cargo run --release -F shared