Skip to content

The example of usage of the esp-hal and esp-idf-hal (WIP) with the embedded-sdmmc library over SPI in Rust

License

Notifications You must be signed in to change notification settings

syrtcevvi/rust-esp32-embedded-sdmmc

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 

Repository files navigation

Esp32 and embedded-sdmmc esp-hal and esp-idf-hal examples

embedded_sdmmc embedded-hal-bus esp-hal esp32

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 SpiDevice the DummyCsPin is used rather then the actual ps pin (in esp-hal example)

esp-hal provides only the Spi-driver and it implements only the SpiBus, but the SdCard requires SpiDevice trait implemented, so we need the embedded-hal-bus. More info at esp-hal

esp-hal example

Inspired by this example but it uses older versions of the esp-hal and embedded-sdmmc

esp-idf-hal example

WIP

Running examples

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 VCC pin of the sd-card module to the 5V source. In case of 3.3V the sd card won't respond to any command and you will get an error TimeoutACommand. But actually you should check the datasheet of your sd-card module to 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

About

The example of usage of the esp-hal and esp-idf-hal (WIP) with the embedded-sdmmc library over SPI in Rust

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published