mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-21 01:01:43 +00:00
SPI and I2C simulator (#662)
* Creating SPI and I2C simulation abilities * Update the callback helpers to support different function callback types * Create callback type that uses a buffer * Created I2C/SPI data classes that manage the callbacks and don't do much of anything else * Ran format, cleaned up some issues
This commit is contained in:
committed by
Peter Johnson
parent
be77f9cb26
commit
3c842d8234
@@ -7,18 +7,24 @@
|
||||
|
||||
#include "HAL/SPI.h"
|
||||
|
||||
void HAL_InitializeSPI(HAL_SPIPort port, int32_t* status) {}
|
||||
#include "MockData/SPIDataInternal.h"
|
||||
|
||||
using namespace hal;
|
||||
|
||||
void HAL_InitializeSPI(HAL_SPIPort port, int32_t* status) {
|
||||
SimSPIData[port].SetInitialized(true);
|
||||
}
|
||||
int32_t HAL_TransactionSPI(HAL_SPIPort port, uint8_t* dataToSend,
|
||||
uint8_t* dataReceived, int32_t size) {
|
||||
return 0;
|
||||
return SimSPIData[port].Transaction(dataToSend, dataReceived, size);
|
||||
}
|
||||
int32_t HAL_WriteSPI(HAL_SPIPort port, uint8_t* dataToSend, int32_t sendSize) {
|
||||
return 0;
|
||||
return SimSPIData[port].Write(dataToSend, sendSize);
|
||||
}
|
||||
int32_t HAL_ReadSPI(HAL_SPIPort port, uint8_t* buffer, int32_t count) {
|
||||
return 0;
|
||||
return SimSPIData[port].Read(buffer, count);
|
||||
}
|
||||
void HAL_CloseSPI(HAL_SPIPort port) {}
|
||||
void HAL_CloseSPI(HAL_SPIPort port) { SimSPIData[port].SetInitialized(false); }
|
||||
void HAL_SetSPISpeed(HAL_SPIPort port, int32_t speed) {}
|
||||
void HAL_SetSPIOpts(HAL_SPIPort port, HAL_Bool msbFirst,
|
||||
HAL_Bool sampleOnTrailing, HAL_Bool clkIdleHigh) {}
|
||||
@@ -33,7 +39,9 @@ void HAL_InitSPIAccumulator(HAL_SPIPort port, int32_t period, int32_t cmd,
|
||||
int32_t dataSize, HAL_Bool isSigned,
|
||||
HAL_Bool bigEndian, int32_t* status) {}
|
||||
void HAL_FreeSPIAccumulator(HAL_SPIPort port, int32_t* status) {}
|
||||
void HAL_ResetSPIAccumulator(HAL_SPIPort port, int32_t* status) {}
|
||||
void HAL_ResetSPIAccumulator(HAL_SPIPort port, int32_t* status) {
|
||||
SimSPIData[port].ResetAccumulator();
|
||||
}
|
||||
void HAL_SetSPIAccumulatorCenter(HAL_SPIPort port, int32_t center,
|
||||
int32_t* status) {}
|
||||
void HAL_SetSPIAccumulatorDeadband(HAL_SPIPort port, int32_t deadband,
|
||||
@@ -42,7 +50,7 @@ int32_t HAL_GetSPIAccumulatorLastValue(HAL_SPIPort port, int32_t* status) {
|
||||
return 0;
|
||||
}
|
||||
int64_t HAL_GetSPIAccumulatorValue(HAL_SPIPort port, int32_t* status) {
|
||||
return 0;
|
||||
return SimSPIData[port].GetAccumulatorValue();
|
||||
}
|
||||
int64_t HAL_GetSPIAccumulatorCount(HAL_SPIPort port, int32_t* status) {
|
||||
return 0;
|
||||
|
||||
Reference in New Issue
Block a user