mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-30 02:31:44 +00:00
[hal,ntcore,cscore] Update Handle constants to all caps
This commit is contained in:
@@ -20,13 +20,13 @@ using namespace wpi::util::java;
|
||||
|
||||
static wpi::hal::UnlimitedHandleResource<
|
||||
SIM_JniHandle, BufferCallbackStore,
|
||||
wpi::hal::HAL_HandleEnum::SimulationJni>* callbackHandles;
|
||||
wpi::hal::HAL_HandleEnum::SIMULATION_JNI>* callbackHandles;
|
||||
|
||||
namespace wpi::hal::sim {
|
||||
void InitializeBufferStore() {
|
||||
static wpi::hal::UnlimitedHandleResource<
|
||||
SIM_JniHandle, BufferCallbackStore,
|
||||
wpi::hal::HAL_HandleEnum::SimulationJni>
|
||||
wpi::hal::HAL_HandleEnum::SIMULATION_JNI>
|
||||
cb;
|
||||
callbackHandles = &cb;
|
||||
}
|
||||
|
||||
@@ -20,13 +20,13 @@ using namespace wpi::hal::sim;
|
||||
using namespace wpi::util::java;
|
||||
|
||||
static wpi::hal::UnlimitedHandleResource<
|
||||
SIM_JniHandle, CallbackStore, wpi::hal::HAL_HandleEnum::SimulationJni>*
|
||||
SIM_JniHandle, CallbackStore, wpi::hal::HAL_HandleEnum::SIMULATION_JNI>*
|
||||
callbackHandles;
|
||||
|
||||
namespace wpi::hal::sim {
|
||||
void InitializeStore() {
|
||||
static wpi::hal::UnlimitedHandleResource<
|
||||
SIM_JniHandle, CallbackStore, wpi::hal::HAL_HandleEnum::SimulationJni>
|
||||
SIM_JniHandle, CallbackStore, wpi::hal::HAL_HandleEnum::SIMULATION_JNI>
|
||||
cb;
|
||||
callbackHandles = &cb;
|
||||
}
|
||||
|
||||
@@ -20,13 +20,13 @@ using namespace wpi::util::java;
|
||||
|
||||
static wpi::hal::UnlimitedHandleResource<
|
||||
SIM_JniHandle, ConstBufferCallbackStore,
|
||||
wpi::hal::HAL_HandleEnum::SimulationJni>* callbackHandles;
|
||||
wpi::hal::HAL_HandleEnum::SIMULATION_JNI>* callbackHandles;
|
||||
|
||||
namespace wpi::hal::sim {
|
||||
void InitializeConstBufferStore() {
|
||||
static wpi::hal::UnlimitedHandleResource<
|
||||
SIM_JniHandle, ConstBufferCallbackStore,
|
||||
wpi::hal::HAL_HandleEnum::SimulationJni>
|
||||
wpi::hal::HAL_HandleEnum::SIMULATION_JNI>
|
||||
cb;
|
||||
callbackHandles = &cb;
|
||||
}
|
||||
|
||||
@@ -20,12 +20,12 @@ using namespace wpi::hal::sim;
|
||||
using namespace wpi::util::java;
|
||||
|
||||
static UnlimitedHandleResource<SIM_JniHandle, OpModeOptionsCallbackStore,
|
||||
HAL_HandleEnum::SimulationJni>* callbackHandles;
|
||||
HAL_HandleEnum::SIMULATION_JNI>* callbackHandles;
|
||||
|
||||
namespace wpi::hal::sim {
|
||||
void InitializeOpModeOptionsStore() {
|
||||
static UnlimitedHandleResource<SIM_JniHandle, OpModeOptionsCallbackStore,
|
||||
HAL_HandleEnum::SimulationJni>
|
||||
HAL_HandleEnum::SIMULATION_JNI>
|
||||
cb;
|
||||
callbackHandles = &cb;
|
||||
}
|
||||
|
||||
@@ -195,7 +195,7 @@ void ValueCallbackStore::performCallback(const char* name,
|
||||
|
||||
static wpi::hal::UnlimitedHandleResource<
|
||||
SIM_JniHandle, DeviceCallbackStore,
|
||||
wpi::hal::HAL_HandleEnum::SimulationJni>* deviceCallbackHandles;
|
||||
wpi::hal::HAL_HandleEnum::SIMULATION_JNI>* deviceCallbackHandles;
|
||||
|
||||
namespace {
|
||||
using RegisterDeviceCallbackFunc =
|
||||
@@ -251,8 +251,8 @@ static void FreeDeviceCallback(JNIEnv* env, SIM_JniHandle handle,
|
||||
}
|
||||
|
||||
static wpi::hal::UnlimitedHandleResource<
|
||||
SIM_JniHandle, ValueCallbackStore, wpi::hal::HAL_HandleEnum::SimulationJni>*
|
||||
valueCallbackHandles;
|
||||
SIM_JniHandle, ValueCallbackStore,
|
||||
wpi::hal::HAL_HandleEnum::SIMULATION_JNI>* valueCallbackHandles;
|
||||
|
||||
namespace {
|
||||
using FreeValueCallbackFunc = void (*)(int32_t uid);
|
||||
@@ -348,13 +348,13 @@ bool InitializeSimDeviceDataJNI(JNIEnv* env) {
|
||||
|
||||
static wpi::hal::UnlimitedHandleResource<
|
||||
SIM_JniHandle, DeviceCallbackStore,
|
||||
wpi::hal::HAL_HandleEnum::SimulationJni>
|
||||
wpi::hal::HAL_HandleEnum::SIMULATION_JNI>
|
||||
cbDevice;
|
||||
deviceCallbackHandles = &cbDevice;
|
||||
|
||||
static wpi::hal::UnlimitedHandleResource<
|
||||
SIM_JniHandle, ValueCallbackStore,
|
||||
wpi::hal::HAL_HandleEnum::SimulationJni>
|
||||
wpi::hal::HAL_HandleEnum::SIMULATION_JNI>
|
||||
cbValue;
|
||||
valueCallbackHandles = &cbValue;
|
||||
|
||||
|
||||
@@ -37,42 +37,42 @@ class HandleBase {
|
||||
int16_t m_version;
|
||||
};
|
||||
|
||||
constexpr int16_t InvalidHandleIndex = -1;
|
||||
constexpr int16_t INVALID_HANDLE_INDEX = -1;
|
||||
|
||||
/**
|
||||
* Enum of HAL handle types. Vendors/Teams should use Vendor (17).
|
||||
*/
|
||||
enum class HAL_HandleEnum {
|
||||
Undefined = 0,
|
||||
DIO = wpi::util::kHandleTypeHALBase,
|
||||
Port = 2,
|
||||
Notifier = 3,
|
||||
Interrupt = 4,
|
||||
AnalogOutput = 5,
|
||||
AnalogInput = 6,
|
||||
AnalogTrigger = 7,
|
||||
Relay = 8,
|
||||
UNDEFINED = 0,
|
||||
DIO = wpi::util::HANDLE_TYPE_HAL_BASE,
|
||||
PORT = 2,
|
||||
NOTIFIER = 3,
|
||||
INTERRUPT = 4,
|
||||
ANALOG_OUTPUT = 5,
|
||||
ANALOG_INPUT = 6,
|
||||
ANALOG_TRIGGER = 7,
|
||||
RELAY = 8,
|
||||
PWM = 9,
|
||||
DigitalPWM = 10,
|
||||
Counter = 11,
|
||||
FPGAEncoder = 12,
|
||||
Encoder = 13,
|
||||
Compressor = 14,
|
||||
Solenoid = 15,
|
||||
AnalogGyro = 16,
|
||||
Vendor = 17,
|
||||
SimulationJni = 18,
|
||||
DIGITAL_PWM = 10,
|
||||
COUNTER = 11,
|
||||
FPGA_ENCODER = 12,
|
||||
ENCODER = 13,
|
||||
COMPRESSOR = 14,
|
||||
SOLENOID = 15,
|
||||
ANALOG_GYRO = 16,
|
||||
VENDOR = 17,
|
||||
SIMULATION_JNI = 18,
|
||||
CAN = 19,
|
||||
SerialPort = 20,
|
||||
DutyCycle = 21,
|
||||
SERIAL_PORT = 20,
|
||||
DUTY_CYCLE = 21,
|
||||
DMA = 22,
|
||||
AddressableLED = 23,
|
||||
CTREPCM = 24,
|
||||
CTREPDP = 25,
|
||||
REVPDH = 26,
|
||||
REVPH = 27,
|
||||
CANStream = 28,
|
||||
Alert = 29,
|
||||
ADDRESSABLE_LED = 23,
|
||||
CTRE_PCM = 24,
|
||||
CTRE_PDP = 25,
|
||||
REV_PDH = 26,
|
||||
REV_PH = 27,
|
||||
CAN_STREAM = 28,
|
||||
ALERT = 29,
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -135,11 +135,11 @@ static inline bool isHandleCorrectVersion(HAL_Handle handle, int16_t version) {
|
||||
inline int16_t getHandleTypedIndex(HAL_Handle handle, HAL_HandleEnum enumType,
|
||||
int16_t version) {
|
||||
if (!isHandleType(handle, enumType)) {
|
||||
return InvalidHandleIndex;
|
||||
return INVALID_HANDLE_INDEX;
|
||||
}
|
||||
#if !defined(__FIRST_SYSTEMCORE__)
|
||||
if (!isHandleCorrectVersion(handle, version)) {
|
||||
return InvalidHandleIndex;
|
||||
return INVALID_HANDLE_INDEX;
|
||||
}
|
||||
#endif
|
||||
return getHandleIndex(handle);
|
||||
|
||||
@@ -36,7 +36,7 @@ HAL_AddressableLEDHandle HAL_InitializeAddressableLED(
|
||||
HAL_DigitalHandle handle;
|
||||
|
||||
auto port = digitalChannelHandles->Allocate(
|
||||
channel, HAL_HandleEnum::AddressableLED, &handle, status);
|
||||
channel, HAL_HandleEnum::ADDRESSABLE_LED, &handle, status);
|
||||
|
||||
if (*status != 0) {
|
||||
if (port) {
|
||||
@@ -62,9 +62,9 @@ HAL_AddressableLEDHandle HAL_InitializeAddressableLED(
|
||||
|
||||
void HAL_FreeAddressableLED(HAL_AddressableLEDHandle handle) {
|
||||
auto port =
|
||||
digitalChannelHandles->Get(handle, HAL_HandleEnum::AddressableLED);
|
||||
digitalChannelHandles->Get(handle, HAL_HandleEnum::ADDRESSABLE_LED);
|
||||
// no status, so no need to check for a proper free.
|
||||
digitalChannelHandles->Free(handle, HAL_HandleEnum::AddressableLED);
|
||||
digitalChannelHandles->Free(handle, HAL_HandleEnum::ADDRESSABLE_LED);
|
||||
if (port == nullptr) {
|
||||
return;
|
||||
}
|
||||
@@ -74,7 +74,7 @@ void HAL_FreeAddressableLED(HAL_AddressableLEDHandle handle) {
|
||||
void HAL_SetAddressableLEDStart(HAL_AddressableLEDHandle handle, int32_t start,
|
||||
int32_t* status) {
|
||||
auto port =
|
||||
digitalChannelHandles->Get(handle, HAL_HandleEnum::AddressableLED);
|
||||
digitalChannelHandles->Get(handle, HAL_HandleEnum::ADDRESSABLE_LED);
|
||||
if (!port) {
|
||||
*status = HAL_HANDLE_ERROR;
|
||||
return;
|
||||
@@ -94,7 +94,7 @@ void HAL_SetAddressableLEDStart(HAL_AddressableLEDHandle handle, int32_t start,
|
||||
void HAL_SetAddressableLEDLength(HAL_AddressableLEDHandle handle,
|
||||
int32_t length, int32_t* status) {
|
||||
auto port =
|
||||
digitalChannelHandles->Get(handle, HAL_HandleEnum::AddressableLED);
|
||||
digitalChannelHandles->Get(handle, HAL_HandleEnum::ADDRESSABLE_LED);
|
||||
if (!port) {
|
||||
*status = HAL_HANDLE_ERROR;
|
||||
return;
|
||||
|
||||
@@ -33,12 +33,12 @@ struct Alert {
|
||||
|
||||
using namespace wpi::hal;
|
||||
|
||||
static UnlimitedHandleResource<HAL_AlertHandle, Alert, HAL_HandleEnum::Alert>*
|
||||
static UnlimitedHandleResource<HAL_AlertHandle, Alert, HAL_HandleEnum::ALERT>*
|
||||
alertHandles;
|
||||
|
||||
namespace wpi::hal::init {
|
||||
void InitializeAlert() {
|
||||
static UnlimitedHandleResource<HAL_AlertHandle, Alert, HAL_HandleEnum::Alert>
|
||||
static UnlimitedHandleResource<HAL_AlertHandle, Alert, HAL_HandleEnum::ALERT>
|
||||
aH;
|
||||
alertHandles = &aH;
|
||||
}
|
||||
|
||||
@@ -9,14 +9,14 @@
|
||||
|
||||
namespace wpi::hal {
|
||||
IndexedHandleResource<HAL_AnalogInputHandle, wpi::hal::AnalogPort,
|
||||
kNumAnalogInputs, HAL_HandleEnum::AnalogInput>*
|
||||
kNumAnalogInputs, HAL_HandleEnum::ANALOG_INPUT>*
|
||||
analogInputHandles;
|
||||
} // namespace wpi::hal
|
||||
|
||||
namespace wpi::hal::init {
|
||||
void InitializeAnalogInternal() {
|
||||
static IndexedHandleResource<HAL_AnalogInputHandle, wpi::hal::AnalogPort,
|
||||
kNumAnalogInputs, HAL_HandleEnum::AnalogInput>
|
||||
kNumAnalogInputs, HAL_HandleEnum::ANALOG_INPUT>
|
||||
aiH;
|
||||
analogInputHandles = &aiH;
|
||||
}
|
||||
|
||||
@@ -26,6 +26,6 @@ struct AnalogPort {
|
||||
};
|
||||
|
||||
extern IndexedHandleResource<HAL_AnalogInputHandle, wpi::hal::AnalogPort,
|
||||
kNumAnalogInputs, HAL_HandleEnum::AnalogInput>*
|
||||
kNumAnalogInputs, HAL_HandleEnum::ANALOG_INPUT>*
|
||||
analogInputHandles;
|
||||
} // namespace wpi::hal
|
||||
|
||||
@@ -24,12 +24,12 @@ struct PCM {
|
||||
} // namespace
|
||||
|
||||
static IndexedHandleResource<HAL_CTREPCMHandle, PCM, kNumCTREPCMModules,
|
||||
HAL_HandleEnum::CTREPCM>* pcmHandles;
|
||||
HAL_HandleEnum::CTRE_PCM>* pcmHandles;
|
||||
|
||||
namespace wpi::hal::init {
|
||||
void InitializeCTREPCM() {
|
||||
static IndexedHandleResource<HAL_CTREPCMHandle, PCM, kNumCTREPCMModules,
|
||||
HAL_HandleEnum::CTREPCM>
|
||||
HAL_HandleEnum::CTRE_PCM>
|
||||
pH;
|
||||
pcmHandles = &pH;
|
||||
}
|
||||
|
||||
@@ -13,13 +13,13 @@
|
||||
namespace wpi::hal {
|
||||
|
||||
LimitedHandleResource<HAL_CounterHandle, Counter, kNumCounters,
|
||||
HAL_HandleEnum::Counter>* counterHandles;
|
||||
HAL_HandleEnum::COUNTER>* counterHandles;
|
||||
} // namespace wpi::hal
|
||||
|
||||
namespace wpi::hal::init {
|
||||
void InitializeCounter() {
|
||||
static LimitedHandleResource<HAL_CounterHandle, Counter, kNumCounters,
|
||||
HAL_HandleEnum::Counter>
|
||||
HAL_HandleEnum::COUNTER>
|
||||
cH;
|
||||
counterHandles = &cH;
|
||||
}
|
||||
|
||||
@@ -15,6 +15,6 @@ struct Counter {
|
||||
};
|
||||
|
||||
extern LimitedHandleResource<HAL_CounterHandle, Counter, kNumCounters,
|
||||
HAL_HandleEnum::Counter>* counterHandles;
|
||||
HAL_HandleEnum::COUNTER>* counterHandles;
|
||||
|
||||
} // namespace wpi::hal
|
||||
|
||||
@@ -16,14 +16,14 @@
|
||||
using namespace wpi::hal;
|
||||
|
||||
static LimitedHandleResource<HAL_DigitalPWMHandle, uint8_t,
|
||||
kNumDigitalPWMOutputs, HAL_HandleEnum::DigitalPWM>*
|
||||
digitalPWMHandles;
|
||||
kNumDigitalPWMOutputs,
|
||||
HAL_HandleEnum::DIGITAL_PWM>* digitalPWMHandles;
|
||||
|
||||
namespace wpi::hal::init {
|
||||
void InitializeDIO() {
|
||||
static LimitedHandleResource<HAL_DigitalPWMHandle, uint8_t,
|
||||
kNumDigitalPWMOutputs,
|
||||
HAL_HandleEnum::DigitalPWM>
|
||||
HAL_HandleEnum::DIGITAL_PWM>
|
||||
dpH;
|
||||
digitalPWMHandles = &dpH;
|
||||
}
|
||||
|
||||
@@ -25,12 +25,12 @@ struct Empty {};
|
||||
} // namespace
|
||||
|
||||
static IndexedHandleResource<HAL_DutyCycleHandle, DutyCycle, kNumDutyCycles,
|
||||
HAL_HandleEnum::DutyCycle>* dutyCycleHandles;
|
||||
HAL_HandleEnum::DUTY_CYCLE>* dutyCycleHandles;
|
||||
|
||||
namespace wpi::hal::init {
|
||||
void InitializeDutyCycle() {
|
||||
static IndexedHandleResource<HAL_DutyCycleHandle, DutyCycle, kNumDutyCycles,
|
||||
HAL_HandleEnum::DutyCycle>
|
||||
HAL_HandleEnum::DUTY_CYCLE>
|
||||
dcH;
|
||||
dutyCycleHandles = &dcH;
|
||||
}
|
||||
|
||||
@@ -31,20 +31,20 @@ struct Empty {};
|
||||
|
||||
static LimitedHandleResource<HAL_EncoderHandle, Encoder,
|
||||
kNumEncoders + kNumCounters,
|
||||
HAL_HandleEnum::Encoder>* encoderHandles;
|
||||
HAL_HandleEnum::ENCODER>* encoderHandles;
|
||||
|
||||
static LimitedHandleResource<HAL_FPGAEncoderHandle, Empty, kNumEncoders,
|
||||
HAL_HandleEnum::FPGAEncoder>* fpgaEncoderHandles;
|
||||
HAL_HandleEnum::FPGA_ENCODER>* fpgaEncoderHandles;
|
||||
|
||||
namespace wpi::hal::init {
|
||||
void InitializeEncoder() {
|
||||
static LimitedHandleResource<HAL_FPGAEncoderHandle, Empty, kNumEncoders,
|
||||
HAL_HandleEnum::FPGAEncoder>
|
||||
HAL_HandleEnum::FPGA_ENCODER>
|
||||
feH;
|
||||
fpgaEncoderHandles = &feH;
|
||||
static LimitedHandleResource<HAL_EncoderHandle, Encoder,
|
||||
kNumEncoders + kNumCounters,
|
||||
HAL_HandleEnum::Encoder>
|
||||
HAL_HandleEnum::ENCODER>
|
||||
eH;
|
||||
encoderHandles = &eH;
|
||||
}
|
||||
@@ -120,9 +120,9 @@ void HAL_FreeEncoder(HAL_EncoderHandle encoderHandle) {
|
||||
if (encoder == nullptr) {
|
||||
return;
|
||||
}
|
||||
if (isHandleType(encoder->nativeHandle, HAL_HandleEnum::FPGAEncoder)) {
|
||||
if (isHandleType(encoder->nativeHandle, HAL_HandleEnum::FPGA_ENCODER)) {
|
||||
fpgaEncoderHandles->Free(encoder->nativeHandle);
|
||||
} else if (isHandleType(encoder->nativeHandle, HAL_HandleEnum::Counter)) {
|
||||
} else if (isHandleType(encoder->nativeHandle, HAL_HandleEnum::COUNTER)) {
|
||||
counterHandles->Free(encoder->nativeHandle);
|
||||
}
|
||||
SimEncoderData[encoder->index].initialized = false;
|
||||
|
||||
@@ -52,7 +52,7 @@ class NotifierThread : public wpi::util::SafeThread {
|
||||
bool m_paused = false;
|
||||
|
||||
UnlimitedHandleResource<HAL_NotifierHandle, Notifier,
|
||||
HAL_HandleEnum::Notifier>
|
||||
HAL_HandleEnum::NOTIFIER>
|
||||
m_handles;
|
||||
|
||||
struct Alarm {
|
||||
|
||||
@@ -24,12 +24,12 @@ struct PCM {
|
||||
} // namespace
|
||||
|
||||
static IndexedHandleResource<HAL_REVPHHandle, PCM, kNumREVPHModules,
|
||||
HAL_HandleEnum::REVPH>* pcmHandles;
|
||||
HAL_HandleEnum::REV_PH>* pcmHandles;
|
||||
|
||||
namespace wpi::hal::init {
|
||||
void InitializeREVPH() {
|
||||
static IndexedHandleResource<HAL_REVPHHandle, PCM, kNumREVPHModules,
|
||||
HAL_HandleEnum::REVPH>
|
||||
HAL_HandleEnum::REV_PH>
|
||||
pH;
|
||||
pcmHandles = &pH;
|
||||
}
|
||||
|
||||
@@ -97,7 +97,7 @@ HAL_AddressableLEDHandle HAL_InitializeAddressableLED(
|
||||
|
||||
HAL_DigitalHandle handle;
|
||||
|
||||
auto port = smartIoHandles->Allocate(channel, HAL_HandleEnum::AddressableLED,
|
||||
auto port = smartIoHandles->Allocate(channel, HAL_HandleEnum::ADDRESSABLE_LED,
|
||||
&handle, status);
|
||||
|
||||
if (*status != 0) {
|
||||
@@ -115,7 +115,7 @@ HAL_AddressableLEDHandle HAL_InitializeAddressableLED(
|
||||
|
||||
*status = port->InitializeMode(SmartIoMode::AddressableLED);
|
||||
if (*status != 0) {
|
||||
smartIoHandles->Free(handle, HAL_HandleEnum::AddressableLED);
|
||||
smartIoHandles->Free(handle, HAL_HandleEnum::ADDRESSABLE_LED);
|
||||
return HAL_kInvalidHandle;
|
||||
}
|
||||
|
||||
@@ -125,12 +125,12 @@ HAL_AddressableLEDHandle HAL_InitializeAddressableLED(
|
||||
}
|
||||
|
||||
void HAL_FreeAddressableLED(HAL_AddressableLEDHandle handle) {
|
||||
auto port = smartIoHandles->Get(handle, HAL_HandleEnum::AddressableLED);
|
||||
auto port = smartIoHandles->Get(handle, HAL_HandleEnum::ADDRESSABLE_LED);
|
||||
if (port == nullptr) {
|
||||
return;
|
||||
}
|
||||
|
||||
smartIoHandles->Free(handle, HAL_HandleEnum::AddressableLED);
|
||||
smartIoHandles->Free(handle, HAL_HandleEnum::ADDRESSABLE_LED);
|
||||
|
||||
// Wait for no other object to hold this handle.
|
||||
auto start = wpi::hal::monotonic_clock::now();
|
||||
@@ -147,7 +147,7 @@ void HAL_FreeAddressableLED(HAL_AddressableLEDHandle handle) {
|
||||
|
||||
void HAL_SetAddressableLEDStart(HAL_AddressableLEDHandle handle, int32_t start,
|
||||
int32_t* status) {
|
||||
auto port = smartIoHandles->Get(handle, HAL_HandleEnum::AddressableLED);
|
||||
auto port = smartIoHandles->Get(handle, HAL_HandleEnum::ADDRESSABLE_LED);
|
||||
if (port == nullptr) {
|
||||
*status = HAL_HANDLE_ERROR;
|
||||
return;
|
||||
@@ -158,7 +158,7 @@ void HAL_SetAddressableLEDStart(HAL_AddressableLEDHandle handle, int32_t start,
|
||||
|
||||
void HAL_SetAddressableLEDLength(HAL_AddressableLEDHandle handle,
|
||||
int32_t length, int32_t* status) {
|
||||
auto port = smartIoHandles->Get(handle, HAL_HandleEnum::AddressableLED);
|
||||
auto port = smartIoHandles->Get(handle, HAL_HandleEnum::ADDRESSABLE_LED);
|
||||
if (port == nullptr) {
|
||||
*status = HAL_HANDLE_ERROR;
|
||||
return;
|
||||
|
||||
@@ -33,12 +33,12 @@ struct Alert {
|
||||
|
||||
using namespace wpi::hal;
|
||||
|
||||
static UnlimitedHandleResource<HAL_AlertHandle, Alert, HAL_HandleEnum::Alert>*
|
||||
static UnlimitedHandleResource<HAL_AlertHandle, Alert, HAL_HandleEnum::ALERT>*
|
||||
alertHandles;
|
||||
|
||||
namespace wpi::hal::init {
|
||||
void InitializeAlert() {
|
||||
static UnlimitedHandleResource<HAL_AlertHandle, Alert, HAL_HandleEnum::Alert>
|
||||
static UnlimitedHandleResource<HAL_AlertHandle, Alert, HAL_HandleEnum::ALERT>
|
||||
aH;
|
||||
alertHandles = &aH;
|
||||
}
|
||||
|
||||
@@ -36,7 +36,7 @@ HAL_AnalogInputHandle HAL_InitializeAnalogInputPort(
|
||||
|
||||
HAL_DigitalHandle handle;
|
||||
|
||||
auto port = smartIoHandles->Allocate(channel, HAL_HandleEnum::AnalogInput,
|
||||
auto port = smartIoHandles->Allocate(channel, HAL_HandleEnum::ANALOG_INPUT,
|
||||
&handle, status);
|
||||
|
||||
if (*status != 0) {
|
||||
@@ -54,7 +54,7 @@ HAL_AnalogInputHandle HAL_InitializeAnalogInputPort(
|
||||
|
||||
*status = port->InitializeMode(SmartIoMode::AnalogInput);
|
||||
if (*status != 0) {
|
||||
smartIoHandles->Free(handle, HAL_HandleEnum::AnalogInput);
|
||||
smartIoHandles->Free(handle, HAL_HandleEnum::ANALOG_INPUT);
|
||||
return HAL_kInvalidHandle;
|
||||
}
|
||||
|
||||
@@ -65,12 +65,12 @@ HAL_AnalogInputHandle HAL_InitializeAnalogInputPort(
|
||||
|
||||
void HAL_FreeAnalogInputPort(HAL_AnalogInputHandle analogPortHandle) {
|
||||
auto port =
|
||||
smartIoHandles->Get(analogPortHandle, HAL_HandleEnum::AnalogInput);
|
||||
smartIoHandles->Get(analogPortHandle, HAL_HandleEnum::ANALOG_INPUT);
|
||||
if (port == nullptr) {
|
||||
return;
|
||||
}
|
||||
|
||||
smartIoHandles->Free(analogPortHandle, HAL_HandleEnum::AnalogInput);
|
||||
smartIoHandles->Free(analogPortHandle, HAL_HandleEnum::ANALOG_INPUT);
|
||||
|
||||
// Wait for no other object to hold this handle.
|
||||
auto start = wpi::hal::monotonic_clock::now();
|
||||
@@ -133,7 +133,7 @@ int32_t HAL_GetAnalogOversampleBits(HAL_AnalogInputHandle analogPortHandle,
|
||||
int32_t HAL_GetAnalogValue(HAL_AnalogInputHandle analogPortHandle,
|
||||
int32_t* status) {
|
||||
auto port =
|
||||
smartIoHandles->Get(analogPortHandle, HAL_HandleEnum::AnalogInput);
|
||||
smartIoHandles->Get(analogPortHandle, HAL_HandleEnum::ANALOG_INPUT);
|
||||
if (port == nullptr) {
|
||||
*status = HAL_HANDLE_ERROR;
|
||||
return 0;
|
||||
@@ -159,7 +159,7 @@ int32_t HAL_GetAnalogVoltsToValue(HAL_AnalogInputHandle analogPortHandle,
|
||||
double HAL_GetAnalogVoltage(HAL_AnalogInputHandle analogPortHandle,
|
||||
int32_t* status) {
|
||||
auto port =
|
||||
smartIoHandles->Get(analogPortHandle, HAL_HandleEnum::AnalogInput);
|
||||
smartIoHandles->Get(analogPortHandle, HAL_HandleEnum::ANALOG_INPUT);
|
||||
if (port == nullptr) {
|
||||
*status = HAL_HANDLE_ERROR;
|
||||
return 0;
|
||||
|
||||
@@ -117,7 +117,7 @@ struct SocketCanState {
|
||||
} // namespace
|
||||
|
||||
static UnlimitedHandleResource<HAL_CANStreamHandle, CANStreamStorage,
|
||||
HAL_HandleEnum::CANStream>* canStreamHandles;
|
||||
HAL_HandleEnum::CAN_STREAM>* canStreamHandles;
|
||||
|
||||
static SocketCanState* canState;
|
||||
|
||||
@@ -125,7 +125,7 @@ namespace wpi::hal::init {
|
||||
void InitializeCAN() {
|
||||
canState = new SocketCanState{};
|
||||
static UnlimitedHandleResource<HAL_CANStreamHandle, CANStreamStorage,
|
||||
HAL_HandleEnum::CANStream>
|
||||
HAL_HandleEnum::CAN_STREAM>
|
||||
cSH;
|
||||
canStreamHandles = &cSH;
|
||||
}
|
||||
|
||||
@@ -134,12 +134,12 @@ struct PCM {
|
||||
} // namespace
|
||||
|
||||
static IndexedHandleResource<HAL_CTREPCMHandle, PCM, kNumCTREPCMModules,
|
||||
HAL_HandleEnum::CTREPCM>* pcmHandles;
|
||||
HAL_HandleEnum::CTRE_PCM>* pcmHandles;
|
||||
|
||||
namespace wpi::hal::init {
|
||||
void InitializeCTREPCM() {
|
||||
static IndexedHandleResource<HAL_CTREPCMHandle, PCM, kNumCTREPCMModules,
|
||||
HAL_HandleEnum::CTREPCM>
|
||||
HAL_HandleEnum::CTRE_PCM>
|
||||
pH;
|
||||
pcmHandles = &pH;
|
||||
}
|
||||
|
||||
@@ -115,12 +115,12 @@ struct PDP {
|
||||
} // namespace
|
||||
|
||||
static IndexedHandleResource<HAL_PDPHandle, PDP, kNumCTREPDPModules,
|
||||
HAL_HandleEnum::CTREPDP>* pdpHandles;
|
||||
HAL_HandleEnum::CTRE_PDP>* pdpHandles;
|
||||
|
||||
namespace wpi::hal::init {
|
||||
void InitializeCTREPDP() {
|
||||
static IndexedHandleResource<HAL_PDPHandle, PDP, kNumCTREPDPModules,
|
||||
HAL_HandleEnum::CTREPDP>
|
||||
HAL_HandleEnum::CTRE_PDP>
|
||||
pH;
|
||||
pdpHandles = &pH;
|
||||
}
|
||||
|
||||
@@ -27,7 +27,7 @@ HAL_CounterHandle HAL_InitializeCounter(int channel, HAL_Bool risingEdge,
|
||||
const char* allocationLocation,
|
||||
int32_t* status) {
|
||||
wpi::hal::init::CheckInit();
|
||||
if (channel == InvalidHandleIndex || channel >= kNumSmartIo) {
|
||||
if (channel == INVALID_HANDLE_INDEX || channel >= kNumSmartIo) {
|
||||
*status = RESOURCE_OUT_OF_RANGE;
|
||||
wpi::hal::SetLastErrorIndexOutOfRange(status, "Invalid Index for Counter",
|
||||
0, kNumSmartIo, channel);
|
||||
@@ -36,7 +36,7 @@ HAL_CounterHandle HAL_InitializeCounter(int channel, HAL_Bool risingEdge,
|
||||
|
||||
HAL_CounterHandle handle;
|
||||
|
||||
auto port = smartIoHandles->Allocate(channel, HAL_HandleEnum::Counter,
|
||||
auto port = smartIoHandles->Allocate(channel, HAL_HandleEnum::COUNTER,
|
||||
&handle, status);
|
||||
|
||||
if (*status != 0) {
|
||||
@@ -56,7 +56,7 @@ HAL_CounterHandle HAL_InitializeCounter(int channel, HAL_Bool risingEdge,
|
||||
port->InitializeMode(risingEdge ? SmartIoMode::SingleCounterRising
|
||||
: SmartIoMode::SingleCounterFalling);
|
||||
if (*status != 0) {
|
||||
smartIoHandles->Free(handle, HAL_HandleEnum::Counter);
|
||||
smartIoHandles->Free(handle, HAL_HandleEnum::COUNTER);
|
||||
return HAL_kInvalidHandle;
|
||||
}
|
||||
|
||||
@@ -66,12 +66,12 @@ HAL_CounterHandle HAL_InitializeCounter(int channel, HAL_Bool risingEdge,
|
||||
}
|
||||
|
||||
void HAL_FreeCounter(HAL_CounterHandle counterHandle) {
|
||||
auto port = smartIoHandles->Get(counterHandle, HAL_HandleEnum::Counter);
|
||||
auto port = smartIoHandles->Get(counterHandle, HAL_HandleEnum::COUNTER);
|
||||
if (port == nullptr) {
|
||||
return;
|
||||
}
|
||||
|
||||
smartIoHandles->Free(counterHandle, HAL_HandleEnum::Counter);
|
||||
smartIoHandles->Free(counterHandle, HAL_HandleEnum::COUNTER);
|
||||
|
||||
// Wait for no other object to hold this handle.
|
||||
auto start = wpi::hal::monotonic_clock::now();
|
||||
@@ -98,7 +98,7 @@ void HAL_ResetCounter(HAL_CounterHandle counterHandle, int32_t* status) {
|
||||
}
|
||||
|
||||
int32_t HAL_GetCounter(HAL_CounterHandle counterHandle, int32_t* status) {
|
||||
auto port = smartIoHandles->Get(counterHandle, HAL_HandleEnum::Counter);
|
||||
auto port = smartIoHandles->Get(counterHandle, HAL_HandleEnum::COUNTER);
|
||||
if (port == nullptr) {
|
||||
*status = HAL_HANDLE_ERROR;
|
||||
return false;
|
||||
|
||||
@@ -36,7 +36,7 @@ HAL_DutyCycleHandle HAL_InitializeDutyCycle(int32_t channel,
|
||||
|
||||
HAL_DigitalHandle handle;
|
||||
|
||||
auto port = smartIoHandles->Allocate(channel, HAL_HandleEnum::DutyCycle,
|
||||
auto port = smartIoHandles->Allocate(channel, HAL_HandleEnum::DUTY_CYCLE,
|
||||
&handle, status);
|
||||
|
||||
if (*status != 0) {
|
||||
@@ -54,7 +54,7 @@ HAL_DutyCycleHandle HAL_InitializeDutyCycle(int32_t channel,
|
||||
|
||||
*status = port->InitializeMode(SmartIoMode::PwmInput);
|
||||
if (*status != 0) {
|
||||
smartIoHandles->Free(handle, HAL_HandleEnum::DutyCycle);
|
||||
smartIoHandles->Free(handle, HAL_HandleEnum::DUTY_CYCLE);
|
||||
return HAL_kInvalidHandle;
|
||||
}
|
||||
|
||||
@@ -63,12 +63,12 @@ HAL_DutyCycleHandle HAL_InitializeDutyCycle(int32_t channel,
|
||||
return handle;
|
||||
}
|
||||
void HAL_FreeDutyCycle(HAL_DutyCycleHandle dutyCycleHandle) {
|
||||
auto port = smartIoHandles->Get(dutyCycleHandle, HAL_HandleEnum::DutyCycle);
|
||||
auto port = smartIoHandles->Get(dutyCycleHandle, HAL_HandleEnum::DUTY_CYCLE);
|
||||
if (port == nullptr) {
|
||||
return;
|
||||
}
|
||||
|
||||
smartIoHandles->Free(dutyCycleHandle, HAL_HandleEnum::DutyCycle);
|
||||
smartIoHandles->Free(dutyCycleHandle, HAL_HandleEnum::DUTY_CYCLE);
|
||||
|
||||
// Wait for no other object to hold this handle.
|
||||
auto start = wpi::hal::monotonic_clock::now();
|
||||
@@ -88,7 +88,7 @@ void HAL_SetDutyCycleSimDevice(HAL_EncoderHandle handle,
|
||||
|
||||
double HAL_GetDutyCycleFrequency(HAL_DutyCycleHandle dutyCycleHandle,
|
||||
int32_t* status) {
|
||||
auto port = smartIoHandles->Get(dutyCycleHandle, HAL_HandleEnum::DutyCycle);
|
||||
auto port = smartIoHandles->Get(dutyCycleHandle, HAL_HandleEnum::DUTY_CYCLE);
|
||||
if (port == nullptr) {
|
||||
*status = HAL_HANDLE_ERROR;
|
||||
return 0;
|
||||
@@ -106,7 +106,7 @@ double HAL_GetDutyCycleFrequency(HAL_DutyCycleHandle dutyCycleHandle,
|
||||
|
||||
double HAL_GetDutyCycleOutput(HAL_DutyCycleHandle dutyCycleHandle,
|
||||
int32_t* status) {
|
||||
auto port = smartIoHandles->Get(dutyCycleHandle, HAL_HandleEnum::DutyCycle);
|
||||
auto port = smartIoHandles->Get(dutyCycleHandle, HAL_HandleEnum::DUTY_CYCLE);
|
||||
if (port == nullptr) {
|
||||
*status = HAL_HANDLE_ERROR;
|
||||
return 0.0;
|
||||
@@ -131,7 +131,7 @@ double HAL_GetDutyCycleOutput(HAL_DutyCycleHandle dutyCycleHandle,
|
||||
|
||||
int32_t HAL_GetDutyCycleHighTime(HAL_DutyCycleHandle dutyCycleHandle,
|
||||
int32_t* status) {
|
||||
auto port = smartIoHandles->Get(dutyCycleHandle, HAL_HandleEnum::DutyCycle);
|
||||
auto port = smartIoHandles->Get(dutyCycleHandle, HAL_HandleEnum::DUTY_CYCLE);
|
||||
if (port == nullptr) {
|
||||
*status = HAL_HANDLE_ERROR;
|
||||
return 0;
|
||||
|
||||
@@ -43,7 +43,7 @@ class NotifierThread : public wpi::util::SafeThread {
|
||||
void ProcessAlarms();
|
||||
|
||||
UnlimitedHandleResource<HAL_NotifierHandle, Notifier,
|
||||
HAL_HandleEnum::Notifier>
|
||||
HAL_HandleEnum::NOTIFIER>
|
||||
m_handles;
|
||||
|
||||
struct Alarm {
|
||||
|
||||
@@ -72,7 +72,8 @@ HAL_PowerDistributionHandle HAL_InitializePowerDistribution(
|
||||
}
|
||||
}
|
||||
|
||||
#define IsCtre(handle) ::wpi::hal::isHandleType(handle, HAL_HandleEnum::CTREPDP)
|
||||
#define IsCtre(handle) \
|
||||
::wpi::hal::isHandleType(handle, HAL_HandleEnum::CTRE_PDP)
|
||||
|
||||
void HAL_CleanPowerDistribution(HAL_PowerDistributionHandle handle) {
|
||||
if (IsCtre(handle)) {
|
||||
|
||||
@@ -75,12 +75,12 @@ static constexpr int32_t kPDHFrameStatus3Timeout = 20;
|
||||
static constexpr int32_t kPDHFrameStatus4Timeout = 20;
|
||||
|
||||
static IndexedHandleResource<HAL_REVPDHHandle, REV_PDHObj, kNumREVPDHModules,
|
||||
HAL_HandleEnum::REVPDH>* REVPDHHandles;
|
||||
HAL_HandleEnum::REV_PDH>* REVPDHHandles;
|
||||
|
||||
namespace wpi::hal::init {
|
||||
void InitializeREVPDH() {
|
||||
static IndexedHandleResource<HAL_REVPDHHandle, REV_PDHObj, kNumREVPDHModules,
|
||||
HAL_HandleEnum::REVPDH>
|
||||
HAL_HandleEnum::REV_PDH>
|
||||
rH;
|
||||
REVPDHHandles = &rH;
|
||||
}
|
||||
|
||||
@@ -72,12 +72,12 @@ struct REV_PHObj {
|
||||
} // namespace
|
||||
|
||||
static IndexedHandleResource<HAL_REVPHHandle, REV_PHObj, 63,
|
||||
HAL_HandleEnum::REVPH>* REVPHHandles;
|
||||
HAL_HandleEnum::REV_PH>* REVPHHandles;
|
||||
|
||||
namespace wpi::hal::init {
|
||||
void InitializeREVPH() {
|
||||
static IndexedHandleResource<HAL_REVPHHandle, REV_PHObj, kNumREVPHModules,
|
||||
HAL_HandleEnum::REVPH>
|
||||
HAL_HandleEnum::REV_PH>
|
||||
rH;
|
||||
REVPHHandles = &rH;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user