diff options
| author | Max Christian Pohle | 2015-07-27 15:12:22 +0200 |
|---|---|---|
| committer | Max Christian Pohle | 2015-07-27 15:12:22 +0200 |
| commit | 2df2697107d7873232c31a25a6947711b0903edb (patch) | |
| tree | ff7247e9e970c69f3d3385950b19db9997a511b8 /src/inc/int/dcf77/clock.h | |
| download | alarmclock-2df2697107d7873232c31a25a6947711b0903edb.tar.bz2 alarmclock-2df2697107d7873232c31a25a6947711b0903edb.zip | |
latest running version from march 2011, not having been in repo before,
dcf77 working, mp3 playback and two display types are supported
Diffstat (limited to 'src/inc/int/dcf77/clock.h')
| -rwxr-xr-x | src/inc/int/dcf77/clock.h | 98 |
1 files changed, 98 insertions, 0 deletions
diff --git a/src/inc/int/dcf77/clock.h b/src/inc/int/dcf77/clock.h new file mode 100755 index 0000000..c7f75c7 --- /dev/null +++ b/src/inc/int/dcf77/clock.h | |||
| @@ -0,0 +1,98 @@ | |||
| 1 | #ifndef CLOCK_H | ||
| 2 | #define CLOCK_H | ||
| 3 | /* this dcf77-module relies on a accuarate clock (cristal) for receiving | ||
| 4 | * the dcf-signal. therefor the clock is going to work as expected, | ||
| 5 | * even with no dcf77-signal available. | ||
| 6 | * receivement is automatically turned on, if the avr is connected to the | ||
| 7 | * signal via INT0. if there is no signal the clock will not be set (K.I.S.S.) | ||
| 8 | * | ||
| 9 | */ | ||
| 10 | #include <stdint.h> | ||
| 11 | #include <avr/io.h> | ||
| 12 | #include <avr/interrupt.h> | ||
| 13 | #include <limits.h> | ||
| 14 | |||
| 15 | /// #include "../stdout.h" | ||
| 16 | /// #include "../display/display.h" | ||
| 17 | /// #include "../uart/uart.h" | ||
| 18 | |||
| 19 | #define INT0_CONTROL MCUCR | ||
| 20 | #define INT0_FALLING_EDGE 0x02 | ||
| 21 | #define INT0_RISING_EDGE 0x03 | ||
| 22 | |||
| 23 | |||
| 24 | |||
| 25 | typedef struct | ||
| 26 | { | ||
| 27 | volatile unsigned char bit : 1; | ||
| 28 | } Bit; | ||
| 29 | |||
| 30 | typedef struct | ||
| 31 | { | ||
| 32 | unsigned char h ; // hour | ||
| 33 | unsigned char m ; // minute | ||
| 34 | unsigned char s ; // second | ||
| 35 | unsigned char dd; // day | ||
| 36 | unsigned char wd; // weekday | ||
| 37 | unsigned char mm; // month | ||
| 38 | unsigned char yy; // year | ||
| 39 | unsigned char us; // 10th second | ||
| 40 | unsigned int ms; // milli second | ||
| 41 | } Time; | ||
| 42 | |||
| 43 | typedef enum | ||
| 44 | { | ||
| 45 | DCF_FIRST = 0, // start of a new minute (note: always 0) | ||
| 46 | DCF_WEATHER = 14, // proprietary :-( | ||
| 47 | DCF_ANTENNA = 15, // 0: normal, 1: replacement | ||
| 48 | DCF_DST = 16, // daylight saving time: this hour new time... | ||
| 49 | DCF_MEZ = 17, // 'summer-time' | ||
| 50 | DCF_MESZ = 18, // 'winter-time' | ||
| 51 | DCF_DBLSEC = 19, // one extra second gonna be inserted | ||
| 52 | DCF_START = 20, // begin of time-info (note: always 1) | ||
| 53 | DCF_MIN = 21, // 7 bit | ||
| 54 | DCF_MINP = 28, // parity bit for minutes | ||
| 55 | DCF_HOUR = 29, // 6 bit | ||
| 56 | DCF_HOURP = 35, // parity bit for hours | ||
| 57 | DCF_DAY = 36, // 6 bit | ||
| 58 | DCF_WEEKDAY = 42, // 3 bit | ||
| 59 | DCF_MONTH = 45, // 5 bit | ||
| 60 | DCF_YEAR = 50, // 8 bit | ||
| 61 | DCF_DATEP = 58 // parity bit for date | ||
| 62 | } DCF; | ||
| 63 | |||
| 64 | /* | ||
| 65 | typedef struct | ||
| 66 | { | ||
| 67 | Bit useless[14]; | ||
| 68 | Bit antenna; | ||
| 69 | Bit dst; | ||
| 70 | Bit mez; | ||
| 71 | Bit mesz; | ||
| 72 | Bit dblsec; | ||
| 73 | Bit start; // < always 1 - use for verification | ||
| 74 | unsigned char min : 7; | ||
| 75 | Bit min_p; // < minutes parity | ||
| 76 | unsigned char hour : 6; | ||
| 77 | Bit hour_p; // < hours parity | ||
| 78 | unsigned char day : 6; // day of month | ||
| 79 | unsigned char dow : 3; // day of week (1=monday) | ||
| 80 | unsigned char month : 5; // month of year | ||
| 81 | unsigned char year : 8; // year | ||
| 82 | Bit date_p; // parity of date | ||
| 83 | } DCF_Signal; | ||
| 84 | */ | ||
| 85 | |||
| 86 | |||
| 87 | volatile Bit dcf77[60]; | ||
| 88 | volatile unsigned char dcf77_bit; | ||
| 89 | volatile Time t_current; | ||
| 90 | volatile unsigned int interval; | ||
| 91 | volatile unsigned int lastinterval; | ||
| 92 | |||
| 93 | /// void getBits(volatile unsigned char* target, const DCF start, const char len, const DCF parity); | ||
| 94 | /// void set_dcf_value(); | ||
| 95 | void timer_init(); | ||
| 96 | /// void interrupts_init(); | ||
| 97 | |||
| 98 | #endif | ||
