SPI
SPISettings
Since 0.6.2:
The SPISettings object specifies the SPI peripheral settings. This object can be used with beginTransaction() function and can replace separate calls to setClockSpeed(), setBitOrder() and setDataMode().
| SPISettings | __SPISettings | |
|---|---|---|
| Available in Device OS | 0.6.1 | 0.6.2 |
Requires #include "Arduino.h |
0.6.2 - 1.5.2 | No |
| Available in 2.0.0 and later | ✓ | ✓ |
You should use SPISettings() with 2.0.0 and later, with or without #include "Arduino.h.
__SPISettings() can be used in 0.6.2 and later for backward compatibility with those versions of Device OS, but is unnecessary for 2.0.0 and later.
// SYNTAX
SPI.beginTransaction(SPISettings(4*MHZ, MSBFIRST, SPI_MODE0));
// Pre-declared SPISettings object
SPISettings settings(4*MHZ, MSBFIRST, SPI_MODE0);
SPI.beginTransaction(settings);
Parameters:
clockSpeed: maximum SPI clock speed (seesetClockSpeed())bitOrder: bit order of the bits shifted out of and into the SPI bus, eitherLSBFIRST(least significant bit first) orMSBFIRST(most-significant bit first)dataMode:SPI_MODE0,SPI_MODE1,SPI_MODE2orSPI_MODE3(seesetDataMode())