diff --git a/hal/include/HAL/Counter.h b/hal/include/HAL/Counter.h index 7566d4874b..720886f863 100644 --- a/hal/include/HAL/Counter.h +++ b/hal/include/HAL/Counter.h @@ -54,7 +54,7 @@ void HAL_SetCounterPulseLengthMode(HAL_CounterHandle counterHandle, int32_t HAL_GetCounterSamplesToAverage(HAL_CounterHandle counterHandle, int32_t* status); void HAL_SetCounterSamplesToAverage(HAL_CounterHandle counterHandle, - int samplesToAverage, int32_t* status); + int32_t samplesToAverage, int32_t* status); void HAL_ResetCounter(HAL_CounterHandle counterHandle, int32_t* status); int32_t HAL_GetCounter(HAL_CounterHandle counterHandle, int32_t* status); double HAL_GetCounterPeriod(HAL_CounterHandle counterHandle, int32_t* status); diff --git a/hal/include/HAL/DriverStation.h b/hal/include/HAL/DriverStation.h index 4a4d6073e0..8505ddbaf7 100644 --- a/hal/include/HAL/DriverStation.h +++ b/hal/include/HAL/DriverStation.h @@ -54,12 +54,12 @@ enum HAL_AllianceStationID { #define HAL_kMaxJoystickPOVs 12 struct HAL_JoystickAxes { - uint16_t count; + int16_t count; float axes[HAL_kMaxJoystickAxes]; }; struct HAL_JoystickPOVs { - uint16_t count; + int16_t count; int16_t povs[HAL_kMaxJoystickPOVs]; }; diff --git a/hal/include/HAL/Task.h b/hal/include/HAL/Task.h index d54bc876da..dce8dcba47 100644 --- a/hal/include/HAL/Task.h +++ b/hal/include/HAL/Task.h @@ -12,7 +12,7 @@ #ifndef _STATUS_DEFINED #define _STATUS_DEFINED -typedef int STATUS; +typedef int32_t STATUS; #endif /* _STATUS_DEFINED */ #ifndef OK @@ -33,8 +33,11 @@ extern "C" { const int32_t HAL_TaskLib_ILLEGAL_PRIORITY = 22; // 22 is EINVAL STATUS HAL_VerifyTaskID(TASK task); -STATUS HAL_SetTaskPriority(TASK task, int priority); // valid priority [1..99] -STATUS HAL_GetTaskPriority(TASK task, int* priority); + +// valid priority [1..99] +STATUS HAL_SetTaskPriority(TASK task, int32_t priority); + +STATUS HAL_GetTaskPriority(TASK task, int32_t* priority); #ifdef __cplusplus } #endif diff --git a/hal/include/HAL/cpp/Semaphore.h b/hal/include/HAL/cpp/Semaphore.h index 82af7cc5d6..140749467e 100644 --- a/hal/include/HAL/cpp/Semaphore.h +++ b/hal/include/HAL/cpp/Semaphore.h @@ -15,7 +15,7 @@ class Semaphore { public: - explicit Semaphore(uint32_t count = 0); + explicit Semaphore(int32_t count = 0); Semaphore(Semaphore&&); Semaphore& operator=(Semaphore&&); @@ -28,11 +28,11 @@ class Semaphore { static const int32_t kNoWait = 0; static const int32_t kWaitForever = -1; - static const uint32_t kEmpty = 0; - static const uint32_t kFull = 1; + static const int32_t kEmpty = 0; + static const int32_t kFull = 1; private: priority_mutex m_mutex; std::condition_variable_any m_condition; - uint32_t m_count = 0; + int32_t m_count = 0; }; diff --git a/hal/lib/athena/Accelerometer.cpp b/hal/lib/athena/Accelerometer.cpp index a9f012a136..6cc71ac2cd 100644 --- a/hal/lib/athena/Accelerometer.cpp +++ b/hal/lib/athena/Accelerometer.cpp @@ -216,7 +216,7 @@ void HAL_SetAccelerometerRange(HAL_AccelerometerRange range) { double HAL_GetAccelerometerX() { initializeAccelerometer(); - int raw = + int32_t raw = (readRegister(kReg_OutXMSB) << 4) | (readRegister(kReg_OutXLSB) >> 4); return unpackAxis(raw); } @@ -229,7 +229,7 @@ double HAL_GetAccelerometerX() { double HAL_GetAccelerometerY() { initializeAccelerometer(); - int raw = + int32_t raw = (readRegister(kReg_OutYMSB) << 4) | (readRegister(kReg_OutYLSB) >> 4); return unpackAxis(raw); } @@ -242,7 +242,7 @@ double HAL_GetAccelerometerY() { double HAL_GetAccelerometerZ() { initializeAccelerometer(); - int raw = + int32_t raw = (readRegister(kReg_OutZMSB) << 4) | (readRegister(kReg_OutZLSB) >> 4); return unpackAxis(raw); } diff --git a/hal/lib/athena/AnalogAccumulator.cpp b/hal/lib/athena/AnalogAccumulator.cpp index 58f55ca7e4..3a5cf9fa58 100644 --- a/hal/lib/athena/AnalogAccumulator.cpp +++ b/hal/lib/athena/AnalogAccumulator.cpp @@ -26,7 +26,7 @@ HAL_Bool HAL_IsAccumulatorChannel(HAL_AnalogInputHandle analogPortHandle, *status = HAL_HANDLE_ERROR; return false; } - for (uint32_t i = 0; i < kNumAccumulators; i++) { + for (int32_t i = 0; i < kNumAccumulators; i++) { if (port->channel == kAccumulatorChannels[i]) return true; } return false; diff --git a/hal/lib/athena/AnalogInput.cpp b/hal/lib/athena/AnalogInput.cpp index 3ce156b389..8717e2afbc 100644 --- a/hal/lib/athena/AnalogInput.cpp +++ b/hal/lib/athena/AnalogInput.cpp @@ -375,7 +375,7 @@ int32_t HAL_GetAnalogLSBWeight(HAL_AnalogInputHandle analogPortHandle, *status = HAL_HANDLE_ERROR; return 0; } - uint32_t lsbWeight = FRC_NetworkCommunication_nAICalibration_getLSBWeight( + int32_t lsbWeight = FRC_NetworkCommunication_nAICalibration_getLSBWeight( 0, port->channel, status); // XXX: aiSystemIndex == 0? return lsbWeight; } diff --git a/hal/lib/athena/AnalogInternal.cpp b/hal/lib/athena/AnalogInternal.cpp index b4730a9f76..f734f26549 100644 --- a/hal/lib/athena/AnalogInternal.cpp +++ b/hal/lib/athena/AnalogInternal.cpp @@ -21,7 +21,7 @@ IndexedHandleResource analogInputHandles; -static uint32_t analogNumChannelsToActivate = 0; +static int32_t analogNumChannelsToActivate = 0; bool analogSystemInitialized = false; @@ -43,8 +43,8 @@ void initializeAnalog(int32_t* status) { * * @return Active channels. */ -uint32_t getAnalogNumActiveChannels(int32_t* status) { - uint32_t scanSize = analogInputSystem->readConfig_ScanSize(status); +int32_t getAnalogNumActiveChannels(int32_t* status) { + int32_t scanSize = analogInputSystem->readConfig_ScanSize(status); if (scanSize == 0) return 8; return scanSize; } @@ -60,7 +60,7 @@ uint32_t getAnalogNumActiveChannels(int32_t* status) { * * @return Value to write to the active channels field. */ -uint32_t getAnalogNumChannelsToActivate(int32_t* status) { +int32_t getAnalogNumChannelsToActivate(int32_t* status) { if (analogNumChannelsToActivate == 0) return getAnalogNumActiveChannels(status); return analogNumChannelsToActivate; @@ -75,7 +75,7 @@ uint32_t getAnalogNumChannelsToActivate(int32_t* status) { * * @param channels Number of active channels. */ -void setAnalogNumChannelsToActivate(uint32_t channels) { +void setAnalogNumChannelsToActivate(int32_t channels) { analogNumChannelsToActivate = channels; } } // namespace hal diff --git a/hal/lib/athena/AnalogInternal.h b/hal/lib/athena/AnalogInternal.h index 1ffe3f82df..faad09c3d0 100644 --- a/hal/lib/athena/AnalogInternal.h +++ b/hal/lib/athena/AnalogInternal.h @@ -37,9 +37,9 @@ extern IndexedHandleResource analogInputHandles; -uint32_t getAnalogNumActiveChannels(int32_t* status); -uint32_t getAnalogNumChannelsToActivate(int32_t* status); -void setAnalogNumChannelsToActivate(uint32_t channels); +int32_t getAnalogNumActiveChannels(int32_t* status); +int32_t getAnalogNumChannelsToActivate(int32_t* status); +void setAnalogNumChannelsToActivate(int32_t channels); void initializeAnalog(int32_t* status); extern bool analogSystemInitialized; diff --git a/hal/lib/athena/DIO.cpp b/hal/lib/athena/DIO.cpp index 6d665a1bb3..3132fa85f0 100644 --- a/hal/lib/athena/DIO.cpp +++ b/hal/lib/athena/DIO.cpp @@ -383,7 +383,7 @@ HAL_Bool HAL_IsAnyPulsing(int32_t* status) { * @param filterIndex The filter index. Must be in the range 0 - 3, where 0 * means "none" and 1 - 3 means filter # filterIndex - 1. */ -void HAL_SetFilterSelect(HAL_DigitalHandle dioPortHandle, int filterIndex, +void HAL_SetFilterSelect(HAL_DigitalHandle dioPortHandle, int32_t filterIndex, int32_t* status) { auto port = digitalChannelHandles.Get(dioPortHandle, HAL_HandleEnum::DIO); if (port == nullptr) { @@ -408,7 +408,7 @@ void HAL_SetFilterSelect(HAL_DigitalHandle dioPortHandle, int filterIndex, * @return filterIndex The filter index. Must be in the range 0 - 3, * where 0 means "none" and 1 - 3 means filter # filterIndex - 1. */ -int HAL_GetFilterSelect(HAL_DigitalHandle dioPortHandle, int32_t* status) { +int32_t HAL_GetFilterSelect(HAL_DigitalHandle dioPortHandle, int32_t* status) { auto port = digitalChannelHandles.Get(dioPortHandle, HAL_HandleEnum::DIO); if (port == nullptr) { *status = HAL_HANDLE_ERROR; diff --git a/hal/lib/athena/DigitalInternal.h b/hal/lib/athena/DigitalInternal.h index 00d4ba7013..2adecdf833 100644 --- a/hal/lib/athena/DigitalInternal.h +++ b/hal/lib/athena/DigitalInternal.h @@ -23,9 +23,9 @@ namespace hal { /** * MXP channels when used as digital output PWM are offset from actual value */ -constexpr uint32_t kMXPDigitalPWMOffset = 6; +constexpr int32_t kMXPDigitalPWMOffset = 6; -constexpr uint32_t kExpectedLoopTiming = 40; +constexpr int32_t kExpectedLoopTiming = 40; /** * kDefaultPwmPeriod is in ms diff --git a/hal/lib/athena/Encoder.cpp b/hal/lib/athena/Encoder.cpp index 62c25c9655..b611048032 100644 --- a/hal/lib/athena/Encoder.cpp +++ b/hal/lib/athena/Encoder.cpp @@ -172,7 +172,7 @@ void Encoder::SetReverseDirection(bool reverseDirection, int32_t* status) { } } -void Encoder::SetSamplesToAverage(int samplesToAverage, int32_t* status) { +void Encoder::SetSamplesToAverage(int32_t samplesToAverage, int32_t* status) { if (samplesToAverage < 1 || samplesToAverage > 127) { *status = PARAMETER_OUT_OF_RANGE; return; diff --git a/hal/lib/athena/EncoderInternal.h b/hal/lib/athena/EncoderInternal.h index 87488981d6..ede7577b81 100644 --- a/hal/lib/athena/EncoderInternal.h +++ b/hal/lib/athena/EncoderInternal.h @@ -36,7 +36,7 @@ class Encoder { void SetMinRate(double minRate, int32_t* status); void SetDistancePerPulse(double distancePerPulse, int32_t* status); void SetReverseDirection(bool reverseDirection, int32_t* status); - void SetSamplesToAverage(int samplesToAverage, int32_t* status); + void SetSamplesToAverage(int32_t samplesToAverage, int32_t* status); int32_t GetSamplesToAverage(int32_t* status) const; void SetIndexSource(HAL_Handle digitalSourceHandle, diff --git a/hal/lib/athena/FRCDriverStation.cpp b/hal/lib/athena/FRCDriverStation.cpp index 6f63e4e4c8..2c86fd7807 100644 --- a/hal/lib/athena/FRCDriverStation.cpp +++ b/hal/lib/athena/FRCDriverStation.cpp @@ -14,8 +14,11 @@ #include "HAL/cpp/priority_condition_variable.h" #include "HAL/cpp/priority_mutex.h" +static_assert(sizeof(int32_t) >= sizeof(int), + "FRC_NetworkComm status variable is larger than 32 bits"); + struct HAL_JoystickAxesInt { - uint16_t count; + int16_t count; int16_t axes[HAL_kMaxJoystickAxes]; }; @@ -95,11 +98,11 @@ int32_t HAL_GetJoystickAxes(int32_t joystickNum, HAL_JoystickAxes* axes) { joystickNum, reinterpret_cast(&axesInt), HAL_kMaxJoystickAxes); - // copy int values to float values + // copy integer values to float values axes->count = axesInt.count; // current scaling is -128 to 127, can easily be patched in the future by // changing this function. - for (unsigned int i = 0; i < axesInt.count; i++) { + for (int32_t i = 0; i < axesInt.count; i++) { int8_t value = axesInt.axes[i]; if (value < 0) { axes->axes[i] = value / 128.0f; diff --git a/hal/lib/athena/Notifier.cpp b/hal/lib/athena/Notifier.cpp index cf300e08a1..8a74b87495 100644 --- a/hal/lib/athena/Notifier.cpp +++ b/hal/lib/athena/Notifier.cpp @@ -20,7 +20,7 @@ #include "HAL/cpp/priority_mutex.h" #include "HAL/handles/UnlimitedHandleResource.h" -static const uint32_t kTimerInterruptNumber = 28; +static const int32_t kTimerInterruptNumber = 28; static priority_mutex notifierInterruptMutex; static priority_recursive_mutex notifierMutex; diff --git a/hal/lib/athena/SPI.cpp b/hal/lib/athena/SPI.cpp index d4fc5ccbf8..6dd4d43927 100644 --- a/hal/lib/athena/SPI.cpp +++ b/hal/lib/athena/SPI.cpp @@ -342,12 +342,12 @@ static void spiAccumulatorProcess(uint64_t currentTime, // convert from bytes uint32_t resp = 0; if (accum->bigEndian) { - for (int i = 0; i < accum->xferSize; ++i) { + for (int32_t i = 0; i < accum->xferSize; ++i) { resp <<= 8; resp |= resp_b[i] & 0xff; } } else { - for (int i = accum->xferSize - 1; i >= 0; --i) { + for (int32_t i = accum->xferSize - 1; i >= 0; --i) { resp <<= 8; resp |= resp_b[i] & 0xff; } @@ -408,7 +408,7 @@ void HAL_InitSPIAccumulator(int32_t port, int32_t period, int32_t cmd, spiAccumulators[port] = std::make_unique(); SPIAccumulator* accum = spiAccumulators[port].get(); if (bigEndian) { - for (int i = xferSize - 1; i >= 0; --i) { + for (int32_t i = xferSize - 1; i >= 0; --i) { accum->cmd[i] = cmd & 0xff; cmd >>= 8; } diff --git a/hal/lib/athena/SerialPort.cpp b/hal/lib/athena/SerialPort.cpp index 07ed3f18a2..21c1b19d0f 100644 --- a/hal/lib/athena/SerialPort.cpp +++ b/hal/lib/athena/SerialPort.cpp @@ -9,8 +9,8 @@ #include "visa/visa.h" -static uint32_t m_resourceManagerHandle; -static uint32_t m_portHandle[2]; +static int32_t m_resourceManagerHandle; +static int32_t m_portHandle[2]; extern "C" { diff --git a/hal/lib/athena/Solenoid.cpp b/hal/lib/athena/Solenoid.cpp index e0be4f06f7..756f3f7906 100644 --- a/hal/lib/athena/Solenoid.cpp +++ b/hal/lib/athena/Solenoid.cpp @@ -118,7 +118,7 @@ void HAL_SetSolenoid(HAL_SolenoidHandle solenoidPortHandle, HAL_Bool value, int32_t HAL_GetPCMSolenoidBlackList(int32_t module, int32_t* status) { if (!checkPCMInit(module, status)) return 0; - UINT8 value; + uint8_t value; *status = PCM_modules[module]->GetSolenoidBlackList(value); diff --git a/hal/lib/athena/Task.cpp b/hal/lib/athena/Task.cpp index 9cd17aa758..c91d6cada2 100644 --- a/hal/lib/athena/Task.cpp +++ b/hal/lib/athena/Task.cpp @@ -26,8 +26,8 @@ STATUS HAL_VerifyTaskID(TASK task) { } } -STATUS HAL_SetTaskPriority(TASK task, int priority) { - int policy = 0; +STATUS HAL_SetTaskPriority(TASK task, int32_t priority) { + int32_t policy = 0; struct sched_param param; if (HAL_VerifyTaskID(task) == OK && @@ -43,8 +43,8 @@ STATUS HAL_SetTaskPriority(TASK task, int priority) { } } -STATUS HAL_GetTaskPriority(TASK task, int* priority) { - int policy = 0; +STATUS HAL_GetTaskPriority(TASK task, int32_t* priority) { + int32_t policy = 0; struct sched_param param; if (HAL_VerifyTaskID(task) == OK && diff --git a/hal/lib/athena/cpp/Semaphore.cpp b/hal/lib/athena/cpp/Semaphore.cpp index 64f3ed1c97..0b017b8647 100644 --- a/hal/lib/athena/cpp/Semaphore.cpp +++ b/hal/lib/athena/cpp/Semaphore.cpp @@ -7,7 +7,7 @@ #include "HAL/cpp/Semaphore.h" -Semaphore::Semaphore(uint32_t count) { m_count = count; } +Semaphore::Semaphore(int32_t count) { m_count = count; } void Semaphore::give() { std::lock_guard lock(m_mutex);