mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-21 01:01:43 +00:00
Uses new FPGA calls to get 64 bit FPGA time and 64 bit PWM cycle start time. (#687)
This commit is contained in:
committed by
Peter Johnson
parent
4ab095e9c9
commit
f34332643a
@@ -450,4 +450,24 @@ int32_t HAL_GetLoopTiming(int32_t* status) {
|
||||
return pwmSystem->readLoopTiming(status);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the pwm starting cycle time
|
||||
*
|
||||
* @return The pwm cycle start time.
|
||||
*/
|
||||
uint64_t HAL_GetCycleStartTime(int32_t* status) {
|
||||
initializeDigital(status);
|
||||
if (*status != 0) return 0;
|
||||
uint64_t upper1 = pwmSystem->readCycleStartTimeUpper(status);
|
||||
uint32_t lower = pwmSystem->readCycleStartTime(status);
|
||||
uint64_t upper2 = pwmSystem->readCycleStartTimeUpper(status);
|
||||
if (*status != 0) return 0;
|
||||
if (upper1 != upper2) {
|
||||
// Rolled over between the lower call, reread lower
|
||||
lower = pwmSystem->readCycleStartTime(status);
|
||||
if (*status != 0) return 0;
|
||||
}
|
||||
return (upper2 << 32) + lower;
|
||||
}
|
||||
|
||||
} // extern "C"
|
||||
|
||||
Reference in New Issue
Block a user