Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: oldheating gps motorhome heating
Diff: tick.c
- Revision:
- 31:f6ff7fdb9c67
- Parent:
- 30:212ca42b8779
diff -r 212ca42b8779 -r f6ff7fdb9c67 tick.c
--- a/tick.c Fri Feb 16 17:30:46 2018 +0000
+++ b/tick.c Thu Nov 29 16:51:19 2018 +0000
@@ -2,7 +2,7 @@
#include <stdbool.h>
#include "rtc.h"
-#include "time.h"
+#include "tm.h"
#include "tick.h"
#include "timer.h"
#include "led.h"
@@ -20,7 +20,7 @@
bool TickIsSet() { return countIsSet; }
bool Ticked() { return ticked; }
-int64_t Ticks() { return ticksThisScan; } //30th bit is one second
+int64_t TicksNow() { return ticksThisScan; } //30th bit is one second
int32_t TickGetSlew() { return slew; }
void TickSetSlew(int32_t value) { slew = value; }
@@ -32,16 +32,16 @@
void TicksToTmUtc (int64_t ticks, struct tm* ptm)
{
time_t t = ticks >> TICK_ONE_SECOND_SHIFT;
- TimeToTmUtc(t, ptm);
+ TmUtcFromTimeT(t, ptm);
}
int64_t TicksFromTmUtc(struct tm* ptm)
{
- time_t t = TimeFromTmUtc(ptm);
+ time_t t = TmUtcToTimeT(ptm);
return t << TICK_ONE_SECOND_SHIFT;
}
-/*
+/* Timer counts like this:
+---------+---------------+
| Seconds | Base count |
+---------+---------------+
@@ -53,6 +53,9 @@
| 45 | 25,032,704 |
| ... | ... |
+---------+---------------+
+Tick counts as a signed 64 bit integer
+1 bit sign, 33 bits for seconds, 30 bits for fraction
+giving +/- 272 years with a resolution of around approximately 1ns or 1 ppb per second (2^30 == 1024x1024x1024)
*/
void TickSet(int64_t extClock)
@@ -73,7 +76,7 @@
void TickMain()
{
//Update the times whenever there has been a system second
- if (TimerTicked)
+ if (TimerHadSecond)
{
__disable_irq();
tickCount += TICK_ONE_SECOND + ppb;