Unify WPI_Now and HAL_GetFPGATime. (#743)

Depends on wpilibsuite/wpiutil#56.
This commit is contained in:
Peter Johnson
2017-11-19 12:33:36 -08:00
committed by GitHub
parent 303c259b89
commit 7f46b50b21
3 changed files with 19 additions and 8 deletions

View File

@@ -20,6 +20,7 @@
#include <FRC_NetworkCommunication/LoadOut.h>
#include <llvm/raw_ostream.h>
#include <support/mutex.h>
#include <support/timestamp.h>
#include "HAL/ChipObject.h"
#include "HAL/DriverStation.h"
@@ -357,6 +358,20 @@ HAL_Bool HAL_Initialize(int32_t timeout, int32_t mode) {
HAL_InitializeDriverStation();
// Set WPI_Now to use FPGA timestamp
wpi::SetNowImpl([]() -> uint64_t {
int32_t status = 0;
uint64_t rv = HAL_GetFPGATime(&status);
if (status != 0) {
llvm::errs()
<< "Call to HAL_GetFPGATime failed."
<< "Initialization might have failed. Time will not be correct\n";
llvm::errs().flush();
return 0u;
}
return rv;
});
initialized = true;
return true;
}