[hal] Remove everything that references chipobject or VISA (#7698)

This commit is contained in:
Thad House
2025-01-16 23:21:40 -08:00
committed by GitHub
parent ff1b2a205e
commit dc335ddedb
6 changed files with 0 additions and 375 deletions

View File

@@ -1,45 +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
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wpedantic"
#pragma GCC diagnostic ignored "-Wignored-qualifiers"
#include <stdint.h>
#include <FRC_FPGA_ChipObject/RoboRIO_FRC_ChipObject_Aliases.h>
#include <FRC_FPGA_ChipObject/nRoboRIO_FPGANamespace/nInterfaceGlobals.h>
#include <FRC_FPGA_ChipObject/nRoboRIO_FPGANamespace/tAI.h>
#include <FRC_FPGA_ChipObject/nRoboRIO_FPGANamespace/tAO.h>
#include <FRC_FPGA_ChipObject/nRoboRIO_FPGANamespace/tAccel.h>
#include <FRC_FPGA_ChipObject/nRoboRIO_FPGANamespace/tAccumulator.h>
#include <FRC_FPGA_ChipObject/nRoboRIO_FPGANamespace/tAlarm.h>
#include <FRC_FPGA_ChipObject/nRoboRIO_FPGANamespace/tAnalogTrigger.h>
#include <FRC_FPGA_ChipObject/nRoboRIO_FPGANamespace/tBIST.h>
#include <FRC_FPGA_ChipObject/nRoboRIO_FPGANamespace/tCounter.h>
#include <FRC_FPGA_ChipObject/nRoboRIO_FPGANamespace/tDIO.h>
#include <FRC_FPGA_ChipObject/nRoboRIO_FPGANamespace/tDMA.h>
#include <FRC_FPGA_ChipObject/nRoboRIO_FPGANamespace/tDutyCycle.h>
#include <FRC_FPGA_ChipObject/nRoboRIO_FPGANamespace/tEncoder.h>
#include <FRC_FPGA_ChipObject/nRoboRIO_FPGANamespace/tGlobal.h>
#include <FRC_FPGA_ChipObject/nRoboRIO_FPGANamespace/tHMB.h>
#include <FRC_FPGA_ChipObject/nRoboRIO_FPGANamespace/tInterrupt.h>
#include <FRC_FPGA_ChipObject/nRoboRIO_FPGANamespace/tLED.h>
#include <FRC_FPGA_ChipObject/nRoboRIO_FPGANamespace/tPWM.h>
#include <FRC_FPGA_ChipObject/nRoboRIO_FPGANamespace/tPower.h>
#include <FRC_FPGA_ChipObject/nRoboRIO_FPGANamespace/tRelay.h>
#include <FRC_FPGA_ChipObject/nRoboRIO_FPGANamespace/tSPI.h>
#include <FRC_FPGA_ChipObject/nRoboRIO_FPGANamespace/tSysWatchdog.h>
#include <FRC_FPGA_ChipObject/tDMAChannelDescriptor.h>
#include <FRC_FPGA_ChipObject/tDMAManager.h>
#include <FRC_FPGA_ChipObject/tSystem.h>
#include <FRC_FPGA_ChipObject/tSystemInterface.h>
namespace hal {
using namespace nFPGA;
using namespace nRoboRIO_FPGANamespace;
} // namespace hal
#pragma GCC diagnostic pop

View File

@@ -1,80 +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 <stdint.h>
#include <string>
#include <vector>
#include <wpi/SmallString.h>
#include <wpi/SmallVector.h>
#include <wpi/mutex.h>
#include "hal/SerialPort.h"
namespace hal {
/**
* A class for deterministically getting information about Serial Ports.
*/
class SerialHelper {
public:
SerialHelper();
/**
* Get the VISA name of a serial port.
*
* @param[in] port the serial port index
* @param[out] status status check
* @return the VISA name
*/
std::string GetVISASerialPortName(HAL_SerialPort port, int32_t* status);
/**
* Get the OS name of a serial port.
*
* @param[in] port the serial port index
* @param[out] status status check
* @return the OS name
*/
std::string GetOSSerialPortName(HAL_SerialPort port, int32_t* status);
/**
* Get a vector of all serial port VISA names.
*
* @param[out] status status check
* @return vector of serial port VISA names
*/
std::vector<std::string> GetVISASerialPortList(int32_t* status);
/**
* Get a vector of all serial port OS names.
*
* @param[out] status status check
* @return vector of serial port OS names
*/
std::vector<std::string> GetOSSerialPortList(int32_t* status);
private:
void SortHubPathVector();
void CoiteratedSort(wpi::SmallVectorImpl<wpi::SmallString<16>>& vec);
void QueryHubPaths(int32_t* status);
int32_t GetIndexForPort(HAL_SerialPort port, int32_t* status);
// Vectors to hold data before sorting.
// Note we will most likely have at max 2 instances, and the longest string
// is around 12, so these should never touch the heap;
wpi::SmallVector<wpi::SmallString<16>, 4> m_visaResource;
wpi::SmallVector<wpi::SmallString<16>, 4> m_osResource;
wpi::SmallVector<wpi::SmallString<16>, 4> m_unsortedHubPath;
wpi::SmallVector<wpi::SmallString<16>, 4> m_sortedHubPath;
int32_t m_resourceHandle;
static wpi::mutex m_nameMutex;
static std::string m_usbNames[2];
};
} // namespace hal

View File

@@ -1,104 +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 <wpi/mutex.h>
#include "hal/ChipObject.h"
#include "hal/Types.h"
namespace hal {
/**
* Proxy class for directly manipulating the DIO pins.
*
* This class is not copyable or movable, and should never be used
* outside of the UnsafeManipulateDIO callback.
*/
struct DIOSetProxy {
DIOSetProxy(tDIO::tOutputEnable setOutputDirReg,
tDIO::tOutputEnable unsetOutputDirReg,
tDIO::tDO setOutputStateReg, tDIO::tDO unsetOutputStateReg,
tDIO* dio)
: m_setOutputDirReg{setOutputDirReg},
m_unsetOutputDirReg{unsetOutputDirReg},
m_setOutputStateReg{setOutputStateReg},
m_unsetOutputStateReg{unsetOutputStateReg},
m_dio{dio} {}
DIOSetProxy(const DIOSetProxy&) = delete;
DIOSetProxy(DIOSetProxy&&) = delete;
DIOSetProxy& operator=(const DIOSetProxy&) = delete;
DIOSetProxy& operator=(DIOSetProxy&&) = delete;
void SetOutputMode(int32_t* status) {
m_dio->writeOutputEnable(m_setOutputDirReg, status);
}
void SetInputMode(int32_t* status) {
m_dio->writeOutputEnable(m_unsetOutputDirReg, status);
}
void SetOutputTrue(int32_t* status) {
m_dio->writeDO(m_setOutputStateReg, status);
}
void SetOutputFalse(int32_t* status) {
m_dio->writeDO(m_unsetOutputStateReg, status);
}
tDIO::tOutputEnable m_setOutputDirReg;
tDIO::tOutputEnable m_unsetOutputDirReg;
tDIO::tDO m_setOutputStateReg;
tDIO::tDO m_unsetOutputStateReg;
tDIO* m_dio;
};
namespace detail {
wpi::mutex& UnsafeGetDIOMutex();
tDIO* UnsafeGetDigitalSystem();
int32_t ComputeDigitalMask(HAL_DigitalHandle handle, int32_t* status);
} // namespace detail
/**
* Unsafe digital output set function
* This function can be used to perform fast and deterministically set digital
* outputs. This function holds the DIO lock, so calling anything other then
* functions on the Proxy object passed as a parameter can deadlock your
* program.
*
* @param[in] handle the HAL digital handle of the pin to toggle.
* @param[out] status status check
* @param[in] func A functor taking a ref to a DIOSetProxy object.
*/
template <typename Functor>
void UnsafeManipulateDIO(HAL_DigitalHandle handle, int32_t* status,
Functor func) {
auto port = digitalChannelHandles->Get(handle, HAL_HandleEnum::DIO);
if (port == nullptr) {
*status = HAL_HANDLE_ERROR;
return;
}
wpi::mutex& dioMutex = detail::UnsafeGetDIOMutex();
tDIO* dSys = detail::UnsafeGetDigitalSystem();
auto mask = detail::ComputeDigitalMask(handle, status);
if (*status != 0) {
return;
}
std::scoped_lock lock(dioMutex);
tDIO::tOutputEnable enableOE = dSys->readOutputEnable(status);
enableOE.value |= mask;
auto disableOE = enableOE;
disableOE.value &= ~mask;
tDIO::tDO enableDO = dSys->readDO(status);
enableDO.value |= mask;
auto disableDO = enableDO;
disableDO.value &= ~mask;
DIOSetProxy dioData{enableOE, disableOE, enableDO, disableDO, dSys};
func(dioData);
}
} // namespace hal

View File

@@ -1,112 +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 <stdint.h>
struct HAL_HMBData {
struct AnalogInputs {
uint32_t Values[8];
uint32_t Reserved[8];
} AnalogInputs;
struct AveragedAnalogInputs {
uint32_t Values[8];
uint32_t Reserved[8];
} AveragedAnalogInputs;
struct Accumulator0 {
uint32_t Count;
uint32_t Value0;
uint32_t Value1;
uint32_t Reserved[13];
} Accumulator0;
struct Accumulator1 {
uint32_t Count;
uint32_t Value0;
uint32_t Value1;
uint32_t Reserved[13];
} Accumulator1;
struct DI {
uint32_t Values;
uint32_t FilteredValues;
uint32_t Reserved[14];
} DI;
struct AnalogTriggers {
struct Trigger {
uint8_t InHysteresis0 : 1;
uint8_t OverLimit0 : 1;
uint8_t Rising0 : 1;
uint8_t Falling0 : 1;
uint8_t InHysteresis1 : 1;
uint8_t OverLimit1 : 1;
uint8_t Rising1 : 1;
uint8_t Falling1 : 1;
} Trigger[4];
uint32_t Reserved[15];
} AnalogTriggers;
struct Counters {
struct Counter {
uint32_t Direction : 1;
int32_t Value : 31;
} Counter[8];
uint32_t Reserved[8];
} Counters;
struct CounterTimers {
struct Timer {
uint32_t Period : 23;
int32_t Count : 8;
uint32_t Stalled : 1;
} Timer[8];
uint32_t Reserved[8];
} CounterTimers;
struct Encoders {
struct Encoder {
uint32_t Direction : 1;
int32_t Value : 31;
} Encoder[8];
uint32_t Reserved[8];
} Encoders;
struct EncoderTimers {
struct Timer {
uint32_t Period : 23;
int32_t Count : 8;
uint32_t Stalled : 1;
} Timer[8];
uint32_t Reserved[8];
} EncoderTimers;
struct DutyCycle {
uint32_t Output[8];
uint32_t Reserved[8];
} DutyCycle;
struct Interrupts {
struct Interrupt {
uint32_t FallingTimestamp;
uint32_t RisingTimestamp;
} Interrupt[8];
} Interrupts;
struct PWM {
uint32_t Headers[10];
uint32_t Reserved[6];
uint32_t MXP[10];
uint32_t Reserved2[6];
} PWM;
struct RelayDOAO {
uint32_t Relays;
uint32_t Reserved;
uint32_t AO[2];
uint32_t Reserved2[12];
} RelayDOAO;
struct Timestamp {
uint32_t Lower;
uint32_t Upper;
uint32_t Reserved[14];
} Timestamp;
};
extern "C" {
void HAL_InitializeHMB(int32_t* status);
const volatile HAL_HMBData* HAL_GetHMBBuffer(void);
} // extern "C"

View File

@@ -1,33 +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 <FRC_FPGA_ChipObject/fpgainterfacecapi/NiFpga.h>
#include <wpi/mutex.h>
#include "hal/ChipObject.h"
#include "hal/Types.h"
namespace hal {
class InterruptManager {
public:
static InterruptManager& GetInstance();
static void Initialize(tSystemInterface* baseSystem);
NiFpga_IrqContext GetContext() noexcept;
void ReleaseContext(NiFpga_IrqContext context) noexcept;
uint32_t WaitForInterrupt(NiFpga_IrqContext context, uint32_t mask,
bool ignorePrevious, uint32_t timeoutInMs,
int32_t* status);
private:
InterruptManager() = default;
wpi::priority_mutex currentMaskMutex;
uint32_t currentMask;
NiFpga_Session fpgaSession;
};
} // namespace hal

View File

@@ -21,7 +21,6 @@
#include <fmt/format.h>
#include "HALInternal.h"
#include "hal/cpp/SerialHelper.h"
#include "hal/handles/HandlesInternal.h"
#include "hal/handles/IndexedHandleResource.h"