Back to Esp Idf

README

examples/peripherals/spi_slave/README.md

6.1-dev1.9 KB
Original Source
Supported TargetsESP32ESP32-C2ESP32-C3ESP32-C5ESP32-C6ESP32-C61ESP32-H2ESP32-H21ESP32-H4ESP32-P4ESP32-S2ESP32-S3

SPI slave example

These two projects illustrate the SPI Slave driver. They're supposed to be flashed into two separate Espressif chips connected to each other using the SPI pins defined in app_main.c. Once connected and flashed, they will use the spi master and spi slave driver to communicate with each other. The example also includes a handshaking line to allow the master to only poll the slave when it is actually ready to parse a transaction.

Connection

For different chip and host used, the connections may be different. Here show a example diagram of hardware connection, you can freely change the GPIO settings by editing defines in the top of main/app_main.c in the master/slave source code. and change the hardware relatively.

The default GPIOs used in the example are the following:

<table> <tr align="middle"> <th bgcolor=#ffffcc>Signal</th> <td>Handshake</td> <td>MOSI</td> <td>MISO</td> <td>SCLK</td> <td>CS</td> </tr> <tr align="middle"> <th bgcolor=#ffffcc>Pin</th> <td>GPIO2</td> <td>GPIO12</td> <td>GPIO13</td> <td>GPIO15</td> <td>GPIO14</td> </tr> </table>

Please run wires between the following GPIOs between the slave and master to make the example function:

SlaveMaster
HandshakeHandshake
MOSIMOSI
MISOMISO
SCLKSCLK
CSCS

Be aware that the example by default uses lines normally reserved for JTAG on ESP32. If this is an issue, either because of hardwired JTAG hardware or because of the need to do JTAG debugging, feel free to change the GPIO settings.