SPI stands for the Serial Peripheral Interface. SPI is a general-objective synchronous serial interface. During an SPI transfer, send and receive data is simultaneously shifted out and in serially. It was created by Motorola in the mid-1980 for inter-chip communication. The SPI is used to authorise a microcontroller to communicate with peripheral devices such as E2PROMs.
SPI devices transmitted using a master-slave relationship. Because of its lack of built-in device addressing, SPI needs more effort and more hardware resources than I2C when more than one slave is involved. But SPI tends to be easier and more efficient than I2C in point-to-point (single master, single slave) applications for a very similar reason; the lack of device addressing means less overhead.
The SPI protocol uses four wires for communication. These are shown in the figure below −
MOSI − MOSI represents Master Output Slave Input. It can send data from the master to the slave.
MISO − MISO represents Master Input Slave Output. It can send data from the slave to the master.
SCK or SCLK (Serial Clock) − It is frequently used to signal the clock.
SS/CS (Slave Select / Chip Select) − The master uses it to send data by selecting a slave.
There are various uses of SPI, which are as follows −
It can full-duplex communication.
It is used for the arbitrary choice of message sizes, contents and purpose.
It is used for low power requirements.
It has separate MISO and MOSI lines so that the data can be sent and received simultaneously.
It can do simple hardware interfacing.
There is no requirement for a unique address of the slave in this protocol.