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