Libraries
\ SPI
Reference for Wiring version 1.0 Build 0100+ If you have a previous version, use the reference included with your software. If see any errors or have any comments, let us know.
Name |
begin() |
Examples |
SPI.begin();
SPI.begin(SPI_MASTER, LSBFIRST, SPI_MODE3, SPI_CLOCK_DIV4);
|
Description |
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. The begin() method starts SPI communication. 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. |
Syntax |
SPI.begin()
SPI.begin(mode,bitOrder,dataMode,clockDivider)
|
Parameters |
mode |
constant for the mode of operation: SPI_MASTER (master) or SPI_SLAVE (slave) |
bitOrder |
MSBFIRST or LSBFIRST: the bit order to use. MSBFIRST stands for most significant bit first (leftmost bit), LSBFIRST stands for less significant bit first (rightmost bit). |
dataMode |
constant for the data mode: SPI_MODE0 (leading edge Sample rising, trailing edge Setup falling), SPI_MODE1 (leading edge Setup rising, trailing edge Sample falling), SPI_MODE2 (leading edge Sample falling, trailing edge Setup rising), SPI_MODE3 (leading edge Setup falling, trailing edge Sample rising) |
clockDivider |
constant for the speed clock divider used for the communication, clockDivider is a fraction of the main CPU clock speed: SPI_CLOCK_DIV4 (1/4th of the CPU speed), SPI_CLOCK_DIV16 (1/16th of the CPU speed), SPI_CLOCK_DIV64 (1/64th of the CPU speed), SPI_CLOCK_DIV128 (1/128th of the CPU speed), SPI_CLOCK_DIV2 (1/2 of the CPU speed), SPI_CLOCK_DIV8 (1/8th of the CPU speed), SPI_CLOCK_DIV32 (1/32th of the CPU speed) or SPI_CLOCK_DIV64 (1/64th of the CPU speed) |
|
Returns |
None |
Usage |
Application |
Updated on July 07, 2011 11:11:42pm PDT