summaryrefslogtreecommitdiff
path: root/avr/timer.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/timer.c
parente63b2f75607905fedf00cfd9fe644b26af715ffd (diff)
downloadz180-stamp-be5cfb4b00c91be32cb736369a452faef8c24760.zip
System time: Init from rtc on startup, update in timer inerrupt.
Diffstat (limited to 'avr/timer.c')
-rw-r--r--avr/timer.c13
1 files changed, 11 insertions, 2 deletions
diff --git a/avr/timer.c b/avr/timer.c
index 7907bba..e222e68 100644
--- a/avr/timer.c
+++ b/avr/timer.c
@@ -4,6 +4,7 @@
#include "common.h"
#include <avr/interrupt.h>
#include <util/atomic.h>
+#include "time.h"
#include "timer.h"
/* timer interrupt/overflow counter */
@@ -18,7 +19,8 @@ uint32_t timestamp;
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 +28,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;
}