[hal,wpilib] Remove a ton of things related to the FPGA (#7846)

Co-authored-by: Gold856 <117957790+Gold856@users.noreply.github.com>
This commit is contained in:
Thad House
2026-04-17 19:38:25 -07:00
committed by GitHub
parent fdb454a6b1
commit 6cb6903780
73 changed files with 69 additions and 1834 deletions

View File

@@ -17,10 +17,6 @@
using namespace wpi;
AnalogInput::AnalogInput(int channel) {
if (!SensorUtil::CheckAnalogInputChannel(channel)) {
throw WPILIB_MakeError(err::ChannelIndexOutOfRange, "Channel {}", channel);
}
m_channel = channel;
int32_t status = 0;
std::string stackTrace = wpi::util::GetStackTrace(1);
@@ -39,13 +35,6 @@ int AnalogInput::GetValue() const {
return value;
}
int AnalogInput::GetAverageValue() const {
int32_t status = 0;
int value = HAL_GetAnalogAverageValue(m_port, &status);
WPILIB_CheckErrorStatus(status, "Channel {}", m_channel);
return value;
}
double AnalogInput::GetVoltage() const {
int32_t status = 0;
double voltage = HAL_GetAnalogVoltage(m_port, &status);
@@ -53,70 +42,10 @@ double AnalogInput::GetVoltage() const {
return voltage;
}
double AnalogInput::GetAverageVoltage() const {
int32_t status = 0;
double voltage = HAL_GetAnalogAverageVoltage(m_port, &status);
WPILIB_CheckErrorStatus(status, "Channel {}", m_channel);
return voltage;
}
int AnalogInput::GetChannel() const {
return m_channel;
}
void AnalogInput::SetAverageBits(int bits) {
int32_t status = 0;
HAL_SetAnalogAverageBits(m_port, bits, &status);
WPILIB_CheckErrorStatus(status, "Channel {}", m_channel);
}
int AnalogInput::GetAverageBits() const {
int32_t status = 0;
int averageBits = HAL_GetAnalogAverageBits(m_port, &status);
WPILIB_CheckErrorStatus(status, "Channel {}", m_channel);
return averageBits;
}
void AnalogInput::SetOversampleBits(int bits) {
int32_t status = 0;
HAL_SetAnalogOversampleBits(m_port, bits, &status);
WPILIB_CheckErrorStatus(status, "Channel {}", m_channel);
}
int AnalogInput::GetOversampleBits() const {
int32_t status = 0;
int oversampleBits = HAL_GetAnalogOversampleBits(m_port, &status);
WPILIB_CheckErrorStatus(status, "Channel {}", m_channel);
return oversampleBits;
}
int AnalogInput::GetLSBWeight() const {
int32_t status = 0;
int lsbWeight = HAL_GetAnalogLSBWeight(m_port, &status);
WPILIB_CheckErrorStatus(status, "Channel {}", m_channel);
return lsbWeight;
}
int AnalogInput::GetOffset() const {
int32_t status = 0;
int offset = HAL_GetAnalogOffset(m_port, &status);
WPILIB_CheckErrorStatus(status, "Channel {}", m_channel);
return offset;
}
void AnalogInput::SetSampleRate(double samplesPerSecond) {
int32_t status = 0;
HAL_SetAnalogSampleRate(samplesPerSecond, &status);
WPILIB_CheckErrorStatus(status, "SetSampleRate");
}
double AnalogInput::GetSampleRate() {
int32_t status = 0;
double sampleRate = HAL_GetAnalogSampleRate(&status);
WPILIB_CheckErrorStatus(status, "GetSampleRate");
return sampleRate;
}
void AnalogInput::SetSimDevice(HAL_SimDeviceHandle device) {
HAL_SetAnalogInputSimDevice(m_port, device);
}
@@ -124,5 +53,5 @@ void AnalogInput::SetSimDevice(HAL_SimDeviceHandle device) {
void AnalogInput::InitSendable(wpi::util::SendableBuilder& builder) {
builder.SetSmartDashboardType("Analog Input");
builder.AddDoubleProperty(
"Value", [=, this] { return GetAverageVoltage(); }, nullptr);
"Value", [=, this] { return GetVoltage(); }, nullptr);
}

View File

@@ -17,9 +17,6 @@
using namespace wpi;
DigitalInput::DigitalInput(int channel) {
if (!SensorUtil::CheckDigitalChannel(channel)) {
throw WPILIB_MakeError(err::ChannelIndexOutOfRange, "Channel {}", channel);
}
m_channel = channel;
int32_t status = 0;

View File

@@ -18,9 +18,6 @@ using namespace wpi;
DigitalOutput::DigitalOutput(int channel) {
m_pwmGenerator = HAL_INVALID_HANDLE;
if (!SensorUtil::CheckDigitalChannel(channel)) {
throw WPILIB_MakeError(err::ChannelIndexOutOfRange, "Channel {}", channel);
}
m_channel = channel;
int32_t status = 0;
@@ -120,9 +117,6 @@ void DigitalOutput::DisablePWM() {
int32_t status = 0;
// Disable the output by routing to a dead bit.
HAL_SetDigitalPWMOutputChannel(m_pwmGenerator,
SensorUtil::GetNumDigitalChannels(), &status);
WPILIB_CheckErrorStatus(status, "Channel {}", m_channel);
HAL_FreeDigitalPWM(m_pwmGenerator);

View File

@@ -15,10 +15,6 @@
using namespace wpi;
PWM::PWM(int channel, bool registerSendable) {
if (!SensorUtil::CheckPWMChannel(channel)) {
throw WPILIB_MakeError(err::ChannelIndexOutOfRange, "Channel {}", channel);
}
auto stack = wpi::util::GetStackTrace(1);
int32_t status = 0;
m_handle = HAL_InitializePWMPort(channel, stack.c_str(), &status);

View File

@@ -9,16 +9,11 @@
#include "wpi/hal/AddressableLED.h"
#include "wpi/hal/UsageReporting.hpp"
#include "wpi/system/Errors.hpp"
#include "wpi/util/SensorUtil.hpp"
#include "wpi/util/StackTrace.hpp"
using namespace wpi;
AddressableLED::AddressableLED(int channel) : m_channel{channel} {
if (!SensorUtil::CheckDigitalChannel(channel)) {
throw WPILIB_MakeError(err::ChannelIndexOutOfRange, "Channel {}", channel);
}
int32_t status = 0;
auto stack = wpi::util::GetStackTrace(1);
m_handle = HAL_InitializeAddressableLED(channel, stack.c_str(), &status);

View File

@@ -16,9 +16,6 @@
using namespace wpi;
DutyCycle::DutyCycle(int channel) : m_channel{channel} {
if (!SensorUtil::CheckDigitalChannel(channel)) {
throw WPILIB_MakeError(err::ChannelIndexOutOfRange, "Channel {}", channel);
}
InitDutyCycle();
}