mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-24 01:31:46 +00:00
[hal, wpilib] Remove SPI support (#7678)
This commit is contained in:
@@ -85,8 +85,6 @@ void InitializeHAL() {
|
||||
InitializePWMData();
|
||||
InitializeRoboRioData();
|
||||
InitializeSimDeviceData();
|
||||
InitializeSPIAccelerometerData();
|
||||
InitializeSPIData();
|
||||
InitializeAccelerometer();
|
||||
InitializeAddressableLED();
|
||||
InitializeAnalogAccumulator();
|
||||
@@ -116,7 +114,6 @@ void InitializeHAL() {
|
||||
InitializePWM();
|
||||
InitializeSerialPort();
|
||||
InitializeSimDevice();
|
||||
InitializeSPI();
|
||||
InitializeThreads();
|
||||
}
|
||||
} // namespace hal::init
|
||||
|
||||
@@ -36,8 +36,6 @@ extern void InitializePowerDistributionData();
|
||||
extern void InitializePWMData();
|
||||
extern void InitializeRoboRioData();
|
||||
extern void InitializeSimDeviceData();
|
||||
extern void InitializeSPIAccelerometerData();
|
||||
extern void InitializeSPIData();
|
||||
extern void InitializeAccelerometer();
|
||||
extern void InitializeAddressableLED();
|
||||
extern void InitializeAnalogAccumulator();
|
||||
@@ -67,7 +65,6 @@ extern void InitializeREVPH();
|
||||
extern void InitializePWM();
|
||||
extern void InitializeSerialPort();
|
||||
extern void InitializeSimDevice();
|
||||
extern void InitializeSPI();
|
||||
extern void InitializeThreads();
|
||||
|
||||
} // namespace hal::init
|
||||
|
||||
@@ -1,74 +0,0 @@
|
||||
// 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.
|
||||
|
||||
#include "hal/SPI.h"
|
||||
|
||||
#include "HALInitializer.h"
|
||||
#include "mockdata/SPIDataInternal.h"
|
||||
|
||||
using namespace hal;
|
||||
|
||||
namespace hal::init {
|
||||
void InitializeSPI() {}
|
||||
} // namespace hal::init
|
||||
|
||||
extern "C" {
|
||||
|
||||
void HAL_InitializeSPI(HAL_SPIPort port, int32_t* status) {
|
||||
hal::init::CheckInit();
|
||||
SimSPIData[port].initialized = true;
|
||||
}
|
||||
int32_t HAL_TransactionSPI(HAL_SPIPort port, const uint8_t* dataToSend,
|
||||
uint8_t* dataReceived, int32_t size) {
|
||||
return SimSPIData[port].Transaction(dataToSend, dataReceived, size);
|
||||
}
|
||||
int32_t HAL_WriteSPI(HAL_SPIPort port, const uint8_t* dataToSend,
|
||||
int32_t sendSize) {
|
||||
return SimSPIData[port].Write(dataToSend, sendSize);
|
||||
}
|
||||
int32_t HAL_ReadSPI(HAL_SPIPort port, uint8_t* buffer, int32_t count) {
|
||||
return SimSPIData[port].Read(buffer, count);
|
||||
}
|
||||
void HAL_CloseSPI(HAL_SPIPort port) {
|
||||
SimSPIData[port].initialized = false;
|
||||
}
|
||||
void HAL_SetSPISpeed(HAL_SPIPort port, int32_t speed) {}
|
||||
void HAL_SetSPIMode(HAL_SPIPort port, HAL_SPIMode mode) {}
|
||||
HAL_SPIMode HAL_GetSPIMode(HAL_SPIPort port) {
|
||||
return HAL_SPI_kMode0;
|
||||
}
|
||||
void HAL_SetSPIChipSelectActiveHigh(HAL_SPIPort port, int32_t* status) {}
|
||||
void HAL_SetSPIChipSelectActiveLow(HAL_SPIPort port, int32_t* status) {}
|
||||
int32_t HAL_GetSPIHandle(HAL_SPIPort port) {
|
||||
return 0;
|
||||
}
|
||||
void HAL_SetSPIHandle(HAL_SPIPort port, int32_t handle) {}
|
||||
|
||||
void HAL_InitSPIAuto(HAL_SPIPort port, int32_t bufferSize, int32_t* status) {}
|
||||
void HAL_FreeSPIAuto(HAL_SPIPort port, int32_t* status) {}
|
||||
void HAL_StartSPIAutoRate(HAL_SPIPort port, double period, int32_t* status) {}
|
||||
void HAL_StartSPIAutoTrigger(HAL_SPIPort port, HAL_Handle digitalSourceHandle,
|
||||
HAL_AnalogTriggerType analogTriggerType,
|
||||
HAL_Bool triggerRising, HAL_Bool triggerFalling,
|
||||
int32_t* status) {}
|
||||
void HAL_StopSPIAuto(HAL_SPIPort port, int32_t* status) {}
|
||||
void HAL_SetSPIAutoTransmitData(HAL_SPIPort port, const uint8_t* dataToSend,
|
||||
int32_t dataSize, int32_t zeroSize,
|
||||
int32_t* status) {}
|
||||
void HAL_ForceSPIAutoRead(HAL_SPIPort port, int32_t* status) {}
|
||||
int32_t HAL_ReadSPIAutoReceivedData(HAL_SPIPort port, uint32_t* buffer,
|
||||
int32_t numToRead, double timeout,
|
||||
int32_t* status) {
|
||||
return SimSPIData[port].ReadAutoReceivedData(buffer, numToRead, timeout,
|
||||
status);
|
||||
}
|
||||
int32_t HAL_GetSPIAutoDroppedCount(HAL_SPIPort port, int32_t* status) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
void HAL_ConfigureSPIAutoStall(HAL_SPIPort port, int32_t csToSclkTicks,
|
||||
int32_t stallTicks, int32_t pow2BytesPerRead,
|
||||
int32_t* status) {}
|
||||
|
||||
} // extern "C"
|
||||
@@ -19,8 +19,6 @@
|
||||
#include <hal/simulation/PowerDistributionData.h>
|
||||
#include <hal/simulation/REVPHData.h>
|
||||
#include <hal/simulation/RoboRioData.h>
|
||||
#include <hal/simulation/SPIAccelerometerData.h>
|
||||
#include <hal/simulation/SPIData.h>
|
||||
#include <hal/simulation/SimDeviceData.h>
|
||||
|
||||
#include "../PortsInternal.h"
|
||||
@@ -88,12 +86,4 @@ extern "C" void HALSIM_ResetAllSimData(void) {
|
||||
|
||||
HALSIM_ResetRoboRioData();
|
||||
HALSIM_ResetSimDeviceData();
|
||||
|
||||
for (int32_t i = 0; i < hal::kSPIAccelerometers; i++) {
|
||||
HALSIM_ResetSPIAccelerometerData(i);
|
||||
}
|
||||
|
||||
for (int32_t i = 0; i < hal::kSPIPorts; i++) {
|
||||
HALSIM_ResetSPIData(i);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,55 +0,0 @@
|
||||
// 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.
|
||||
|
||||
#include "../PortsInternal.h"
|
||||
#include "SPIAccelerometerDataInternal.h"
|
||||
|
||||
using namespace hal;
|
||||
|
||||
namespace hal::init {
|
||||
void InitializeSPIAccelerometerData() {
|
||||
static SPIAccelerometerData ssad[kSPIAccelerometers];
|
||||
::hal::SimSPIAccelerometerData = ssad;
|
||||
}
|
||||
} // namespace hal::init
|
||||
|
||||
SPIAccelerometerData* hal::SimSPIAccelerometerData;
|
||||
void SPIAccelerometerData::ResetData() {
|
||||
active.Reset(false);
|
||||
range.Reset(0);
|
||||
x.Reset(0.0);
|
||||
y.Reset(0.0);
|
||||
z.Reset(0.0);
|
||||
}
|
||||
|
||||
extern "C" {
|
||||
void HALSIM_ResetSPIAccelerometerData(int32_t index) {
|
||||
SimSPIAccelerometerData[index].ResetData();
|
||||
}
|
||||
|
||||
#define DEFINE_CAPI(TYPE, CAPINAME, LOWERNAME) \
|
||||
HAL_SIMDATAVALUE_DEFINE_CAPI(TYPE, HALSIM, SPIAccelerometer##CAPINAME, \
|
||||
SimSPIAccelerometerData, LOWERNAME)
|
||||
|
||||
DEFINE_CAPI(HAL_Bool, Active, active)
|
||||
DEFINE_CAPI(int32_t, Range, range)
|
||||
DEFINE_CAPI(double, X, x)
|
||||
DEFINE_CAPI(double, Y, y)
|
||||
DEFINE_CAPI(double, Z, z)
|
||||
|
||||
#define REGISTER(NAME) \
|
||||
SimSPIAccelerometerData[index].NAME.RegisterCallback(callback, param, \
|
||||
initialNotify)
|
||||
|
||||
void HALSIM_RegisterSPIAccelerometerAllCallbacks(int32_t index,
|
||||
HAL_NotifyCallback callback,
|
||||
void* param,
|
||||
HAL_Bool initialNotify) {
|
||||
REGISTER(active);
|
||||
REGISTER(range);
|
||||
REGISTER(x);
|
||||
REGISTER(y);
|
||||
REGISTER(z);
|
||||
}
|
||||
} // extern "C"
|
||||
@@ -1,28 +0,0 @@
|
||||
// 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.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "hal/simulation/SPIAccelerometerData.h"
|
||||
#include "hal/simulation/SimDataValue.h"
|
||||
|
||||
namespace hal {
|
||||
class SPIAccelerometerData {
|
||||
HAL_SIMDATAVALUE_DEFINE_NAME(Active)
|
||||
HAL_SIMDATAVALUE_DEFINE_NAME(Range)
|
||||
HAL_SIMDATAVALUE_DEFINE_NAME(X)
|
||||
HAL_SIMDATAVALUE_DEFINE_NAME(Y)
|
||||
HAL_SIMDATAVALUE_DEFINE_NAME(Z)
|
||||
|
||||
public:
|
||||
SimDataValue<HAL_Bool, HAL_MakeBoolean, GetActiveName> active{false};
|
||||
SimDataValue<int32_t, HAL_MakeInt, GetRangeName> range{0};
|
||||
SimDataValue<double, HAL_MakeDouble, GetXName> x{0.0};
|
||||
SimDataValue<double, HAL_MakeDouble, GetYName> y{0.0};
|
||||
SimDataValue<double, HAL_MakeDouble, GetZName> z{0.0};
|
||||
|
||||
virtual void ResetData();
|
||||
};
|
||||
extern SPIAccelerometerData* SimSPIAccelerometerData;
|
||||
} // namespace hal
|
||||
@@ -1,70 +0,0 @@
|
||||
// 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.
|
||||
|
||||
#include "../PortsInternal.h"
|
||||
#include "SPIDataInternal.h"
|
||||
|
||||
using namespace hal;
|
||||
|
||||
namespace hal::init {
|
||||
void InitializeSPIData() {
|
||||
static SPIData ssd[kSPIPorts];
|
||||
::hal::SimSPIData = ssd;
|
||||
}
|
||||
} // namespace hal::init
|
||||
|
||||
SPIData* hal::SimSPIData;
|
||||
void SPIData::ResetData() {
|
||||
initialized.Reset(false);
|
||||
read.Reset();
|
||||
write.Reset();
|
||||
autoReceivedData.Reset();
|
||||
}
|
||||
|
||||
int32_t SPIData::Read(uint8_t* buffer, int32_t count) {
|
||||
read(buffer, count);
|
||||
return count;
|
||||
}
|
||||
|
||||
int32_t SPIData::Write(const uint8_t* dataToSend, int32_t sendSize) {
|
||||
write(dataToSend, sendSize);
|
||||
return sendSize;
|
||||
}
|
||||
|
||||
int32_t SPIData::Transaction(const uint8_t* dataToSend, uint8_t* dataReceived,
|
||||
int32_t size) {
|
||||
write(dataToSend, size);
|
||||
read(dataReceived, size);
|
||||
return size;
|
||||
}
|
||||
|
||||
int32_t SPIData::ReadAutoReceivedData(uint32_t* buffer, int32_t numToRead,
|
||||
double timeout, int32_t* status) {
|
||||
int32_t outputCount = 0;
|
||||
autoReceivedData(buffer, numToRead, &outputCount);
|
||||
return outputCount;
|
||||
}
|
||||
|
||||
extern "C" {
|
||||
void HALSIM_ResetSPIData(int32_t index) {
|
||||
SimSPIData[index].ResetData();
|
||||
}
|
||||
|
||||
#define DEFINE_CAPI(TYPE, CAPINAME, LOWERNAME) \
|
||||
HAL_SIMDATAVALUE_DEFINE_CAPI(TYPE, HALSIM, SPI##CAPINAME, SimSPIData, \
|
||||
LOWERNAME)
|
||||
|
||||
DEFINE_CAPI(HAL_Bool, Initialized, initialized)
|
||||
|
||||
#undef DEFINE_CAPI
|
||||
#define DEFINE_CAPI(TYPE, CAPINAME, LOWERNAME) \
|
||||
HAL_SIMCALLBACKREGISTRY_DEFINE_CAPI(TYPE, HALSIM, SPI##CAPINAME, SimSPIData, \
|
||||
LOWERNAME)
|
||||
|
||||
DEFINE_CAPI(HAL_BufferCallback, Read, read)
|
||||
DEFINE_CAPI(HAL_ConstBufferCallback, Write, write)
|
||||
DEFINE_CAPI(HAL_SpiReadAutoReceiveBufferCallback, ReadAutoReceivedData,
|
||||
autoReceivedData)
|
||||
|
||||
} // extern "C"
|
||||
@@ -1,37 +0,0 @@
|
||||
// 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.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "hal/simulation/SPIData.h"
|
||||
#include "hal/simulation/SimCallbackRegistry.h"
|
||||
#include "hal/simulation/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, HAL_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
|
||||
Reference in New Issue
Block a user