From db71043c3d1c5cbf1e008c027b25a848032affc2 Mon Sep 17 00:00:00 2001 From: Thad House Date: Thu, 16 Jan 2025 17:40:39 -0800 Subject: [PATCH 1/2] Remove anything that references chipobject or VISA --- hal/src/main/native/include/hal/ChipObject.h | 45 ------- .../native/include/hal/cpp/SerialHelper.h | 80 ------------- .../main/native/include/hal/cpp/UnsafeDIO.h | 104 ---------------- hal/src/main/native/include/hal/roborio/HMB.h | 112 ------------------ .../include/hal/roborio/InterruptManager.h | 33 ------ 5 files changed, 374 deletions(-) delete mode 100644 hal/src/main/native/include/hal/ChipObject.h delete mode 100644 hal/src/main/native/include/hal/cpp/SerialHelper.h delete mode 100644 hal/src/main/native/include/hal/cpp/UnsafeDIO.h delete mode 100644 hal/src/main/native/include/hal/roborio/HMB.h delete mode 100644 hal/src/main/native/include/hal/roborio/InterruptManager.h diff --git a/hal/src/main/native/include/hal/ChipObject.h b/hal/src/main/native/include/hal/ChipObject.h deleted file mode 100644 index 23dcb3894a0..00000000000 --- a/hal/src/main/native/include/hal/ChipObject.h +++ /dev/null @@ -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 - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -namespace hal { -using namespace nFPGA; -using namespace nRoboRIO_FPGANamespace; -} // namespace hal - -#pragma GCC diagnostic pop diff --git a/hal/src/main/native/include/hal/cpp/SerialHelper.h b/hal/src/main/native/include/hal/cpp/SerialHelper.h deleted file mode 100644 index 13b6857d5a2..00000000000 --- a/hal/src/main/native/include/hal/cpp/SerialHelper.h +++ /dev/null @@ -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 - -#include -#include - -#include -#include -#include - -#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 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 GetOSSerialPortList(int32_t* status); - - private: - void SortHubPathVector(); - void CoiteratedSort(wpi::SmallVectorImpl>& 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, 4> m_visaResource; - wpi::SmallVector, 4> m_osResource; - wpi::SmallVector, 4> m_unsortedHubPath; - wpi::SmallVector, 4> m_sortedHubPath; - - int32_t m_resourceHandle; - - static wpi::mutex m_nameMutex; - static std::string m_usbNames[2]; -}; -} // namespace hal diff --git a/hal/src/main/native/include/hal/cpp/UnsafeDIO.h b/hal/src/main/native/include/hal/cpp/UnsafeDIO.h deleted file mode 100644 index d79265ec92f..00000000000 --- a/hal/src/main/native/include/hal/cpp/UnsafeDIO.h +++ /dev/null @@ -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 - -#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 -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 diff --git a/hal/src/main/native/include/hal/roborio/HMB.h b/hal/src/main/native/include/hal/roborio/HMB.h deleted file mode 100644 index fc7381bbed6..00000000000 --- a/hal/src/main/native/include/hal/roborio/HMB.h +++ /dev/null @@ -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 - -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" diff --git a/hal/src/main/native/include/hal/roborio/InterruptManager.h b/hal/src/main/native/include/hal/roborio/InterruptManager.h deleted file mode 100644 index 36d904b49ed..00000000000 --- a/hal/src/main/native/include/hal/roborio/InterruptManager.h +++ /dev/null @@ -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 -#include - -#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 From ebadd0b2a2c114bdafb801d845c8e80f0b025d3d Mon Sep 17 00:00:00 2001 From: Thad House Date: Thu, 16 Jan 2025 17:53:00 -0800 Subject: [PATCH 2/2] Fix --- hal/src/main/native/systemcore/SerialPort.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/hal/src/main/native/systemcore/SerialPort.cpp b/hal/src/main/native/systemcore/SerialPort.cpp index 70825a1690f..64e24c82c22 100644 --- a/hal/src/main/native/systemcore/SerialPort.cpp +++ b/hal/src/main/native/systemcore/SerialPort.cpp @@ -21,7 +21,6 @@ #include #include "HALInternal.h" -#include "hal/cpp/SerialHelper.h" #include "hal/handles/HandlesInternal.h" #include "hal/handles/IndexedHandleResource.h"