[wpiutil] timestamp: Add ShutdownNowRio (#5610)

This commit is contained in:
Peter Johnson
2023-09-07 09:59:39 -07:00
committed by GitHub
parent e9f612f581
commit a6157f184d
3 changed files with 35 additions and 0 deletions

View File

@@ -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();
}