mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-23 01:21:42 +00:00
Add DMA support to HAL and WPILibC (#2080)
This commit is contained in:
committed by
Peter Johnson
parent
8280b7e3af
commit
82b2170feb
@@ -56,6 +56,7 @@ void InitializeHAL() {
|
||||
InitializeCounter();
|
||||
InitializeDigitalInternal();
|
||||
InitializeDIO();
|
||||
InitializeDMA();
|
||||
InitializeDutyCycle();
|
||||
InitializeEncoder();
|
||||
InitializeFPGAEncoder();
|
||||
@@ -256,6 +257,28 @@ uint64_t HAL_GetFPGATime(int32_t* status) {
|
||||
return (upper2 << 32) + lower;
|
||||
}
|
||||
|
||||
uint64_t HAL_ExpandFPGATime(uint32_t unexpanded_lower, int32_t* status) {
|
||||
// Capture the current FPGA time. This will give us the upper half of the
|
||||
// clock.
|
||||
uint64_t fpga_time = HAL_GetFPGATime(status);
|
||||
if (*status != 0) return 0;
|
||||
|
||||
// Now, we need to detect the case where the lower bits rolled over after we
|
||||
// sampled. In that case, the upper bits will be 1 bigger than they should
|
||||
// be.
|
||||
|
||||
// Break it into lower and upper portions.
|
||||
uint32_t lower = fpga_time & 0xffffffffull;
|
||||
uint64_t upper = (fpga_time >> 32) & 0xffffffff;
|
||||
|
||||
// The time was sampled *before* the current time, so roll it back.
|
||||
if (lower < unexpanded_lower) {
|
||||
--upper;
|
||||
}
|
||||
|
||||
return (upper << 32) + static_cast<uint64_t>(unexpanded_lower);
|
||||
}
|
||||
|
||||
HAL_Bool HAL_GetFPGAButton(int32_t* status) {
|
||||
if (!global) {
|
||||
*status = NiFpga_Status_ResourceNotInitialized;
|
||||
|
||||
Reference in New Issue
Block a user