mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-07-03 03:01:44 +00:00
Fixes WaitForInterrupt to return values matching enum (#503)
This commit is contained in:
committed by
Peter Johnson
parent
f0c413f40d
commit
d348a5b947
@@ -108,7 +108,13 @@ InterruptableSensorBase::WaitResult InterruptableSensorBase::WaitForInterrupt(
|
||||
result = HAL_WaitForInterrupt(m_interrupt, timeout, ignorePrevious, &status);
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
|
||||
return static_cast<WaitResult>(result);
|
||||
// Rising edge result is the interrupt bit set in the byte 0xFF
|
||||
// Falling edge result is the interrupt bit set in the byte 0xFF00
|
||||
// Set any bit set to be true for that edge, and AND the 2 results
|
||||
// together to match the existing enum for all interrupts
|
||||
int32_t rising = (result & 0xFF) ? 0x1 : 0x0;
|
||||
int32_t falling = ((result & 0xFF00) ? 0x0100 : 0x0);
|
||||
return static_cast<WaitResult>(falling | rising);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user