PHPoC provides Serial Peripheral Interface (SPI) as one of methods to communicate with other serial device.
SPI requires 4 signal lines between a master and a slave.
|SCK||Serial Clock||clock for synchronization|
|MOSI||Master Output, Slave Input||master's transmission line|
|MISO||Master Input, Slave Output||slave's transmission line|
|SS||Slave Select||master's slave select line|
A master's three lines except for SS are commonly connected to all slaves while SS is separately connected to individual slave. Therefore, a master which has three slaves should have at least three SS ports. To select a slave, the master outputs LOW to the line which is connected to the slave and output HIGH to the other lines. That means a master can communicate with a single slave at a time. After finishing communication, the master outputs HIGH to the line.
There are four SPI modes (0 ~ 3) according to the sampling methods.
A master and a slave should be set to have the same bit transmission order. There are two ways: One is to send LSB first and the other is to send MSB first.
Data buffer of a master and a slave has a type of ring buffer. Thus, sending and receiving data are simultaneously implemented at all times. The following figure shows data flow in case of sending LSB first.