Treehopper C++ API
Spi.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include "Treehopper.h"
4 #include "ChipSelectMode.h"
5 #include "SpiBurstMode.h"
6 #include "SpiMode.h"
7 #include <stdint.h>
8 #include <cstddef>
9 #include <vector>
10 
11 namespace Treehopper {
12  class SpiChipSelectPin;
13 
15  class Spi {
16  public:
18  virtual bool enabled() = 0;
19 
21  virtual void enabled(bool) = 0;
22 
33  virtual std::vector<uint8_t> sendReceive(std::vector<uint8_t> dataToWrite, SpiChipSelectPin *chipSelect = nullptr,
34  ChipSelectMode chipSelectMode = ChipSelectMode::SpiActiveLow, double speed = 6,
36  };
37 }
virtual std::vector< uint8_t > sendReceive(std::vector< uint8_t > dataToWrite, SpiChipSelectPin *chipSelect=nullptr, ChipSelectMode chipSelectMode=ChipSelectMode::SpiActiveLow, double speed=6, SpiBurstMode burstMode=SpiBurstMode::NoBurst, SpiMode spiMode=SpiMode::Mode00)=0
Send/receive data out of this SPI port.
SpiMode
Defines the clock phase and polarity used for SPI communication.
Definition: SpiMode.h:10
SpiBurstMode
The SPI burst mode to use.
Definition: SpiBurstMode.h:7
An SPI port.
Definition: Spi.h:15
virtual bool enabled()=0
Gets whether the port is enabled.
Clock is initially low; data is valid on the rising edge of the clock
CS is asserted low, the SPI transaction takes place, and then the signal is returned high...
Definition: AdcPin.h:3
Definition: SpiChipSelectPin.h:7
No burst – always read the same number of bytes as transmitted.
ChipSelectMode
Definition: ChipSelectMode.h:3