This example shows how to configure SPI slave by POSIX APIs, this decreases dependence on hardware and platform.
Before project configuration and build, be sure to set the correct chip target using idf.py set-target <chip_name>
.
And this example should be used together with SPI Master Simple.
Open the project configuration menu (idf.py menuconfig
).
In the Example Configuration
menu:
Select SPI Device
option, please note that not all SoC supports SPI3
SPI CS Pin Number
SPI SCLK Pin Number
SPI MOSI Pin Number
SPI MISO Pin Number
Run idf.py -p PORT flash monitor
to build, flash and monitor the project.
(To exit the serial monitor, type Ctrl-]
.)
As you run the example ,you will see the following log:
Plaintext
I (0) cpu_start: Starting scheduler on APP CPU.
I (344) ext_vfs: Extended VFS version: 0.3.0
Opening device /dev/spi/2 for writing OK, fd=3.
Receive total 32 bytes from device: SPI Tx 0
Receive total 32 bytes from device: SPI Tx 1
Receive total 32 bytes from device: SPI Tx 2
Receive total 32 bytes from device: SPI Tx 3
Receive total 32 bytes from device: SPI Tx 4
Receive total 32 bytes from device: SPI Tx 5
Receive total 32 bytes from device: SPI Tx 6
Receive total 32 bytes from device: SPI Tx 7
Receive total 32 bytes from device: SPI Tx 8
Receive total 32 bytes from device: SPI Tx 9
Receive total 32 bytes from device: SPI Tx 10
Receive total 32 bytes from device: SPI Tx 11
To create a project from this example, run:
idf.py create-project-from-example "espressif/extended_vfs=0.3.2:spi_slave_simple"