From 069f3c54d928149a64fccd13a39789472478761e Mon Sep 17 00:00:00 2001 From: Stefan Rupp Date: Sun, 2 Mar 2014 08:01:37 +0100 Subject: [PATCH] implemented basics of rtc module --- rtc.c | 28 ++++++++++++++++------------ rtc.h | 2 +- 2 files changed, 17 insertions(+), 13 deletions(-) diff --git a/rtc.c b/rtc.c index 1147508..4f97b94 100644 --- a/rtc.c +++ b/rtc.c @@ -8,7 +8,6 @@ * ---------------------------------------------------------------------------- */ -#if 0 #include #include "rtc.h" @@ -16,24 +15,29 @@ #include -static volatile uint32_t rtc_time; +static volatile uint32_t _rtc_time; -ISR(TIMER2_COMP_vect) { - ++rtc_time; +ISR(TIMER2_OVF_vect) { + ++_rtc_time; return; } -void rtc_init(void) +void rtc_init(uint32_t rtc_time) { // Stop all interrupts cli(); + TCCR2B = 0; + TCCR2A = 0; + TCNT2 = 0; // Reset timer to zero - rtc_time = 0; + _rtc_time = rtc_time; - // ... - // ... - // ... + ASSR = (1<