mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-22 01:11:42 +00:00
Use units in SPI
This commit is contained in:
@@ -12,6 +12,7 @@
|
||||
#include <memory>
|
||||
|
||||
#include <hal/SPITypes.h>
|
||||
#include <units/units.h>
|
||||
#include <wpi/ArrayRef.h>
|
||||
#include <wpi/deprecated.h>
|
||||
|
||||
@@ -173,6 +174,16 @@ class SPI : public ErrorBase {
|
||||
*/
|
||||
void SetAutoTransmitData(wpi::ArrayRef<uint8_t> dataToSend, int zeroSize);
|
||||
|
||||
/**
|
||||
* Start running the automatic SPI transfer engine at a periodic rate.
|
||||
*
|
||||
* InitAuto() and SetAutoTransmitData() must be called before calling this
|
||||
* function.
|
||||
*
|
||||
* @param period period between transfers (us resolution)
|
||||
*/
|
||||
void StartAutoRate(units::second_t period);
|
||||
|
||||
/**
|
||||
* Start running the automatic SPI transfer engine at a periodic rate.
|
||||
*
|
||||
@@ -181,6 +192,7 @@ class SPI : public ErrorBase {
|
||||
*
|
||||
* @param period period between transfers, in seconds (us resolution)
|
||||
*/
|
||||
WPI_DEPRECATED("Use StartAutoRate with unit-safety instead")
|
||||
void StartAutoRate(double period);
|
||||
|
||||
/**
|
||||
@@ -205,6 +217,28 @@ class SPI : public ErrorBase {
|
||||
*/
|
||||
void ForceAutoRead();
|
||||
|
||||
/**
|
||||
* Read data that has been transferred by the automatic SPI transfer engine.
|
||||
*
|
||||
* Transfers may be made a byte at a time, so it's necessary for the caller
|
||||
* to handle cases where an entire transfer has not been completed.
|
||||
*
|
||||
* Each received data sequence consists of a timestamp followed by the
|
||||
* received data bytes, one byte per word (in the least significant byte).
|
||||
* The length of each received data sequence is the same as the combined
|
||||
* size of the data and zeroSize set in SetAutoTransmitData().
|
||||
*
|
||||
* Blocks until numToRead words have been read or timeout expires.
|
||||
* May be called with numToRead=0 to retrieve how many words are available.
|
||||
*
|
||||
* @param buffer buffer where read words are stored
|
||||
* @param numToRead number of words to read
|
||||
* @param timeout timeout (ms resolution)
|
||||
* @return Number of words remaining to be read
|
||||
*/
|
||||
int ReadAutoReceivedData(uint32_t* buffer, int numToRead,
|
||||
units::second_t timeout);
|
||||
|
||||
/**
|
||||
* Read data that has been transferred by the automatic SPI transfer engine.
|
||||
*
|
||||
@@ -224,6 +258,7 @@ class SPI : public ErrorBase {
|
||||
* @param timeout timeout in seconds (ms resolution)
|
||||
* @return Number of words remaining to be read
|
||||
*/
|
||||
WPI_DEPRECATED("Use ReadAutoReceivedData with unit-safety instead")
|
||||
int ReadAutoReceivedData(uint32_t* buffer, int numToRead, double timeout);
|
||||
|
||||
/**
|
||||
@@ -249,6 +284,26 @@ class SPI : public ErrorBase {
|
||||
* @param isSigned Is data field signed?
|
||||
* @param bigEndian Is device big endian?
|
||||
*/
|
||||
void InitAccumulator(units::second_t period, int cmd, int xferSize,
|
||||
int validMask, int validValue, int dataShift,
|
||||
int dataSize, bool isSigned, bool bigEndian);
|
||||
|
||||
/**
|
||||
* Initialize the accumulator.
|
||||
*
|
||||
* @param period Time between reads
|
||||
* @param cmd SPI command to send to request data
|
||||
* @param xferSize SPI transfer size, in bytes
|
||||
* @param validMask Mask to apply to received data for validity checking
|
||||
* @param validData After valid_mask is applied, required matching value for
|
||||
* validity checking
|
||||
* @param dataShift Bit shift to apply to received data to get actual data
|
||||
* value
|
||||
* @param dataSize Size (in bits) of data field
|
||||
* @param isSigned Is data field signed?
|
||||
* @param bigEndian Is device big endian?
|
||||
*/
|
||||
WPI_DEPRECATED("Use InitAccumulator with unit-safety instead")
|
||||
void InitAccumulator(double period, int cmd, int xferSize, int validMask,
|
||||
int validValue, int dataShift, int dataSize,
|
||||
bool isSigned, bool bigEndian);
|
||||
|
||||
Reference in New Issue
Block a user