I’m trying to use two esp32’s….one as a SPI MASTER and the other as an SPI SLAVE. I can’t find any code to help with a simple example. All the Arduino code I find uses things like :
// Enable SPI as slave.
SPCR = (1 << SPE);
which the IDE doesn’t understand (doesn’t recognize SPCR or SPE) for the esp32.
Can anyone point me to a clear example of working SPI MASTER and SLAVE code? Thanks.
Hi Donald.
I don’t have an example on how to do that.
But, you can take a look at the spi_master.h and spi_slave.h files and see if you can figure out:
https://github.com/espressif/arduino-esp32/blob/master/tools/sdk/include/driver/driver/spi_master.h
https://github.com/espressif/arduino-esp32/blob/master/tools/sdk/include/driver/driver/spi_slave.h
You can also take a look at the IDF documentation:
https://docs.espressif.com/projects/esp-idf/en/latest/api-reference/peripherals/spi_slave.html#_CPPv420spi_slave_initialize17spi_host_device_tPK16spi_bus_config_tPK28spi_slave_interface_config_ti
I hope this helps.
Regards,
Sara