SPI is a synchronous protocol interface, all transfers refer to the same clock (generated by the processor)
When multiple devices are connected to the same SPI port of the host, the host selects the chip through the chip select signal
SPI mainly has 4 signals
MOSI: master output/slave input
MISO: master input/slave output
SCK: Clock Trust
CS: chip select signal
As shown in the figure above, both the master and the slave contain a shift register. When the master sends data to the slave, the slave also sends data to the master. Writing data and reading data are performed synchronously.
Write operation: the master ignores the data sent by the slave
Read operation: The master sends a null byte to the slave