Provides SPI support.
More...
Provides SPI support.
SPISettings() default Constructor.
SPIBase() default Constructor.
virtual void SPIBase::begin |
( |
| ) |
|
|
pure virtual |
begin(): Initializes the SPI bus by setting SCK, MOSI, and SS to outputs, pulling SCK and MOSI low, and SS high.
Implemented in SPIClass, and SPISoft.
virtual void SPIBase::beginTransaction |
( |
SPISettings |
mySettings | ) |
|
|
pure virtual |
virtual void SPIBase::end |
( |
| ) |
|
|
pure virtual |
virtual void SPIBase::endTransaction |
( |
| ) |
|
|
pure virtual |
endTransaction(): Stop using the SPI bus. Normally this is called after de-asserting the chip select, to allow other libraries to use the SPI bus.
Implemented in SPIClass, and SPISoft.
SPISettings::SPISettings |
( |
int |
speed, |
|
|
uint8 |
byteOrder, |
|
|
uint8 |
dataMode |
|
) |
| |
constructor for SPISettings
Settings are applied to SPI::beginTransaction(SPISettings) and are valid until next beginTransaction()
- Parameters
-
speed | The maximum speed of communication. For a SPI chip rated up to sys clock speed. For 20 MHz, use 20000000. |
byteOrder | MSBFIRST or LSBFIRST |
dataMode | : SPI_MODE0, SPI_MODE1, SPI_MODE2, or SPI_MODE3 |
byteOrder's are:
MSBFIRST Data is sent out starting with Bit31 and down to Bit0
LSBFIRST Data is sent out starting with the lowest BYTE, from MSB to LSB.
0xABCDEFGH would be sent as 0xGHEFCDAB
Data modes are:
Mode Clock Polarity (CPOL) Clock Phase (CPHA)
SPI_MODE0 0 0
SPI_MODE1 0 1
SPI_MODE2 1 0
SPI_MODE3 1 1
virtual unsigned char SPIBase::transfer |
( |
unsigned char |
val | ) |
|
|
pure virtual |
transfer(), transfer16()
SPI transfer is based on a simultaneous send and receive: the received data is returned in receivedVal (or receivedVal16). In case of buffer transfers the received data is stored in the buffer in-place (the old data is replaced with the data received).
receivedVal = SPI.transfer(val)
receivedVal16 = SPI.transfer16(val16)
SPI.transfer(buffer, size)
Implemented in SPIClass, and SPISoft.