2017-10-19 02:01:58 -04:00
|
|
|
/*----------------------------------------------------------------------------*/
|
2019-09-23 23:28:49 -07:00
|
|
|
/* Copyright (c) 2017-2019 FIRST. All Rights Reserved. */
|
2017-10-19 02:01:58 -04:00
|
|
|
/* 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
|
|
|
|
|
|
2018-07-20 00:03:45 -07:00
|
|
|
#include "mockdata/SPIData.h"
|
2018-09-03 16:08:07 -07:00
|
|
|
#include "mockdata/SimCallbackRegistry.h"
|
|
|
|
|
#include "mockdata/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
|