Classes | Macros | Variables


The SPI (Serial Peripheral Interface) API provides for data communication between the processor and various peripheral devices over a synchronous external serial port. On LinkIt ONE, SPI needs the following 3 pins to complete communication (see Table below):

  • MISO (Master In Slave Out): Transmits data from slave to master.
  • MOSI (Master Out Slave In): Transmits data from master to slave.
  • SCK (Serial Clock): Serial clock output from master, used to sync signal timing between master and slave.


LinkIt ONE 



As many slaves may be connected to one master at the same time, the SS (Slave Select) pin enables the Master to selects the slave to communicate with. When the SS signal of a slave is at low voltage, the master will start communicating with it. 


The SPI communication protocol is very flexible; therefore before conducting data exchange using SPI, please pay extra attention to the slaves??configuration tables. Only when relevant parameter settings comply with the demand from the slave can the master and slave start normal data communication. Before using a new slave, please answer the following questions first:

  • Is the device? process for sending and receiving data "MSB first" or "LSB first"? (You set this up in setBitOrder().)
  • Is the clock of the device at high voltage or low voltage when it? idle? Does data exchange occur at the rising edge or falling edge of the clock cycle? (You set this up in setDataMode().)
  • What is the transmission speed required by the slave? (You set this up in setClockDivider().)
After all the questions above are answered and the appropriate parameters set, you can use LinkIt ONE to control the device. 



Hardware setup 

The SPI and built-in SD card functions are exclusive. Before using the SPI API, make sure the settings switch is correctly set (see Figure below). Please note that once the board is configured to SPI, calling SD APIs may result in unexpected SPI behavior. 


Figure : The SPI/SD switch 


If you want to use SPI and SD functions at the same time, please use an external SD shield. 


On LinkIt ONE, the LinkIt processor can be used as the master only; therefore other peripheral devices can be used as slaves only.

SPI class interface is used to control SPI port to conduct data communication between the processor and multitudes of peripheral devices. 
SPI clock is 1/128 of the system clock. 
SPI clock is 1/16 of the system clock. 
SPI clock is 1/2 of the system clock. 
SPI clock is 1/32 of the system clock. 
SPI clock is 1/4 of the system clock. 
SPI clock is 1/64 of the system clock. 
SPI clock is 1/8 of the system clock. 
SPI data transfer mode 0. 
SPI data transfer mode 1. 
SPI data transfer mode 2. 
SPI data transfer mode 3. 
The SPI object.