mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-27 02:01:42 +00:00
[wpiutil] timestamp: Add ShutdownNowRio (#5610)
This commit is contained in:
@@ -244,6 +244,7 @@ WPI_DestroySemaphore
|
||||
WPI_DestroySignalObject
|
||||
WPI_GetSystemTime
|
||||
WPI_Impl_SetupNowRio
|
||||
WPI_Impl_ShutdownNowRio
|
||||
WPI_Now
|
||||
WPI_NowDefault
|
||||
WPI_ReleaseSemaphore
|
||||
|
||||
@@ -92,6 +92,18 @@ struct HMBHolder {
|
||||
cfg.Enables_Timestamp = 1;
|
||||
hmb->writeConfig(cfg, &status);
|
||||
}
|
||||
void Reset() {
|
||||
if (hmb) {
|
||||
std::unique_ptr<fpga::tHMB> oldHmb;
|
||||
oldHmb.swap(hmb);
|
||||
closeHmb(oldHmb->getSystemInterface()->getHandle(), hmbName);
|
||||
closeHmb = nullptr;
|
||||
hmbBuffer = nullptr;
|
||||
oldHmb.reset();
|
||||
dlclose(niFpga);
|
||||
niFpga = nullptr;
|
||||
}
|
||||
}
|
||||
std::unique_ptr<fpga::tHMB> hmb;
|
||||
void* niFpga = nullptr;
|
||||
NiFpga_CloseHmbFunc closeHmb = nullptr;
|
||||
@@ -182,6 +194,12 @@ void wpi::impl::SetupNowRio() {
|
||||
#endif
|
||||
}
|
||||
|
||||
void wpi::impl::ShutdownNowRio() {
|
||||
#ifdef __FRC_ROBORIO__
|
||||
hmb.Reset();
|
||||
#endif
|
||||
}
|
||||
|
||||
void wpi::SetNowImpl(uint64_t (*func)(void)) {
|
||||
now_impl = func ? func : NowDefault;
|
||||
}
|
||||
@@ -230,6 +248,10 @@ void WPI_Impl_SetupNowRio(void) {
|
||||
return wpi::impl::SetupNowRio();
|
||||
}
|
||||
|
||||
void WPI_Impl_ShutdownNowRio(void) {
|
||||
return wpi::impl::ShutdownNowRio();
|
||||
}
|
||||
|
||||
uint64_t WPI_NowDefault(void) {
|
||||
return wpi::NowDefault();
|
||||
}
|
||||
|
||||
@@ -18,6 +18,12 @@ extern "C" {
|
||||
*/
|
||||
void WPI_Impl_SetupNowRio(void);
|
||||
|
||||
/**
|
||||
* De-initialize the on-Rio Now() implementation. No effect on non-Rio
|
||||
* platforms.
|
||||
*/
|
||||
void WPI_Impl_ShutdownNowRio(void);
|
||||
|
||||
/**
|
||||
* The default implementation used for Now().
|
||||
* In general this is the time returned by the operating system.
|
||||
@@ -62,6 +68,12 @@ namespace impl {
|
||||
* thus should generally not be called by user code.
|
||||
*/
|
||||
void SetupNowRio();
|
||||
|
||||
/**
|
||||
* De-initialize the on-Rio Now() implementation. No effect on non-Rio
|
||||
* platforms.
|
||||
*/
|
||||
void ShutdownNowRio();
|
||||
} // namespace impl
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user