FastArduino v1.10
C++ library to build fast but small Arduino/AVR projects
|
Base class for any SPI slave device. More...
#include <fastarduino/spi.h>
Protected Member Functions | |
SPIDevice () INLINE=default | |
Create a new SPIDevice ; this sets up the CS pin for later use during transfers. | |
void | start_transfer () |
Start an SPI transfer to this device. More... | |
void | end_transfer () INLINE |
End the current SPI ransfer tot hsi device. More... | |
Protected Member Functions inherited from spi::AbstractSPIDevice | |
AbstractSPIDevice (const AbstractSPIDevice &)=delete | |
AbstractSPIDevice & | operator= (const AbstractSPIDevice &)=delete |
uint8_t | transfer (uint8_t data) |
Transfer one byte to the currently selected SPI slave device through MOSI pin, and get the byte returned by the device through MISO pin. More... | |
void | transfer (uint8_t *data, uint16_t size) |
Transfer an array of payload data to the currently selected SPI slave device through MOSI pin, and get all data bytes simultaneously received from that device through MISO pin. More... | |
void | transfer (const uint8_t *data, uint16_t size) |
Transfer an array of payload data to the currently selected SPI slave device through MOSI pin; any data bytes simultaneously received from that device through MISO pin are lost. More... | |
void | transfer (uint8_t *data, uint16_t size, uint8_t sent) |
Transfer the provided byte sent several times to the currently selected SPI slave device through MOSI pin, and get all data bytes simultaneously received from that device through MISO pin. More... | |
void | transfer (uint16_t size, uint8_t sent) |
Transfer the provided byte sent several times to the currently selected SPI slave device through MOSI pin; any data bytes simultaneously received from that device through MISO pin are lost. More... | |
Base class for any SPI slave device.
It contains the barebones API for implementing a real device.
Implementing a new SPI device consists mainly in subclassing SPIDevice
and add public
device-specific methods that will use start_transfer()
, transfer()
and end_transfer()
to communicate with the actual device.
The snippet below illustrates this and summarizes the definition of an SPI based device, the Winbond W25Q80BV flash-memory chip:
CS | the pin used to select the slave device; this may be DigitalPin::NONE if your device is alone on the SPI bus, its CS pin is forced low (always active), and your device actually supports this way of working. Some devices do not like having an always-0 CS pin! |
CS_MODE | the chip select active mode |
RATE | the SPI clock rate for this device |
MODE | the SPI mode used for this device |
ORDER | the bit order for this device |
|
inlineprotected |
|
inlineprotected |