]> cloudbase.mooo.com Git - z180-stamp.git/blobdiff - avr/main.c
System time: Init from rtc on startup, update in timer inerrupt.
[z180-stamp.git] / avr / main.c
index 7e832bf493a216e4392267e99c93336e2c90972d..8acf265b5b430f319780724655899aacb9ba2b64 100644 (file)
@@ -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"));