33 lines
1.1 KiB
Plaintext
33 lines
1.1 KiB
Plaintext
|
= SPI =
|
||
|
|
||
|
SPI or Serial peripheral interface is the standard often used as a form of
|
||
|
interchip communication on boards, and in embedded devices.
|
||
|
|
||
|
See https://www.youtube.com/watch?v=MCi7dCBhVpQ
|
||
|
|
||
|
== Layout ==
|
||
|
|
||
|
Each device, the master and slave (often microcontroler as master and
|
||
|
peripheral/sensor as slave) have four pins
|
||
|
|
||
|
* SCK - Serial Clock
|
||
|
* CS - Chip select (active low)
|
||
|
* SDI - Serial data in
|
||
|
* SDO - Serial data out
|
||
|
|
||
|
NOTE serial data * is from the persepctive of the device (SDI on master is
|
||
|
connected to SDO on slave and vice versa).
|
||
|
|
||
|
SDO on the master to SDI on the peripherial is often called MOSI (Master out
|
||
|
Slave in), and the inverse is often called MISO (Master in Slave out).
|
||
|
|
||
|
Some chips may only have a MOSI, as some devices do not create data to send
|
||
|
back to the master.
|
||
|
|
||
|
== Sending data ==
|
||
|
|
||
|
On the *rising edge* of the clock, each device reads what is currently set on
|
||
|
the respective input port. The chip must also have its output set before the
|
||
|
rising edge, to ensure that the device will receive the data it intends to
|
||
|
send. All of this only occurs when CS is set low.
|