Andrew Boyson / clock

Dependents:   oldheating gps motorhome heating

Revision:
28:b4aa41fdeb68
Parent:
26:0421132e6eaf
Child:
29:9332cf906aad
--- a/tick.c	Thu Jan 25 11:17:27 2018 +0000
+++ b/tick.c	Thu Jan 25 19:23:30 2018 +0000
@@ -13,13 +13,13 @@
 static int64_t     slewCount = 0;
 static bool       countIsSet = false;
 static bool           ticked = false;
-static int64_t         ticks = 0;
+static int64_t ticksThisScan = 0;
 static volatile int32_t slew = 0; //ns     - up to +/- 2.147s of slew
 static volatile int32_t ppb  = 0; //This gets set to the last recorded ppb in TickInit
 
 bool    TickIsSet() { return countIsSet; }
 bool    Ticked()    { return ticked; }
-int64_t Ticks()     { return ticks; } //30th bit is one second
+int64_t Ticks()     { return ticksThisScan; } //30th bit is one second
 
 int32_t TickGetSlew() { return slew; }
 void    TickSetSlew(int32_t value) { slew = value; }
@@ -55,7 +55,7 @@
 */
 
 void TickSet(int64_t extClock)
-{
+{    
      int64_t timerCountSinceLastSecond = TimerCountSinceLastSecond();
      int64_t fraction = (timerCountSinceLastSecond << TICK_ONE_SECOND_SHIFT) / TIMER_COUNT_PER_SECOND;
      int64_t    ticks = extClock - fraction;
@@ -65,7 +65,7 @@
         slewCount = 0;
     __enable_irq();
     
-    ticks = extClock;
+    ticksThisScan = extClock;
     
     countIsSet = true;
 }
@@ -82,11 +82,11 @@
     }
     
     //Update TickTime
-    ticks = tickCount + slewCount + TimerMultiplyFractionalPart(TICK_ONE_SECOND + ppb + slew, TimerCountSinceLastSecond());
+    ticksThisScan = tickCount + slewCount + TimerMultiplyFractionalPart(TICK_ONE_SECOND + ppb + slew, TimerCountSinceLastSecond());
     
     //Update the ticked flag
     static bool lastTick = false;
-    bool thisTick = ticks & TICK_ONE_SECOND;
+    bool thisTick = ticksThisScan & TICK_ONE_SECOND;
     ticked = thisTick != lastTick;
     lastTick = thisTick;