This library provides functions for transferring information using the Serial Peripheral Interface (SPI). The SPI interface is automatically initialized when the Spi library is included in a sketch. It sets the following digital I/O pins:
pin 13 SCK SPI clock pin 12 MISO SPI master in, slave out pin 11 MOSI SPI master out, slave in pin 10 SS SPI slave select
The default SPI configuation is as follows:
SPI Master enabled MSB of the data byte transmitted first SPI mode 0 (CPOL = 0, CPHA = 0) SPI clock frequency = system clock / 4
The Spi download contains the Spi library.
Example: Spi.mode((1<<CPOL) | (1 << CPHA)); // set SPI mode 3 or Spi.mode((<<SPR0)); // set SPI clock to system clock / 16
Example: n = Spi.transfer(0x2A); // sends the byte 0x2A // and returns the byte received
Example:
n = Spi.transfer(0x2A, 2); // waits 2 usec, then sends the byte 0x2A
// and returns the byte received