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
Revision 71:f621d2127216, committed 2020-02-26
- Comitter:
- andrewboyson
- Date:
- Wed Feb 26 10:57:20 2020 +0000
- Parent:
- 70:d04775a75597
- Child:
- 72:8f15a8b142ab
- Commit message:
- Added initialisation for the case where the RTC has lost power
Changed in this revision
| clk/clkgov.c | Show annotated file Show diff for this revision Revisions of this file |
| clk/clkutc.c | Show annotated file Show diff for this revision Revisions of this file |
--- a/clk/clkgov.c Mon Oct 21 14:32:27 2019 +0000
+++ b/clk/clkgov.c Wed Feb 26 10:57:20 2020 +0000
@@ -6,6 +6,7 @@
#include "clk.h"
#include "clkutc.h"
#include "time64.h"
+#include "rtc.h"
#define GPREG0 (*((volatile unsigned *) 0x40024044))
@@ -19,6 +20,7 @@
void ClkGovSetPpb (int32_t value) { ppb = value; GPREG0 = ppb; }
void ClkGovInit()
{
+ if (RtcPowerLost()) GPREG0 = 0;
ppb = GPREG0;
}
--- a/clk/clkutc.c Mon Oct 21 14:32:27 2019 +0000
+++ b/clk/clkutc.c Wed Feb 26 10:57:20 2020 +0000
@@ -1,7 +1,8 @@
#include <stdint.h>
#include "clktime.h"
-#include "tm.h"
+#include "tm.h"
+#include "rtc.h"
#define GPREG1 (*((volatile unsigned *) 0x40024048))
@@ -78,6 +79,8 @@
void ClkUtcInit(void)
{
+ if (RtcPowerLost()) GPREG1 = 0;
+
epochOffset = GPREG1 & 0x0000FFFF;
epochOffset64 = (clktime)epochOffset << CLK_TIME_ONE_SECOND_SHIFT;
nextEpochMonth1970 = (GPREG1 & 0x0FFF0000) >> 16;