Update DMA code to match NI-Libaries change
An update in NI-Libraries made the timestamp out of DMA to be 64 bits,
this issue was reported here:
https://github.com/wpilibsuite/allwpilib/issues/6276,
and a fix was made on the wpilib side here:
https://github.com/wpilibsuite/allwpilib/pull/6278,
Which we copied the fix over from.
Signed-off-by: Maxwell Henderson <mxwhenderson@gmail.com>
Change-Id: I0900c9a975549ac3e8872427dfd0cc8151dff188
diff --git a/frc971/wpilib/dma.cc b/frc971/wpilib/dma.cc
index cff1ac1..2d40aa9 100644
--- a/frc971/wpilib/dma.cc
+++ b/frc971/wpilib/dma.cc
@@ -290,7 +290,7 @@
SET_SIZE(Enable_EncoderTimers_Low);
SET_SIZE(Enable_EncoderTimers_High);
#undef SET_SIZE
- capture_size_ = accum_size + 1;
+ capture_size_ = accum_size + 2;
}
manager_.reset(
@@ -327,13 +327,14 @@
}
void DMASample::CalculateTimestamp() {
- uint32_t lower_sample = read_buffer_[dma_->capture_size_ - 1];
+ uint64_t upper_sample = read_buffer_[dma_->capture_size_ - 1];
+ uint64_t lower_sample = read_buffer_[dma_->capture_size_ - 2];
#if WPILIB2018
int32_t status = 0;
fpga_timestamp_ = HAL_ExpandFPGATime(lower_sample, &status);
assert(status == 0);
#else
- fpga_timestamp_ = lower_sample;
+ fpga_timestamp_ = (upper_sample << 32) + lower_sample;
#endif
}