Adafruit Library
seesaw_spi.h
Go to the documentation of this file.
1 
5 #ifndef SEESAW_SPI_H
6 #define SEESAW_SPI_H
7 
8 #include "Adafruit_seesaw.h"
9 
11 enum {
15  SEESAW_SPI_READ = 0x03,
18 };
20 enum {
22  SEESAW_SPI_END = 0x02,
24 };
26 enum {
27  SEESAW_SPI_BUSY = 0x01,
32 };
34 enum {
46 };
47 const uint16_t SEESAW_SPI_TIMEOUT_MS =
48  250;
49 const uint8_t SEESAW_SPI_CHUNK_SIZE =
50  29;
51 
57 class seesaw_SPI : public Adafruit_seesaw {
58 public:
59  seesaw_SPI(TwoWire *wire = NULL);
60  bool beginSPI(uint32_t frequency = 1000000, uint8_t mode = 0,
61  bool lsbFirst = false);
62  bool transfer(const uint8_t *tx, uint8_t *rx, size_t length,
63  bool beginTransaction = true, bool endTransaction = true);
64  bool abortSPI(bool releasePins = true);
65  uint32_t getSPIClockFrequency();
66  uint8_t getLastSPIError();
67 
68 private:
69  bool waitReady(uint8_t status[4]);
70  bool transferFailed();
71  uint8_t _lastSPIError =
73 };
74 #endif
I2C read/write failed.
Definition: seesaw_spi.h:45
Do not retain receive data.
Definition: seesaw_spi.h:23
Release chip-select after this chunk.
Definition: seesaw_spi.h:22
Flags and up to 29 transmit bytes.
Definition: seesaw_spi.h:14
Chip-select is low.
Definition: seesaw_spi.h:29
Unsupported configuration.
Definition: seesaw_spi.h:36
uint32_t getSPIClockFrequency()
Read the actual divided SPI clock from the peripheral.
Definition: seesaw_spi.cpp:158
bool transfer(const uint8_t *tx, uint8_t *rx, size_t length, bool beginTransaction=true, bool endTransaction=true)
Transfer an arbitrary-length buffer using bounded I2C chunks.
Definition: seesaw_spi.cpp:103
const uint8_t SEESAW_SPI_CHUNK_SIZE
Payload fitting a classic Wire packet.
Definition: seesaw_spi.h:49
Previous receive data was not consumed.
Definition: seesaw_spi.h:39
bool abortSPI(bool releasePins=true)
Abort the current transaction and clear the device error/RX state.
Definition: seesaw_spi.cpp:145
Completion deadline expired.
Definition: seesaw_spi.h:44
const uint16_t SEESAW_SPI_TIMEOUT_MS
Per-command completion deadline.
Definition: seesaw_spi.h:47
Sticky device error.
Definition: seesaw_spi.h:31
Abort transaction; optionally release pins.
Definition: seesaw_spi.h:16
Class that stores state and functions for interacting with seesaw helper IC.
Definition: Adafruit_seesaw.h:242
bool beginSPI(uint32_t frequency=1000000, uint8_t mode=0, bool lsbFirst=false)
Configure the controller after the inherited begin() succeeds.
Definition: seesaw_spi.cpp:43
Queued or executing work.
Definition: seesaw_spi.h:27
Unexpected response length or sequence.
Definition: seesaw_spi.h:43
Disabled controller or invalid CS sequence.
Definition: seesaw_spi.h:37
Definition: seesaw_spi.h:57
uint8_t getLastSPIError()
Report the last SPI operation's device or host-side error.
Definition: seesaw_spi.cpp:171
Mode, order, requested frequency (six bytes).
Definition: seesaw_spi.h:13
Invalid register/flags/payload.
Definition: seesaw_spi.h:41
Firmware command queue filled.
Definition: seesaw_spi.h:38
Receive data available.
Definition: seesaw_spi.h:30
Pins reserved by another feature.
Definition: seesaw_spi.h:42
Flags, error, RX length, completion sequence.
Definition: seesaw_spi.h:12
seesaw_SPI(TwoWire *wire=NULL)
Construct a bridge using an I2C bus.
Definition: seesaw_spi.cpp:10
Read actual SPI clock frequency in hertz.
Definition: seesaw_spi.h:17
Assert chip-select before this chunk.
Definition: seesaw_spi.h:21
No error.
Definition: seesaw_spi.h:35
Hardware SPI failure or timeout.
Definition: seesaw_spi.h:40
Consume the completed receive buffer.
Definition: seesaw_spi.h:15
Controller configured.
Definition: seesaw_spi.h:28