mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-21 01:01:43 +00:00
Unify WPI_Now and HAL_GetFPGATime. (#743)
Depends on wpilibsuite/wpiutil#56.
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user