This project demonstrates Master SPI communication on ESP32 microcontrollers using the Embassy async runtime in a no_std
environment. It is designed to be only used with and to test the slave implementation provided on the other corresponding repo.
- SCLK => GPIO27
- MISO => GPIO35 (input to ESP32) // the master input is not really used as communication is unidirectional
- MOSI => GPIO22 (output from ESP32)
- CS => GPIO21
Signal | Master (ESP32) | Slave |
---|---|---|
SCLK | GPIO27 | GPIO10 |
MISO | GPIO35 | GPIO11 |
MOSI | GPIO22 | GPIO12 |
CS | GPIO21 | GPIO13 |
You should also connect the ground (GND) between the master and slave devices to ensure a common reference point.
- SPI Configuration: 60MHz, Mode 0 (configurable)
- Buffer Size: 2KB (configurable via
CHUNK_SIZE
const) - Tested Transfer Rate: ~40Hz (~82KB/second) (can do more than that)
- Operation: Asynchronous master SPI chunk batch transfer
- Ensure matching buffer sizes between master and slave devices
- The program transmits at regular intervals with some simple data rate printing for debugging
- Use the provided helper functions for transferring SPI, don't let the normal SPI driver provided by the HAL control the CS pin
- Transfer is made by chunks, the bigger the chunks batch the better the performance should be.
- Remember to change to your specific ESP32 version in the
Cargo.toml
file and config the build setup accordingly.
This project uses the Embassy runtime framework and ESP32 HAL. Build with Rust using appropriate feature flags and toolchains (see https://docs.esp-rs.org/book/installation/riscv-and-xtensa.html for complete setup instructions). Flash to your ESP32 using standard ESP tools with cargo run
.
Remember to change to your specific ESP32 version in the Cargo.toml
file and config the build setup accordingly.
See the source code comments and the slave implementation docs for more information.