Serial Periphiral Interface or SPI is a serial communication protocol which can transter data from sender(called master) to receiver(called slave). This protocol is synchronous communication protocol, which requires a clock pin to send or receive the data. Compared to UART serial communication protocol, it is faster but requires more connection pin.
In this protocol, only master can send data to the slave or read data from the slave. The slave can't send or receive data by itself. Because the clock signal is controlled by the master only. If the master wants to send or read the data, it enables the clock signal.
There can be multiple slave connected to the master and the master can select the slave using the chip enable signal. The master enables the CE signal so that it can perfrom the write or read operation to the selected slave.
After master has selected the slave, it enables the clock signal. The master then sends data bits in each clock signal or master reads the data bits send by the slave in each clock signal. Once the communication is completed, the master disables the clock signal and CE signal.