aboutsummaryrefslogtreecommitdiff
path: root/software/inc/int/dcf77.h
diff options
context:
space:
mode:
Diffstat (limited to 'software/inc/int/dcf77.h')
-rwxr-xr-xsoftware/inc/int/dcf77.h68
1 files changed, 68 insertions, 0 deletions
diff --git a/software/inc/int/dcf77.h b/software/inc/int/dcf77.h
new file mode 100755
index 0000000..2d79cdd
--- /dev/null
+++ b/software/inc/int/dcf77.h
@@ -0,0 +1,68 @@
1#ifndef CLOCK_H
2#define CLOCK_H
3 /* this dcf77-module relies on a accuarate clock (crystal) 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 <avr/io.h>
11 #include <avr/interrupt.h>
12 #include <stdint.h>
13
14 #define INT0_CONTROL MCUCR
15 // #define INT0_FALLING_EDGE 0x02
16 // #define INT0_RISING_EDGE 0x03
17 #define INT0_FALLING_EDGE (1<<ISC01)
18 #define INT0_RISING_EDGE (1<<ISC01 | 1<<ISC00)
19 #define INT0_EDGE_ANY (1<<ISC00)
20
21 typedef struct
22 {
23 volatile unsigned char bit : 1;
24 } Bit;
25
26 typedef struct
27 {
28 uint16_t h; // hour
29 uint16_t m; // minute
30 uint16_t s; // second
31 uint16_t ms; // milli second
32 uint8_t yy; // year
33 uint8_t mm; // month
34 uint8_t dd; // day
35 uint8_t wd; // weekday
36 } Time;
37
38 typedef enum
39 {
40 DCF_FIRST = 0, // start of a new minute (note: always 0)
41 DCF_WEATHER = 14, // proprietary :-(
42 DCF_ANTENNA = 15, // 0: normal, 1: replacement
43 DCF_DST = 16, // daylight saving time: this hour new time...
44 DCF_MEZ = 17, // 'summer-time'
45 DCF_MESZ = 18, // 'winter-time'
46 DCF_DBLSEC = 19, // one extra second gonna be inserted
47 DCF_START = 20, // begin of time-info (note: always 1)
48 DCF_MIN = 21, // 7 bit
49 DCF_MINP = 28, // parity bit for minutes
50 DCF_HOUR = 29, // 6 bit
51 DCF_HOURP = 35, // parity bit for hours
52 DCF_DAY = 36, // 6 bit
53 DCF_WEEKDAY = 42, // 3 bit
54 DCF_MONTH = 45, // 5 bit
55 DCF_YEAR = 50, // 8 bit
56 DCF_DATEP = 58 // parity bit for date
57 } DCF;
58
59 volatile Bit dcf77[60];
60 volatile uint8_t dcf77_bit;
61 volatile Time t_current;
62 volatile uint16_t interval;
63
64 /// void getBits(volatile unsigned char* target, const DCF start, const char len, const DCF parity);
65 /// void set_dcf_value();
66 /// void interrupts_init();
67
68#endif
..