]> cloudbase.mooo.com Git - z180-stamp.git/blobdiff - avr/timer.c
f_sync only, when timout (currently 1s) after last write operation.
[z180-stamp.git] / avr / timer.c
index 7907bbad2811598048a1bed29833f18f5b9219de..f45f2675564f0f26028774de91c63b0ae395f5d5 100644 (file)
@@ -1,9 +1,13 @@
 /*
+ * (C) Copyright 2014 Leo C. <erbl259-lmu@yahoo.de>
+ *
+ * SPDX-License-Identifier:    GPL-2.0+
  */
 
 #include "common.h"
 #include <avr/interrupt.h>
 #include <util/atomic.h>
+#include "time.h"
 #include "timer.h"
 
 /* timer interrupt/overflow counter */
 static volatile
 uint32_t timestamp;
 
-/*---------------------------------------------------------*/
-/* 1000Hz timer interrupt generated by OC3A                */
-/*---------------------------------------------------------*/
-
+/*
+ * 1000Hz timer interrupt generated by OC3A
+ */
 ISR(TIMER3_COMPA_vect)
 {
        static int_fast8_t tick_10ms;
-       int_fast8_t i;
+       static int_fast8_t tick_1s;
+       int_fast8_t i, j;
 
        extern void disk_timerproc(void);
 
@@ -26,11 +30,18 @@ ISR(TIMER3_COMPA_vect)
 
        i = tick_10ms + 1;
        if (i == 10) {
-               i = 0;
                Stat |= S_10MS_TO;
 
                /* Drive timer procedure of low level disk I/O module */
                disk_timerproc();
+
+               j = tick_1s - 1;
+               if (j == 0) {
+                       system_tick();
+                       j = 100;
+               }
+               tick_1s = j;
+               i = 0;
        }
        tick_10ms = i;
 }