mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-22 01:11:42 +00:00
Convert ReadInterrupt* to return int64_t time (#1417)
HAL_ReadInterruptRisingTimestamp and HAL_ReadInterruptFallingTimestamp return time as a double. Instead, keep the raw integer count and move the double conversion into the C++ and Java code. This enables comparison of the time with other timers.
This commit is contained in:
committed by
Peter Johnson
parent
ef3a31aa20
commit
9207d788ab
@@ -42,8 +42,8 @@ struct Interrupt {
|
||||
uint8_t index;
|
||||
HAL_AnalogTriggerType trigType;
|
||||
bool watcher;
|
||||
double risingTimestamp;
|
||||
double fallingTimestamp;
|
||||
int64_t risingTimestamp;
|
||||
int64_t fallingTimestamp;
|
||||
bool previousState;
|
||||
bool fireOnUp;
|
||||
bool fireOnDown;
|
||||
@@ -238,10 +238,10 @@ static int64_t WaitForInterruptDigital(HAL_InterruptHandle handle,
|
||||
// True => false, Falling
|
||||
if (interrupt->previousState) {
|
||||
// Set our return value and our timestamps
|
||||
interrupt->fallingTimestamp = hal::GetFPGATimestamp();
|
||||
interrupt->fallingTimestamp = hal::GetFPGATime();
|
||||
return 1 << (8 + interrupt->index);
|
||||
} else {
|
||||
interrupt->risingTimestamp = hal::GetFPGATimestamp();
|
||||
interrupt->risingTimestamp = hal::GetFPGATime();
|
||||
return 1 << (interrupt->index);
|
||||
}
|
||||
}
|
||||
@@ -302,10 +302,10 @@ static int64_t WaitForInterruptAnalog(HAL_InterruptHandle handle,
|
||||
// True => false, Falling
|
||||
if (interrupt->previousState) {
|
||||
// Set our return value and our timestamps
|
||||
interrupt->fallingTimestamp = hal::GetFPGATimestamp();
|
||||
interrupt->fallingTimestamp = hal::GetFPGATime();
|
||||
return 1 << (8 + interrupt->index);
|
||||
} else {
|
||||
interrupt->risingTimestamp = hal::GetFPGATimestamp();
|
||||
interrupt->risingTimestamp = hal::GetFPGATime();
|
||||
return 1 << (interrupt->index);
|
||||
}
|
||||
}
|
||||
@@ -350,12 +350,12 @@ static void ProcessInterruptDigitalAsynchronous(const char* name, void* param,
|
||||
int32_t mask = 0;
|
||||
if (interrupt->previousState) {
|
||||
interrupt->previousState = retVal;
|
||||
interrupt->fallingTimestamp = hal::GetFPGATimestamp();
|
||||
interrupt->fallingTimestamp = hal::GetFPGATime();
|
||||
mask = 1 << (8 + interrupt->index);
|
||||
if (!interrupt->fireOnDown) return;
|
||||
} else {
|
||||
interrupt->previousState = retVal;
|
||||
interrupt->risingTimestamp = hal::GetFPGATimestamp();
|
||||
interrupt->risingTimestamp = hal::GetFPGATime();
|
||||
mask = 1 << (interrupt->index);
|
||||
if (!interrupt->fireOnUp) return;
|
||||
}
|
||||
@@ -385,12 +385,12 @@ static void ProcessInterruptAnalogAsynchronous(const char* name, void* param,
|
||||
int mask = 0;
|
||||
if (interrupt->previousState) {
|
||||
interrupt->previousState = retVal;
|
||||
interrupt->fallingTimestamp = hal::GetFPGATimestamp();
|
||||
interrupt->fallingTimestamp = hal::GetFPGATime();
|
||||
if (!interrupt->fireOnDown) return;
|
||||
mask = 1 << (8 + interrupt->index);
|
||||
} else {
|
||||
interrupt->previousState = retVal;
|
||||
interrupt->risingTimestamp = hal::GetFPGATimestamp();
|
||||
interrupt->risingTimestamp = hal::GetFPGATime();
|
||||
if (!interrupt->fireOnUp) return;
|
||||
mask = 1 << (interrupt->index);
|
||||
}
|
||||
@@ -486,8 +486,8 @@ void HAL_DisableInterrupts(HAL_InterruptHandle interruptHandle,
|
||||
}
|
||||
interrupt->callbackId = -1;
|
||||
}
|
||||
double HAL_ReadInterruptRisingTimestamp(HAL_InterruptHandle interruptHandle,
|
||||
int32_t* status) {
|
||||
int64_t HAL_ReadInterruptRisingTimestamp(HAL_InterruptHandle interruptHandle,
|
||||
int32_t* status) {
|
||||
auto interrupt = interruptHandles->Get(interruptHandle);
|
||||
if (interrupt == nullptr) {
|
||||
*status = HAL_HANDLE_ERROR;
|
||||
@@ -496,8 +496,8 @@ double HAL_ReadInterruptRisingTimestamp(HAL_InterruptHandle interruptHandle,
|
||||
|
||||
return interrupt->risingTimestamp;
|
||||
}
|
||||
double HAL_ReadInterruptFallingTimestamp(HAL_InterruptHandle interruptHandle,
|
||||
int32_t* status) {
|
||||
int64_t HAL_ReadInterruptFallingTimestamp(HAL_InterruptHandle interruptHandle,
|
||||
int32_t* status) {
|
||||
auto interrupt = interruptHandles->Get(interruptHandle);
|
||||
if (interrupt == nullptr) {
|
||||
*status = HAL_HANDLE_ERROR;
|
||||
|
||||
Reference in New Issue
Block a user