Functions that start with ``wiringPiSPIx`` are new since version 3, allowing the SPI bus number to be specified. This is especially useful for the Compute Module, which has multiple SPI buses (0-7). The old functions remain available, but they always refer to SPI bus 0, which is available on the 40 pin GPIO connector.
-
### wiringPiSPISetup / wiringPiSPISetupMode / wiringPiSPIxSetupMode
- Opens the specified SPI bus.
+ Opens the specified SPI bus. The Raspberry Pi has 2 channels, 0 and 1. The speed parameter is an integer in the range of 500,000 through 32,000,000 and represents the SPI clock speed in Hz.
- >>>
```C
- int wiringPiSPISetup (int channel, int speed)
- int wiringPiSPISetupMode (int channel, int speed, int mode)
- int wiringPiSPIxSetupMode(const int number, const int channel, const int speed, const int mode)
+ int wiringPiSPISetup (int channel, int speed);
+
-int wiringPiSPISetup (int channel, int speed, int mode);
++int wiringPiSPISetupMode (int channel, int speed, int mode);
+
+ int wiringPiSPIxSetupMode(const int number, const int channel, const int speed, const int mode);
```
- ``number``: SPI muber (typically 0, on Compute Module 0-7).
+ ``number``: SPI number (typically 0, on Compute Module 0-7).
``channel``: SPI channel (typically 0 or 1, on Compute Module 0-3).
- ``speed``: SPI clock.
- ``mode``: SPI mode (https://www.kernel.org/doc/Documentation/spi/spidev).
- ``Return Value``: File handle to the SPI bus
- > -1 ... Error or EXIT (Programm termination)
+ ``speed``: SPI clock speed in Hz (500,000 to 32,000,000).
+ ``mode``: SPI mode ([www.kernel.org/doc/Documentation/spi/spidev](https://www.kernel.org/doc/Documentation/spi/spidev)).
+ ``Return Value``: File handle to the SPI bus, or -1 on error.
+
+ **Example**
- **Example**
- >>>
```C
const int spiChannel = 1;
const int spiSpeedInit = 250000; // Hz