Fixes WaitForInterrupt to return values matching enum (#503)

This commit is contained in:
Thad House
2017-05-07 09:07:14 -07:00
committed by Peter Johnson
parent f0c413f40d
commit d348a5b947
2 changed files with 15 additions and 1 deletions

View File

@@ -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);
}
/**