10 #include "SensorBase.h"
26 enum Port { kOnboardCS0, kOnboardCS1, kOnboardCS2, kOnboardCS3, kMXP };
27 explicit SPI(Port SPIport);
31 SPI& operator=(
const SPI&) =
delete;
47 virtual int Write(uint8_t* data,
int size);
48 virtual int Read(
bool initiate, uint8_t* dataReceived,
int size);
49 virtual int Transaction(uint8_t* dataToSend, uint8_t* dataReceived,
int size);
51 void InitAccumulator(
double period,
int cmd,
int xfer_size,
int valid_mask,
52 int valid_value,
int data_shift,
int data_size,
53 bool is_signed,
bool big_endian);
66 bool m_msbFirst =
false;
67 bool m_sampleOnTrailing =
false;
68 bool m_clk_idle_high =
false;
void SetAccumulatorCenter(int center)
Set the center value of the accumulator.
Definition: SPI.cpp:224
void SetAccumulatorDeadband(int deadband)
Set the accumulator's deadband.
Definition: SPI.cpp:233
Base class for all sensors.
Definition: SensorBase.h:22
void GetAccumulatorOutput(int64_t &value, int64_t &count) const
Read the accumulated value and the number of accumulated values atomically.
Definition: SPI.cpp:297
void InitAccumulator(double period, int cmd, int xfer_size, int valid_mask, int valid_value, int data_shift, int data_size, bool is_signed, bool big_endian)
Initialize the accumulator.
Definition: SPI.cpp:188
double GetAccumulatorAverage() const
Read the average of the accumulated value.
Definition: SPI.cpp:281
void SetMSBFirst()
Configure the order that bits are sent and received on the wire to be most significant bit first...
Definition: SPI.cpp:54
void FreeAccumulator()
Frees the accumulator.
Definition: SPI.cpp:201
virtual int Write(uint8_t *data, int size)
Write data to the slave device.
Definition: SPI.cpp:129
int64_t GetAccumulatorValue() const
Read the accumulated value.
Definition: SPI.cpp:254
void SetChipSelectActiveLow()
Configure the chip select line to be active low.
Definition: SPI.cpp:116
void SetChipSelectActiveHigh()
Configure the chip select line to be active high.
Definition: SPI.cpp:107
virtual ~SPI()
Destructor.
Definition: SPI.cpp:38
SPI bus interface class.
Definition: SPI.h:24
void ResetAccumulator()
Resets the accumulator to zero.
Definition: SPI.cpp:210
void SetSampleDataOnRising()
Configure that the data is stable on the rising edge and the data changes on the falling edge...
Definition: SPI.cpp:81
SPI(Port SPIport)
Constructor.
Definition: SPI.cpp:24
virtual int Read(bool initiate, uint8_t *dataReceived, int size)
Read a word from the receive FIFO.
Definition: SPI.cpp:148
void SetClockActiveHigh()
Configure the clock output line to be active high.
Definition: SPI.cpp:99
void SetLSBFirst()
Configure the order that bits are sent and received on the wire to be least significant bit first...
Definition: SPI.cpp:63
Class to write to digital outputs.
Definition: DigitalOutput.h:26
virtual int Transaction(uint8_t *dataToSend, uint8_t *dataReceived, int size)
Perform a simultaneous read/write transaction with the device.
Definition: SPI.cpp:167
void SetClockRate(double hz)
Configure the rate of the generated clock signal.
Definition: SPI.cpp:48
int GetAccumulatorLastValue() const
Read the last value read by the accumulator engine.
Definition: SPI.cpp:242
int64_t GetAccumulatorCount() const
Read the number of accumulated values.
Definition: SPI.cpp:269
void SetClockActiveLow()
Configure the clock output line to be active low.
Definition: SPI.cpp:90
void SetSampleDataOnFalling()
Configure that the data is stable on the falling edge and the data changes on the rising edge...
Definition: SPI.cpp:72