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: clk/clkutc.c
- Revision:
- 57:4daf2e423b27
- Parent:
- 55:e18983651004
- Child:
- 58:ad2bfd0345de
diff -r 3e4fe2d3db4e -r 4daf2e423b27 clk/clkutc.c
--- a/clk/clkutc.c Thu Feb 21 15:45:43 2019 +0000
+++ b/clk/clkutc.c Thu Feb 21 21:08:03 2019 +0000
@@ -23,12 +23,12 @@
//Leap seconds
static int epochOffset = 0; //12 bits holds enough leap seconds for at least 300 years.
-static int64_t epochOffset64 = 0;
+static clktime epochOffset64 = 0;
int ClkUtcGetEpochOffset() { return epochOffset; }
void ClkUtcSetEpochOffset(int value)
{
epochOffset = value;
- epochOffset64 = (int64_t)epochOffset << CLK_TIME_ONE_SECOND_SHIFT;
+ epochOffset64 = (clktime)epochOffset << CLK_TIME_ONE_SECOND_SHIFT;
GPREG1 = GPREG1 & 0xFFFF0000 | value & 0x0000FFFF;
}
void ClkUtcAddEpochOffset(int value)
@@ -38,17 +38,17 @@
//Next leap second
static int nextEpochMonth1970 = 0;
-static int64_t nextEpochUtc = 0;
+static clktime nextEpochUtc = 0;
int ClkUtcGetNextEpochMonth1970() { return nextEpochMonth1970; }
-int64_t ClkUtcGetNextEpoch () { return nextEpochUtc; }
+clktime ClkUtcGetNextEpoch () { return nextEpochUtc; }
static void makeNextEpochUtc()
{
int year = nextEpochMonth1970 / 12 + 1970;
int month = nextEpochMonth1970 % 12 + 1;
struct tm tm;
TmFromInteger(year, month, 1, 0, 0, 0, &tm);
- time_t t = TmUtcToTimeT(&tm);
- nextEpochUtc = (int64_t)t << CLK_TIME_ONE_SECOND_SHIFT;
+ time64 t = TmUtcToTimeT(&tm);
+ nextEpochUtc = (clktime)t << CLK_TIME_ONE_SECOND_SHIFT;
}
void ClkUtcSetNextEpochMonth1970(int value)
{
@@ -79,7 +79,7 @@
void ClkUtcInit(void)
{
epochOffset = GPREG1 & 0x0000FFFF;
- epochOffset64 = (int64_t)epochOffset << CLK_TIME_ONE_SECOND_SHIFT;
+ epochOffset64 = (clktime)epochOffset << CLK_TIME_ONE_SECOND_SHIFT;
nextEpochMonth1970 = (GPREG1 & 0x0FFF0000) >> 16;
makeNextEpochUtc();
nextLeapEnable = GPREG1 & 0x10000000;
@@ -87,15 +87,15 @@
}
-int64_t ClkUtcFromTai(int64_t tai) { return tai - epochOffset64; }
-int64_t ClkUtcToTai (int64_t utc) { return utc + epochOffset64; }
+clktime ClkUtcFromTai(clktime tai) { return tai - epochOffset64; }
+clktime ClkUtcToTai (clktime utc) { return utc + epochOffset64; }
-void ClkUtcCheckAdjustLeapSecondCount(int64_t tai)
+void ClkUtcCheckAdjustLeapSecondCount(clktime tai)
{
if (!nextLeapEnable) return; //Do nothing if leaps are disabled
- int64_t utc = ClkUtcFromTai(tai);
- int64_t epochEnd = ClkUtcGetNextEpoch() - (nextLeapForward ? 0 : 1);
+ clktime utc = ClkUtcFromTai(tai);
+ clktime epochEnd = ClkUtcGetNextEpoch() - (nextLeapForward ? 0 : 1);
if (utc < epochEnd) return; //Do nothing until reached the end of the current epoch