fix parity check
This commit is contained in:
parent
67d4d8e8db
commit
7c6b43d464
|
@ -78,13 +78,13 @@ uint8_t* rtc_dcf77_time(void)
|
|||
if (rtc_dcf77_frame==0) { // no time received yet
|
||||
return NULL;
|
||||
}
|
||||
if (!(rtc_dcf77_frame&(1<<20))) { // start of encode time should always be 1
|
||||
if (!(rtc_dcf77_frame&((uint64_t)1<<20))) { // start of encode time should always be 1
|
||||
return NULL;
|
||||
}
|
||||
// check minute parity
|
||||
parity = 0;
|
||||
for (uint8_t bit=21; bit<29; bit++) {
|
||||
if (rtc_dcf77_frame&(1<<bit)) {
|
||||
for (uint8_t bit=21; bit<=28; bit++) {
|
||||
if (rtc_dcf77_frame&((uint64_t)1<<bit)) {
|
||||
parity++; // count the set bits
|
||||
}
|
||||
}
|
||||
|
@ -94,8 +94,8 @@ uint8_t* rtc_dcf77_time(void)
|
|||
to_return[0] = 1*((rtc_dcf77_frame>>21)&(0x1))+2*((rtc_dcf77_frame>>22)&(0x1))+4*((rtc_dcf77_frame>>23)&(0x1))+8*((rtc_dcf77_frame>>24)&(0x1))+10*((rtc_dcf77_frame>>25)&(0x1))+20*((rtc_dcf77_frame>>26)&(0x1))+40*((rtc_dcf77_frame>>27)&(0x1)); // read minute (00-59)
|
||||
// check hour parity
|
||||
parity = 0;
|
||||
for (uint8_t bit=29; bit<35; bit++) {
|
||||
if (rtc_dcf77_frame&(1<<bit)) {
|
||||
for (uint8_t bit=29; bit<=35; bit++) {
|
||||
if (rtc_dcf77_frame&((uint64_t)1<<bit)) {
|
||||
parity++; // count the set bits
|
||||
}
|
||||
}
|
||||
|
@ -105,8 +105,8 @@ uint8_t* rtc_dcf77_time(void)
|
|||
to_return[1] = 1*((rtc_dcf77_frame>>29)&(0x1))+2*((rtc_dcf77_frame>>30)&(0x1))+4*((rtc_dcf77_frame>>31)&(0x1))+8*((rtc_dcf77_frame>>32)&(0x1))+10*((rtc_dcf77_frame>>33)&(0x1))+20*((rtc_dcf77_frame>>34)&(0x1)); // read hour (00-23)
|
||||
// check date parity
|
||||
parity = 0;
|
||||
for (uint8_t bit=36; bit<57; bit++) {
|
||||
if (rtc_dcf77_frame&(1<<bit)) {
|
||||
for (uint8_t bit=36; bit<=58; bit++) {
|
||||
if (rtc_dcf77_frame&((uint64_t)1<<bit)) {
|
||||
parity++; // count the set bits
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue