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.

SPI.beginTransaction(SPISettings(4*MHZ, MSBFIRST, SPI_MODE0));
// Pre-declared SPISettings object
SPISettings settings(4*MHZ, MSBFIRST, SPI_MODE0);


  • clockSpeed: maximum SPI clock speed (see setClockSpeed())
  • bitOrder: bit order of the bits shifted out of and into the SPI bus, either LSBFIRST (least significant bit first) or MSBFIRST (most-significant bit first)
  • dataMode: SPI_MODE0, SPI_MODE1, SPI_MODE2 or SPI_MODE3 (see setDataMode())