2020-12-26 14:12:05 -08:00
|
|
|
// Copyright (c) FIRST and other WPILib contributors.
|
|
|
|
|
// Open Source Software; you can modify and/or share it under the terms of
|
|
|
|
|
// the WPILib BSD license file in the root directory of this project.
|
2017-10-19 02:01:58 -04:00
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
2020-06-27 22:11:24 -07:00
|
|
|
#include "hal/simulation/SPIData.h"
|
|
|
|
|
#include "hal/simulation/SimCallbackRegistry.h"
|
|
|
|
|
#include "hal/simulation/SimDataValue.h"
|
2017-10-19 02:01:58 -04:00
|
|
|
|
|
|
|
|
namespace hal {
|
2017-12-31 15:37:14 -05:00
|
|
|
|
2017-10-19 02:01:58 -04:00
|
|
|
class SPIData {
|
2018-09-03 16:08:07 -07:00
|
|
|
HAL_SIMDATAVALUE_DEFINE_NAME(Initialized)
|
|
|
|
|
HAL_SIMCALLBACKREGISTRY_DEFINE_NAME(Read)
|
|
|
|
|
HAL_SIMCALLBACKREGISTRY_DEFINE_NAME(Write)
|
|
|
|
|
HAL_SIMCALLBACKREGISTRY_DEFINE_NAME(AutoReceive)
|
2017-10-19 02:01:58 -04:00
|
|
|
|
2018-09-03 16:08:07 -07:00
|
|
|
public:
|
2017-10-19 02:01:58 -04:00
|
|
|
int32_t Read(uint8_t* buffer, int32_t count);
|
2017-11-14 00:00:45 -08:00
|
|
|
int32_t Write(const uint8_t* dataToSend, int32_t sendSize);
|
|
|
|
|
int32_t Transaction(const uint8_t* dataToSend, uint8_t* dataReceived,
|
|
|
|
|
int32_t size);
|
2018-12-06 22:29:20 -08:00
|
|
|
int32_t ReadAutoReceivedData(uint32_t* buffer, int32_t numToRead,
|
2017-12-31 15:37:14 -05:00
|
|
|
double timeout, int32_t* status);
|
2017-10-19 02:01:58 -04:00
|
|
|
|
2019-09-23 23:28:49 -07:00
|
|
|
SimDataValue<HAL_Bool, HAL_MakeBoolean, GetInitializedName> initialized{
|
|
|
|
|
false};
|
2018-09-03 16:08:07 -07:00
|
|
|
SimCallbackRegistry<HAL_BufferCallback, GetReadName> read;
|
|
|
|
|
SimCallbackRegistry<HAL_ConstBufferCallback, GetWriteName> write;
|
|
|
|
|
SimCallbackRegistry<HAL_SpiReadAutoReceiveBufferCallback, GetAutoReceiveName>
|
|
|
|
|
autoReceivedData;
|
2017-10-19 02:01:58 -04:00
|
|
|
|
2018-09-03 16:08:07 -07:00
|
|
|
void ResetData();
|
2017-10-19 02:01:58 -04:00
|
|
|
};
|
2017-12-10 19:38:53 -08:00
|
|
|
extern SPIData* SimSPIData;
|
2017-10-19 02:01:58 -04:00
|
|
|
} // namespace hal
|