Commit 5a4de885 authored by Vincent van Beveren's avatar Vincent van Beveren

Fixed overflow issue in pps_gen_utc

parent e3af54f4
Pipeline #4854 failed with stages
......@@ -85,11 +85,19 @@ void shw_pps_gen_set_time(uint64_t seconds, uint32_t nanoseconds, int counter)
static uint64_t pps_get_utc(void)
{
uint64_t out;
uint32_t low, high;
uint32_t low, low2, high;
low = ppsg_read(CNTR_UTCLO);
high = ppsg_read(CNTR_UTCHI);
// check for wrap, if so, re-read registers
low2 = ppsg_read(CNTR_UTCLO);
if (low2 < low)
{
high = ppsg_read(CNTR_UTCHI);
low = low2;
}
high &= 0xFF; /* CNTR_UTCHI has only 8 bits defined -- rest are HDL don't care */
out = (uint64_t) low | (uint64_t) high << 32;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment