summaryrefslogtreecommitdiff
path: root/avr/main.c
diff options
context:
space:
mode:
authorLeo C2014-12-02 11:45:40 +0100
committerLeo C2014-12-02 11:45:40 +0100
commitbe5cfb4b00c91be32cb736369a452faef8c24760 (patch)
treee9f43c6bd189880b7de66aab0bf0ed16960f5f1a /avr/main.c
parente63b2f75607905fedf00cfd9fe644b26af715ffd (diff)
downloadz180-stamp-be5cfb4b00c91be32cb736369a452faef8c24760.zip
System time: Init from rtc on startup, update in timer inerrupt.
Diffstat (limited to 'avr/main.c')
-rw-r--r--avr/main.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/avr/main.c b/avr/main.c
index 7e832bf..8acf265 100644
--- a/avr/main.c
+++ b/avr/main.c
@@ -20,6 +20,8 @@
#include "z180-serv.h"
#include "spi.h"
#include "gpio.h"
+#include "time.h"
+#include "rtc.h"
static uint8_t mcusr;
@@ -132,6 +134,16 @@ int reset_reason_is_power_on(void)
return (mcusr & _BV(PORF)) != 0;
}
+static
+void setup_system_time(void)
+{
+ struct tm rtc_time;
+
+ rtc_get(&rtc_time);
+ rtc_time.tm_isdst = 0;
+ set_system_time(mk_gmtime(&rtc_time) );
+}
+
/*--------------------------------------------------------------------------*/
/* Stored value of bootdelay, used by autoboot_command() */
@@ -252,6 +264,7 @@ int main(void)
#else
i2c_init(CONFIG_SYS_I2C_CLOCK);
#endif
+ setup_system_time();
printf_P(PSTR("\nATMEGA1281+Z8S180 Stamp Monitor\n\n"));