#include <Adafruit_SPIDevice.h>
Public Member Functions | |
| Adafruit_SPIDevice (int8_t cspin, uint32_t freq=1000000, BusIOBitOrder dataOrder=SPI_BITORDER_MSBFIRST, uint8_t dataMode=SPI_MODE0, SPIClass *theSPI=&SPI) | |
| Create an SPI device with the given CS pin and settings. | |
| Adafruit_SPIDevice (int8_t cspin, int8_t sck, int8_t miso, int8_t mosi, uint32_t freq=1000000, BusIOBitOrder dataOrder=SPI_BITORDER_MSBFIRST, uint8_t dataMode=SPI_MODE0) | |
| Create an SPI device with the given CS pin and settings. | |
| ~Adafruit_SPIDevice () | |
| Release memory allocated in constructors. | |
| bool | begin (void) |
| Initializes SPI bus and sets CS pin high. | |
| bool | read (uint8_t *buffer, size_t len, uint8_t sendvalue=0xFF) |
| Read from SPI into a buffer from the SPI device, with transaction management. | |
| bool | write (const uint8_t *buffer, size_t len, const uint8_t *prefix_buffer=nullptr, size_t prefix_len=0) |
| Write a buffer or two to the SPI device, with transaction management. | |
| bool | write_then_read (const uint8_t *write_buffer, size_t write_len, uint8_t *read_buffer, size_t read_len, uint8_t sendvalue=0xFF) |
| Write some data, then read some data from SPI into another buffer, with transaction management. The buffers can point to same/overlapping locations. This does not transmit-receive at the same time! | |
| bool | write_and_read (uint8_t *buffer, size_t len) |
| Write some data and read some data at the same time from SPI into the same buffer, with transaction management. This is basicaly a wrapper for transfer() with CS-pin and transaction management. This /does/ transmit-receive at the same time! | |
| uint8_t | transfer (uint8_t send) |
| Transfer (send/receive) one byte over hard/soft SPI, without transaction management. | |
| void | transfer (uint8_t *buffer, size_t len) |
| Transfer (send/receive) a buffer over hard/soft SPI, without transaction management. | |
| void | beginTransaction (void) |
| Manually begin a transaction (calls beginTransaction if hardware SPI) | |
| void | endTransaction (void) |
| Manually end a transaction (calls endTransaction if hardware SPI) | |
| void | beginTransactionWithAssertingCS () |
| Write a buffer or two to the SPI device, with transaction management. | |
| void | endTransactionWithDeassertingCS () |
| Manually end a transaction (calls endTransaction if hardware SPI) with deasserting the CS pin. | |
! The class which defines how we will talk to this device over SPI
| Adafruit_SPIDevice::Adafruit_SPIDevice | ( | int8_t | cspin, |
| uint32_t | freq = 1000000, | ||
| BusIOBitOrder | dataOrder = SPI_BITORDER_MSBFIRST, | ||
| uint8_t | dataMode = SPI_MODE0, | ||
| SPIClass * | theSPI = &SPI ) |
Create an SPI device with the given CS pin and settings.
| cspin | The arduino pin number to use for chip select |
| freq | The SPI clock frequency to use, defaults to 1MHz |
| dataOrder | The SPI data order to use for bits within each byte, defaults to SPI_BITORDER_MSBFIRST |
| dataMode | The SPI mode to use, defaults to SPI_MODE0 |
| theSPI | The SPI bus to use, defaults to &theSPI |
| Adafruit_SPIDevice::Adafruit_SPIDevice | ( | int8_t | cspin, |
| int8_t | sckpin, | ||
| int8_t | misopin, | ||
| int8_t | mosipin, | ||
| uint32_t | freq = 1000000, | ||
| BusIOBitOrder | dataOrder = SPI_BITORDER_MSBFIRST, | ||
| uint8_t | dataMode = SPI_MODE0 ) |
Create an SPI device with the given CS pin and settings.
| cspin | The arduino pin number to use for chip select |
| sckpin | The arduino pin number to use for SCK |
| misopin | The arduino pin number to use for MISO, set to -1 if not used |
| mosipin | The arduino pin number to use for MOSI, set to -1 if not used |
| freq | The SPI clock frequency to use, defaults to 1MHz |
| dataOrder | The SPI data order to use for bits within each byte, defaults to SPI_BITORDER_MSBFIRST |
| dataMode | The SPI mode to use, defaults to SPI_MODE0 |
| bool Adafruit_SPIDevice::begin | ( | void | ) |
Initializes SPI bus and sets CS pin high.
| void Adafruit_SPIDevice::beginTransactionWithAssertingCS | ( | ) |
Write a buffer or two to the SPI device, with transaction management.
Manually begin a transaction (calls beginTransaction if hardware SPI) with asserting the CS pin
| bool Adafruit_SPIDevice::read | ( | uint8_t * | buffer, |
| size_t | len, | ||
| uint8_t | sendvalue = 0xFF ) |
Read from SPI into a buffer from the SPI device, with transaction management.
| buffer | Pointer to buffer of data to read into |
| len | Number of bytes from buffer to read. |
| sendvalue | The 8-bits of data to write when doing the data read, defaults to 0xFF |
| void Adafruit_SPIDevice::transfer | ( | uint8_t * | buffer, |
| size_t | len ) |
Transfer (send/receive) a buffer over hard/soft SPI, without transaction management.
| buffer | The buffer to send and receive at the same time |
| len | The number of bytes to transfer |
| uint8_t Adafruit_SPIDevice::transfer | ( | uint8_t | send | ) |
Transfer (send/receive) one byte over hard/soft SPI, without transaction management.
| send | The byte to send |
| bool Adafruit_SPIDevice::write | ( | const uint8_t * | buffer, |
| size_t | len, | ||
| const uint8_t * | prefix_buffer = nullptr, | ||
| size_t | prefix_len = 0 ) |
Write a buffer or two to the SPI device, with transaction management.
| buffer | Pointer to buffer of data to write |
| len | Number of bytes from buffer to write |
| prefix_buffer | Pointer to optional array of data to write before buffer. |
| prefix_len | Number of bytes from prefix buffer to write |
| bool Adafruit_SPIDevice::write_and_read | ( | uint8_t * | buffer, |
| size_t | len ) |
Write some data and read some data at the same time from SPI into the same buffer, with transaction management. This is basicaly a wrapper for transfer() with CS-pin and transaction management. This /does/ transmit-receive at the same time!
| buffer | Pointer to buffer of data to write/read to/from |
| len | Number of bytes from buffer to write/read. |
| bool Adafruit_SPIDevice::write_then_read | ( | const uint8_t * | write_buffer, |
| size_t | write_len, | ||
| uint8_t * | read_buffer, | ||
| size_t | read_len, | ||
| uint8_t | sendvalue = 0xFF ) |
Write some data, then read some data from SPI into another buffer, with transaction management. The buffers can point to same/overlapping locations. This does not transmit-receive at the same time!
| write_buffer | Pointer to buffer of data to write from |
| write_len | Number of bytes from buffer to write. |
| read_buffer | Pointer to buffer of data to read into. |
| read_len | Number of bytes from buffer to read. |
| sendvalue | The 8-bits of data to write when doing the data read, defaults to 0xFF |