Arduino SPI interface. More...
Arduino SPI interface.
SPI.beginTransaction()
and SPI.endTransaction()
The official Arduino SPI-API allows to use SPI transfers without having to call SPI.beginTransaction()
, but discourages to do so. The RIOT API does not provide this feature, instead a call to SPI.beginTransaction()
is mandatory. However, most Arduino code already does this and the remaining code should be fixed anyway.
Definition at line 103 of file spiport.hpp.
#include <spiport.hpp>
Public Member Functions | |
SPIClass (spi_t spi_dev) | |
Create a new SPI interface instance. More... | |
SPIClass (uint8_t uc_pinMISO, uint8_t uc_pinSCK, uint8_t uc_pinMOSI, uint8_t uc_pinSS, uint8_t uc_mux) | |
Create a new SPI interface instance for SPI device 0. More... | |
uint8_t | transfer (uint8_t data) |
Transfer a single byte of data. More... | |
uint16_t | transfer16 (uint16_t data) |
Transfer two bytes of data. More... | |
void | transfer (void *buf, size_t count) |
Transfer data. More... | |
void | begin () |
Doesn't do anything, for compatibility only. | |
void | end () |
Doesn't do anything, for compatibility only. | |
void | beginTransaction (SPISettings settings) |
Acquires the SPI interface and applies the given settings. More... | |
void | endTransaction () |
Releases the SPI interface. | |
void | setBitOrder (uint8_t order) |
Sets the bit order to the given value. More... | |
void | setDataMode (uint8_t mode) |
Sets the SPI mode (clock phase and polarity) More... | |
void | setClockDivider (uint8_t divider) |
Sets the SPI clock in an archaic manner. More... | |
|
explicit |
Create a new SPI interface instance.
spi_dev | The RIOT SPI device to use under the hood |
|
inline |
Create a new SPI interface instance for SPI device 0.
uc_pinMISO | Ignored, for compatibility only |
uc_pinSCK | Ignored, for compatibility only |
uc_pinMOSI | Ignored, for compatibility only |
uc_pinSS | Ignored, for compatibility only |
uc_mux | Ignored, for compatibility only |
Definition at line 125 of file spiport.hpp.
void SPIClass::beginTransaction | ( | SPISettings | settings | ) |
Acquires the SPI interface and applies the given settings.
[in] | settings | Settings to apply |
void SPIClass::setBitOrder | ( | uint8_t | order | ) |
Sets the bit order to the given value.
Currently only most significant bit first is supported, as practically no hardware exists using lsbfirst. An assertion is triggered if lsbfirst is requested.
void SPIClass::setClockDivider | ( | uint8_t | divider | ) |
Sets the SPI clock in an archaic manner.
void SPIClass::setDataMode | ( | uint8_t | mode | ) |
Sets the SPI mode (clock phase and polarity)
|
inline |
Transfer a single byte of data.
[in] | data | Byte to send |
Definition at line 140 of file spiport.hpp.
void SPIClass::transfer | ( | void * | buf, |
size_t | count | ||
) |
Transfer data.
[in,out] | buf | Buffer containing the data to send, received data will be written here |
[in] | count | Number of bytes to send |
|
inline |
Transfer two bytes of data.
[in] | data | The two bytes to send |
Arduino is sending the most significant byte first, if the SPI interface is configured to send the most significant bit first. If the least significant bit is send first, Arduino will also send the least significant byte first.
This wrapper currently only supports sending the most significant bit first over the wire, so this function will also always send the most significant byte first.
Definition at line 160 of file spiport.hpp.