#ifndef CLOCK_H #define CLOCK_H /* this dcf77-module relies on a accuarate clock (cristal) for receiving * the dcf-signal. therefor the clock is going to work as expected, * even with no dcf77-signal available. * receivement is automatically turned on, if the avr is connected to the * signal via INT0. if there is no signal the clock will not be set (K.I.S.S.) * */ #include #include #include #include /// #include "../stdout.h" /// #include "../display/display.h" /// #include "../uart/uart.h" #define INT0_CONTROL MCUCR #define INT0_FALLING_EDGE 0x02 #define INT0_RISING_EDGE 0x03 typedef struct { volatile unsigned char bit : 1; } Bit; typedef struct { unsigned char h ; // hour unsigned char m ; // minute unsigned char s ; // second unsigned char dd; // day unsigned char wd; // weekday unsigned char mm; // month unsigned char yy; // year unsigned char us; // 10th second unsigned int ms; // milli second } Time; typedef enum { DCF_FIRST = 0, // start of a new minute (note: always 0) DCF_WEATHER = 14, // proprietary :-( DCF_ANTENNA = 15, // 0: normal, 1: replacement DCF_DST = 16, // daylight saving time: this hour new time... DCF_MEZ = 17, // 'summer-time' DCF_MESZ = 18, // 'winter-time' DCF_DBLSEC = 19, // one extra second gonna be inserted DCF_START = 20, // begin of time-info (note: always 1) DCF_MIN = 21, // 7 bit DCF_MINP = 28, // parity bit for minutes DCF_HOUR = 29, // 6 bit DCF_HOURP = 35, // parity bit for hours DCF_DAY = 36, // 6 bit DCF_WEEKDAY = 42, // 3 bit DCF_MONTH = 45, // 5 bit DCF_YEAR = 50, // 8 bit DCF_DATEP = 58 // parity bit for date } DCF; /* typedef struct { Bit useless[14]; Bit antenna; Bit dst; Bit mez; Bit mesz; Bit dblsec; Bit start; // < always 1 - use for verification unsigned char min : 7; Bit min_p; // < minutes parity unsigned char hour : 6; Bit hour_p; // < hours parity unsigned char day : 6; // day of month unsigned char dow : 3; // day of week (1=monday) unsigned char month : 5; // month of year unsigned char year : 8; // year Bit date_p; // parity of date } DCF_Signal; */ volatile Bit dcf77[60]; volatile unsigned char dcf77_bit; volatile Time t_current; volatile unsigned int interval; volatile unsigned int lastinterval; /// void getBits(volatile unsigned char* target, const DCF start, const char len, const DCF parity); /// void set_dcf_value(); void timer_init(); /// void interrupts_init(); #endif