transfer()

Description

Transfers one byte over the SPI bus, both sending and receiving.
Extended method for Arduino Due
If you specify one of the Arduino Due’s Slave Select (SS) pin in the call to SPI.transfer(), the specified pin is activated (pulled low) before the transfer occurs and deactivated (pulled high) when the transfer is finished.
You can use an additional SPI_CONTINUE or SPI_LAST parameter to manage the Slave Select line after the transfer. SPI_CONTINUE keeps the specified SS pin active (low) after the transfer to allow the send of additional bytes via the transfer() function in the same SPI transaction. The last byte to be transferred should be accompanied by the SPI_LAST parameter. By default, if you don’t specify a third parameter, SPI_LAST is used. When a transfer is complete with SPI_LAST, the slave select pin returns inactive (high).
More info on extended methods: Due Extended SPI usage

Syntax

SPI.transfer(val)
SPI.transfer(slaveSelectPin, val) (Arduino Due only)
SPI.transfer(slaveSelectPin, val, transferMode) (Arduino Due only)

Parameters

val: the byte to send out over the bus
slaveSelectPin: slave device SS pin (Arduino Due only)
transferMode: -SPI_CONTINUE: keeps the SS pin low, allowing a subsequent byte transfer.
-SPI_LAST: default if not specified the SS pin returns to high after one byte has been transferred.
(Optional, Arduino Due only)

Returns

the byte read from the bus.


Libraries Reference Home

The text of the 86Duino reference is a modification of the 86Duino reference, and is licensed under a Creative Commons Attribution-ShareAlike 3.0 License. Code samples in the reference are released into the public domain.