Overview of SPI

Serial Peripheral Interface (SPI) is typically used on external non-volatile memory and graphical displays, where faster data transfer rates and high bandwidth are required. Many sensor devices support SPI in addition to I2C.

SPI shares some characteristics with I2C. It is a synchronous serial interface, which means it relies on a shared clock signal to synchronize data transfer between devices. Because of the shared clock signal, SPI also has a master-slave architecture, where the master controls the triggering of the clock signal and all other connected peripherals are slaves

SPI is faster than I2C. The clock signal for data transfer is typically in the range of 16 MHz to 25 MHz.

Another similarity with I2C is that it supports multiple slaves.

But there are also some differences. While I2C is semi-duplex, SPI supports full-duplex data transfer, meaning the master and slave can simultaneously exchange information. This is achieved by having a wire to transmit from the master to the slaves and another one from the slaves to the master, which makes SPI a minimum 4-wire interface:

  • Master Out Slave In (MOSI)
  • Master In Slave Out (MISO)
  • Shared Clock Signal (CLK or SCL)
  • Common Ground Reference (GND)
SPI structure diagram from developers.google.com

The other key difference is that the slaves are addressed via hardware instead of software. Each SPI slave has a chip select pin to allow the master to address that particular device. Addressing is necessary for data transfer, since all the slaves share the same bus. Chip select is not mandatory when the bus has a single slave.

Sometimes, SPI breakout circuits do not expose the CS. In that case, that peripheral needs to be the only slave on the bus.

And, as for any example with peripherals, when using SPI we need to add the required permission to the manifest:

<uses-permission android:name="com.google.android.things.permission.USE_PERIPHERAL_IO" />

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.139.233.43