10 #include "HAL/HAL.hpp"
11 #include "SensorBase.h"
25 enum Port { kOnboardCS0, kOnboardCS1, kOnboardCS2, kOnboardCS3, kMXP };
30 SPI& operator=(
const SPI&) =
delete;
46 virtual int32_t
Write(uint8_t* data, uint8_t size);
47 virtual int32_t
Read(
bool initiate, uint8_t* dataReceived, uint8_t size);
48 virtual int32_t
Transaction(uint8_t* dataToSend, uint8_t* dataReceived,
52 uint32_t valid_mask, uint32_t valid_value,
53 uint8_t data_shift, uint8_t data_size,
bool is_signed,
67 bool m_msbFirst =
false;
68 bool m_sampleOnTrailing =
false;
69 bool m_clk_idle_high =
false;
SPI(Port SPIport)
Constructor.
Definition: SPI.cpp:20
void SetMSBFirst()
Configure the order that bits are sent and received on the wire to be most significant bit first...
Definition: SPI.cpp:50
SPI bus interface class.
Definition: SPI.h:23
void SetChipSelectActiveLow()
Configure the chip select line to be active low.
Definition: SPI.cpp:118
void SetAccumulatorDeadband(int32_t deadband)
Set the accumulator's deadband.
Definition: SPI.cpp:236
void SetLSBFirst()
Configure the order that bits are sent and received on the wire to be least significant bit first...
Definition: SPI.cpp:60
Class to write to digital outputs.
Definition: DigitalOutput.h:22
void SetChipSelectActiveHigh()
Configure the chip select line to be active high.
Definition: SPI.cpp:109
virtual ~SPI()
Destructor.
Definition: SPI.cpp:34
void GetAccumulatorOutput(int64_t &value, uint32_t &count) const
Read the accumulated value and the number of accumulated values atomically.
Definition: SPI.cpp:299
int32_t GetAccumulatorLastValue() const
Read the last value read by the accumulator engine.
Definition: SPI.cpp:245
Base class for all sensors.
Definition: SensorBase.h:20
void InitAccumulator(double period, uint32_t cmd, uint8_t xfer_size, uint32_t valid_mask, uint32_t valid_value, uint8_t data_shift, uint8_t data_size, bool is_signed, bool big_endian)
Initialize the accumulator.
Definition: SPI.cpp:191
void SetAccumulatorCenter(int32_t center)
Set the center value of the accumulator.
Definition: SPI.cpp:227
void ResetAccumulator()
Resets the accumulator to zero.
Definition: SPI.cpp:214
double GetAccumulatorAverage() const
Read the average of the accumulated value.
Definition: SPI.cpp:283
void SetSampleDataOnFalling()
Configure that the data is stable on the falling edge and the data changes on the rising edge...
Definition: SPI.cpp:70
void FreeAccumulator()
Frees the accumulator.
Definition: SPI.cpp:205
virtual int32_t Transaction(uint8_t *dataToSend, uint8_t *dataReceived, uint8_t size)
Perform a simultaneous read/write transaction with the device.
Definition: SPI.cpp:169
virtual int32_t Write(uint8_t *data, uint8_t size)
Write data to the slave device.
Definition: SPI.cpp:131
uint32_t GetAccumulatorCount() const
Read the number of accumulated values.
Definition: SPI.cpp:271
void SetClockActiveLow()
Configure the clock output line to be active low.
Definition: SPI.cpp:90
int64_t GetAccumulatorValue() const
Read the accumulated value.
Definition: SPI.cpp:257
virtual int32_t Read(bool initiate, uint8_t *dataReceived, uint8_t size)
Read a word from the receive FIFO.
Definition: SPI.cpp:151
void SetClockActiveHigh()
Configure the clock output line to be active high.
Definition: SPI.cpp:100
void SetClockRate(double hz)
Configure the rate of the generated clock signal.
Definition: SPI.cpp:44
void SetSampleDataOnRising()
Configure that the data is stable on the rising edge and the data changes on the falling edge...
Definition: SPI.cpp:80