diff --git a/hal/src/main/native/athena/Counter.cpp b/hal/src/main/native/athena/Counter.cpp index 7f84df88ff..b0c96a26ff 100644 --- a/hal/src/main/native/athena/Counter.cpp +++ b/hal/src/main/native/athena/Counter.cpp @@ -4,6 +4,8 @@ #include "hal/Counter.h" +#include + #include #include "ConstantsInternal.h" @@ -300,19 +302,14 @@ double HAL_GetCounterPeriod(HAL_CounterHandle counterHandle, int32_t* status) { return 0.0; } tCounter::tTimerOutput output = counter->counter->readTimerOutput(status); - double period; if (output.Stalled) { - // Return infinity - double zero = 0.0; - period = 1.0 / zero; - } else { - // output.Period is a fixed point number that counts by 2 (24 bits, 25 - // integer bits) - period = static_cast(output.Period << 1) / - static_cast(output.Count); + return std::numeric_limits::infinity(); } - return static_cast(period * - 2.5e-8); // result * timebase (currently 25ns) + // output.Period is a fixed point number that counts by 2 (24 bits, 25 + // integer bits) + double period = static_cast(output.Period << 1) / + static_cast(output.Count); + return period * 2.5e-8; // result * timebase (currently 25ns) } void HAL_SetCounterMaxPeriod(HAL_CounterHandle counterHandle, double maxPeriod, diff --git a/hal/src/main/native/athena/FPGAEncoder.cpp b/hal/src/main/native/athena/FPGAEncoder.cpp index 9965d43cb0..c73667454b 100644 --- a/hal/src/main/native/athena/FPGAEncoder.cpp +++ b/hal/src/main/native/athena/FPGAEncoder.cpp @@ -4,6 +4,7 @@ #include "FPGAEncoder.h" +#include #include #include @@ -128,18 +129,14 @@ double HAL_GetFPGAEncoderPeriod(HAL_FPGAEncoderHandle fpgaEncoderHandle, return 0.0; } tEncoder::tTimerOutput output = encoder->encoder->readTimerOutput(status); - double value; if (output.Stalled) { - // Return infinity - double zero = 0.0; - value = 1.0 / zero; - } else { - // output.Period is a fixed point number that counts by 2 (24 bits, 25 - // integer bits) - value = static_cast(output.Period << 1) / - static_cast(output.Count); + return std::numeric_limits::infinity(); } - double measuredPeriod = value * 2.5e-8; + // output.Period is a fixed point number that counts by 2 (24 bits, 25 + // integer bits) + double value = static_cast(output.Period << 1) / + static_cast(output.Count); + double measuredPeriod = value * 2.5e-8; // result * timebase (currently 25ns) return measuredPeriod / DECODING_SCALING_FACTOR; }