Treehopper C++ API
SpiDevice Class Reference

Represents a peripheral on the SPI bus. More...

#include <SpiDevice.h>

Public Member Functions

 SpiDevice (Spi &spiModule, SpiChipSelectPin *chipSelect, ChipSelectMode chipSelectMode=ChipSelectMode::SpiActiveLow, double speedMhz=1, SpiMode mode=SpiMode::Mode00)
 Construct an SPI device attached to a particular module More...
std::vector< uint8_t > sendReceive (std::vector< uint8_t > dataToSend, SpiBurstMode burst)
 Starts an SPI send/receive transaction. More...

Detailed Description

This class is essentially used to "save your settings" (chip select, clock rate, SPI mode, etc) when it comes to multi-peripheral projects. It was more useful before all these settings ended up as params in Spi.sendReceive, but it's still nice to use this as a container; SPI peripheral drivers can pass values directly from the constructor to this class's constructor, and never worry about that stuff again.

Constructor & Destructor Documentation

◆ SpiDevice()

SpiDevice ( Spi spiModule,
SpiChipSelectPin chipSelect,
ChipSelectMode  chipSelectMode = ChipSelectMode::SpiActiveLow,
double  speedMhz = 1,
SpiMode  mode = SpiMode::Mode00 
spiModuleThe module this device is attached to
chipSelectThe chip select pin used by this device
chipSelectModeThe ChipSelectMode to use with this device
speedMhzThe speed to operate this device at
modeThe SpiMode of this device

Member Function Documentation

◆ sendReceive()

std::vector<uint8_t> sendReceive ( std::vector< uint8_t >  dataToSend,
SpiBurstMode  burst 
[in]dataToSendThe transmit buffer where the data is
[in]burstThe SPI burst mode to use when performing this transaction
A vector of received data.

The documentation for this class was generated from the following file: