summaryrefslogtreecommitdiff
path: root/dcf77.c
diff options
context:
space:
mode:
Diffstat (limited to 'dcf77.c')
-rw-r--r--dcf77.c18
1 files changed, 7 insertions, 11 deletions
diff --git a/dcf77.c b/dcf77.c
index 91ae618..8cc385e 100644
--- a/dcf77.c
+++ b/dcf77.c
@@ -14,7 +14,8 @@
#include "dcf77.h"
- u8 code BITNO[] = {
+const u8 code BITNO[] = {
+ 0x60, 0x61, 0x62, 0x63, 0x68, // flags
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, // minute
0xFF, // parity
0x10, 0x11, 0x12, 0x13, 0x14, 0x15, // hour
@@ -24,7 +25,7 @@
0x40, 0x41, 0x42, 0x43, 0x44, // month
0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, // year
0xFF }; // parity
- u8 code BMASK[] = { 1, 2, 4, 8, 10, 20, 40, 80 };
+const u8 code BMASK[] = { 1, 2, 4, 8, 10, 20, 40, 80, 0 };
struct time newtime;
@@ -39,13 +40,13 @@ void decode_dcf77( u8 pulse )
u8 i;
u8 *d;
- i = newtime.second - 21;
+ i = newtime.second - 16;
if( i >= sizeof( BITNO )) // only bit 21 ... 58
return;
parity ^= pulse; // calculate parity
i = LPM(&BITNO[i]);
- if( i == 0xFF ){ // test parity
- if( parity )
+ if( i & 0x08 ){ // test parity
+ if( (i & 0x80) && parity )
dcf77error = 1;
parity = 0;
return;
@@ -81,13 +82,8 @@ void scan_dcf77( void )
if( dcf77error == 0 && newtime.second == 59 ){
synchronize = 0xFF;
sync_sec();
+ time = newtime;
time.second = 0;
- time.minute = newtime.minute;
- time.hour = newtime.hour;
- time.wday = newtime.wday;
- time.day = newtime.day;
- time.month = newtime.month;
- time.year = newtime.year;
}
newtime.second = 0;
dcf77error = 0;