mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-07-06 03:31:43 +00:00
Keep track of FPGA time rollovers with 64-bit time.
This allows both greater than 72 minute (2^32 * 1 us) timeouts and also gracefully handles notifiers across the FPGA time counter rollover. Change-Id: Ibde0b903155f60b618b0ca4d5f8f6dd49f90b020
This commit is contained in:
committed by
Brad Miller (WPI)
parent
063925e737
commit
e2ec34090a
@@ -35,7 +35,7 @@ class Notifier : public ErrorBase {
|
||||
// update the HAL alarm
|
||||
void UpdateAlarm();
|
||||
// HAL callback
|
||||
static void Notify(uint32_t currentTimeInt, void *param);
|
||||
static void Notify(uint64_t currentTimeInt, void *param);
|
||||
|
||||
// held while updating process information
|
||||
priority_mutex m_processMutex;
|
||||
|
||||
@@ -43,7 +43,7 @@ Notifier::~Notifier() {
|
||||
*/
|
||||
void Notifier::UpdateAlarm() {
|
||||
int32_t status = 0;
|
||||
updateNotifierAlarm(m_notifier, (uint32_t)(m_expirationTime * 1e6), &status);
|
||||
updateNotifierAlarm(m_notifier, (uint64_t)(m_expirationTime * 1e6), &status);
|
||||
wpi_setErrorWithContext(status, getHALErrorMessage(status));
|
||||
}
|
||||
|
||||
@@ -51,7 +51,7 @@ void Notifier::UpdateAlarm() {
|
||||
* Notify is called by the HAL layer. We simply need to pass it through to
|
||||
* the user handler.
|
||||
*/
|
||||
void Notifier::Notify(uint32_t currentTimeInt, void *param) {
|
||||
void Notifier::Notify(uint64_t currentTimeInt, void *param) {
|
||||
Notifier* notifier = static_cast<Notifier*>(param);
|
||||
|
||||
notifier->m_processMutex.lock();
|
||||
|
||||
@@ -156,9 +156,9 @@ uint32_t GetFPGARevision() {
|
||||
* @return The current time in microseconds according to the FPGA (since FPGA
|
||||
* reset).
|
||||
*/
|
||||
uint32_t GetFPGATime() {
|
||||
uint64_t GetFPGATime() {
|
||||
int32_t status = 0;
|
||||
uint32_t time = getFPGATime(&status);
|
||||
uint64_t time = getFPGATime(&status);
|
||||
wpi_setGlobalErrorWithContext(status, getHALErrorMessage(status));
|
||||
return time;
|
||||
}
|
||||
|
||||
@@ -46,6 +46,6 @@ void wpi_suspendOnAssertEnabled(bool enabled);
|
||||
|
||||
uint16_t GetFPGAVersion();
|
||||
uint32_t GetFPGARevision();
|
||||
uint32_t GetFPGATime();
|
||||
uint64_t GetFPGATime();
|
||||
bool GetUserButton();
|
||||
std::string GetStackTrace(uint32_t offset);
|
||||
|
||||
@@ -159,7 +159,7 @@ bool wpi_assertNotEqual_impl(int valueA,
|
||||
*
|
||||
* @return The current time in microseconds according to the FPGA (since FPGA reset).
|
||||
*/
|
||||
uint32_t GetFPGATime()
|
||||
uint64_t GetFPGATime()
|
||||
{
|
||||
return wpilib::internal::simTime * 1e6;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user