mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-24 01:31:46 +00:00
The 2019 FPGA image switched the output of auto SPI from plain bytes to a sequence of 32-bit words (timestamp, then words with the byte values in the least significant byte of each word). In addition to changing the HAL and simulators to reflect this, add piecewise integration support to wpilibc/wpilibj SPI to take advantage of the timestamps and use it in the ADXRS450 gyro.
40 lines
1.5 KiB
C++
40 lines
1.5 KiB
C++
/*----------------------------------------------------------------------------*/
|
|
/* Copyright (c) 2017-2018 FIRST. All Rights Reserved. */
|
|
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
|
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
|
/* the project. */
|
|
/*----------------------------------------------------------------------------*/
|
|
|
|
#pragma once
|
|
|
|
#include "mockdata/SPIData.h"
|
|
#include "mockdata/SimCallbackRegistry.h"
|
|
#include "mockdata/SimDataValue.h"
|
|
|
|
namespace hal {
|
|
|
|
class SPIData {
|
|
HAL_SIMDATAVALUE_DEFINE_NAME(Initialized)
|
|
HAL_SIMCALLBACKREGISTRY_DEFINE_NAME(Read)
|
|
HAL_SIMCALLBACKREGISTRY_DEFINE_NAME(Write)
|
|
HAL_SIMCALLBACKREGISTRY_DEFINE_NAME(AutoReceive)
|
|
|
|
public:
|
|
int32_t Read(uint8_t* buffer, int32_t count);
|
|
int32_t Write(const uint8_t* dataToSend, int32_t sendSize);
|
|
int32_t Transaction(const uint8_t* dataToSend, uint8_t* dataReceived,
|
|
int32_t size);
|
|
int32_t ReadAutoReceivedData(uint32_t* buffer, int32_t numToRead,
|
|
double timeout, int32_t* status);
|
|
|
|
SimDataValue<HAL_Bool, MakeBoolean, GetInitializedName> initialized{false};
|
|
SimCallbackRegistry<HAL_BufferCallback, GetReadName> read;
|
|
SimCallbackRegistry<HAL_ConstBufferCallback, GetWriteName> write;
|
|
SimCallbackRegistry<HAL_SpiReadAutoReceiveBufferCallback, GetAutoReceiveName>
|
|
autoReceivedData;
|
|
|
|
void ResetData();
|
|
};
|
|
extern SPIData* SimSPIData;
|
|
} // namespace hal
|