[wpiutil] timestamp: Call FPGA functions directly (#5235)

This works around an exit race with wpi::Now() on Rio; it was overridden
to call HAL_GetFPGATime(), which calls chipobject, but on exit, because
there was not a library dependency, the chipobject could be destroyed
prior to wpiutil/wpinet being shut down.
This commit is contained in:
Peter Johnson
2023-07-24 23:03:28 -07:00
committed by GitHub
parent 2ba8fbb6f4
commit a95994fff6
11 changed files with 166 additions and 20 deletions

View File

@@ -11,6 +11,13 @@
extern "C" {
#endif
/**
* Initialize the on-Rio Now() implementation to use the FPGA timestamp.
* No effect on non-Rio platforms. This is called by HAL_Initialize() and
* thus should generally not be called by user code.
*/
void WPI_Impl_SetupNowRio(void);
/**
* The default implementation used for Now().
* In general this is the time returned by the operating system.
@@ -48,12 +55,21 @@ uint64_t WPI_GetSystemTime(void);
#ifdef __cplusplus
namespace wpi {
namespace impl {
/**
* Initialize the on-Rio Now() implementation to use the FPGA timestamp.
* No effect on non-Rio platforms. This is called by HAL_Initialize() and
* thus should generally not be called by user code.
*/
void SetupNowRio();
} // namespace impl
/**
* The default implementation used for Now().
* In general this is the time returned by the operating system.
* @return Time in microseconds.
*/
uint64_t NowDefault(void);
uint64_t NowDefault();
/**
* Set the implementation used by Now().
@@ -68,7 +84,7 @@ void SetNowImpl(uint64_t (*func)());
* This is a monotonic clock with an undefined epoch.
* @return Time in microseconds.
*/
uint64_t Now(void);
uint64_t Now();
/**
* Return the current system time in microseconds since the Unix epoch