SPI

The Serial Peripheral Interface Bus or SPI bus is a synchronous serial data link standard named by Motorola that operates in full duplex mode. Devices communicate in a master/slave mode where the master device initiates the data frame. Multiple slave devices are allowed with individual slave select (chip select) lines using a pin for each device. There is a wide availability of sensors that communicate using SPI as protocol. Check the examples included with the library.

Including this library automatically defines constants for the pins involved: SS, SCK, MOSI, MISO, making it possible to use them in regular commands like: digitalWrite(SS, HIGH); For the physical location of these pins check the hardware reference. On Wiring v1 boards the SPI pins are: SS=24, MOSI=25, MISO=26 and SCK=27. On Wiring S board the SPI pins are: SS=20, MOSI=21, MISO=22 and SCK=23.

SPI
Wiring I/O board internal SPI.

begin()
Starts SPI communication.

end()
Stops SPI communication.

transfer()
Exchanges bytes of data.

setBitOrder()
Sets the bit order to use for SPI communication.

setDataMode()
Sets the SPI communication mode.

setClockDivider()
Sets clockDivider for the SPI communication speed.

attachInterrupt()
Activate the SPI interrupt and attaches a function to be executed when the SPI transfer complete interruption is generated during communication.

detachInterrupt()
Deactivate the SPI interrupt and detaches the interruption function.