From df67204cc84d996d43edca5cf2b840220aa706d3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?King=20K=C3=A9vin?= Date: Sun, 8 Oct 2017 17:30:22 +0200 Subject: [PATCH] lib/rtc_dcf77: make library compilable again --- lib/rtc_dcf77.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/lib/rtc_dcf77.c b/lib/rtc_dcf77.c index 3e0fdd2..6c548c3 100644 --- a/lib/rtc_dcf77.c +++ b/lib/rtc_dcf77.c @@ -24,18 +24,19 @@ #include // general utilities /* STM32 (including CM3) libraries */ +#include // Cortex M3 utilities #include // real-time control clock library #include // general purpose input output library #include // SPI library #include // timer library #include // interrupt handler -#include // Cortex M3 utilities +#include // external interrupt utilities #include "rtc_dcf77.h" // RTC DCF77 library API #include "global.h" // common methods volatile bool rtc_dcf77_time_flag = false; -volatile uint64_t rtc_dcf77_frame = 0; /**< the received DCF77 frame bits */ +static volatile uint64_t rtc_dcf77_frame = 0; /**< the received DCF77 frame bits */ void rtc_dcf77_setup(void) { @@ -105,7 +106,7 @@ uint8_t* rtc_dcf77_time(void) if (parity%2) { // parity should be even return NULL; } - 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) + 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>>30)>>2)&(0x1))+10*(((rtc_dcf77_frame>>30)>>3)&(0x1))+20*(((rtc_dcf77_frame>>30)>>4)&(0x1)); // read hour (00-23) if (to_return[1]>23) { // hours should not be more than 23 return NULL; } @@ -119,19 +120,19 @@ uint8_t* rtc_dcf77_time(void) if (parity%2) { // parity should be even return NULL; } - to_return[2] = 1*((rtc_dcf77_frame>>36)&(0x1))+2*((rtc_dcf77_frame>>37)&(0x1))+4*((rtc_dcf77_frame>>38)&(0x1))+8*((rtc_dcf77_frame>>39)&(0x1))+10*((rtc_dcf77_frame>>40)&(0x1))+20*((rtc_dcf77_frame>>41)&(0x1)); // read day of the month (01-31) + to_return[2] = 1*(((rtc_dcf77_frame>>30)>>6)&(0x1))+2*(((rtc_dcf77_frame>>30)>>7)&(0x1))+4*(((rtc_dcf77_frame>>30)>>8)&(0x1))+8*(((rtc_dcf77_frame>>30)>>9)&(0x1))+10*(((rtc_dcf77_frame>>30)>>10)&(0x1))+20*(((rtc_dcf77_frame>>30)>>11)&(0x1)); // read day of the month (01-31) if (to_return[2]==0 || to_return[2]>31) { // day of the month should be 1-31 return NULL; } - to_return[3] = 1*((rtc_dcf77_frame>>42)&(0x1))+2*((rtc_dcf77_frame>>43)&(0x1))+4*((rtc_dcf77_frame>>44)&(0x1)); // read day of the week (1=Monday - 7=Sunday) + to_return[3] = 1*(((rtc_dcf77_frame>>30)>>12)&(0x1))+2*(((rtc_dcf77_frame>>30)>>13)&(0x1))+4*(((rtc_dcf77_frame>>30)>>14)&(0x1)); // read day of the week (1=Monday - 7=Sunday) if (to_return[3]==0 || to_return[3]>7) { // day of the week should be 1-7 return NULL; } - to_return[4] = 1*((rtc_dcf77_frame>>45)&(0x1))+2*((rtc_dcf77_frame>>46)&(0x1))+4*((rtc_dcf77_frame>>47)&(0x1))+8*((rtc_dcf77_frame>>48)&(0x1))+10*((rtc_dcf77_frame>>49)&(0x1)); // read month of the year (01-12) + to_return[4] = 1*(((rtc_dcf77_frame>>30)>>15)&(0x1))+2*(((rtc_dcf77_frame>>30)>>16)&(0x1))+4*(((rtc_dcf77_frame>>30)>>17)&(0x1))+8*(((rtc_dcf77_frame>>30)>>18)&(0x1))+10*(((rtc_dcf77_frame>>30)>>19)&(0x1)); // read month of the year (01-12) if (to_return[4]==0 || to_return[4]>12) { // month of the year should be 1-12 return NULL; } - to_return[5] = 1*((rtc_dcf77_frame>>50)&(0x1))+2*((rtc_dcf77_frame>>51)&(0x1))+4*((rtc_dcf77_frame>>52)&(0x1))+8*((rtc_dcf77_frame>>53)&(0x1))+10*((rtc_dcf77_frame>>54)&(0x1))+20*((rtc_dcf77_frame>>55)&(0x1))+40*((rtc_dcf77_frame>>56)&(0x1))+80*((rtc_dcf77_frame>>57)&(0x1)); // read year of the century (00-99) + to_return[5] = 1*(((rtc_dcf77_frame>>30)>>20)&(0x1))+2*(((rtc_dcf77_frame>>30)>>21)&(0x1))+4*(((rtc_dcf77_frame>>30)>>22)&(0x1))+8*(((rtc_dcf77_frame>>30)>>23)&(0x1))+10*(((rtc_dcf77_frame>>30)>>24)&(0x1))+20*(((rtc_dcf77_frame>>30)>>25)&(0x1))+40*(((rtc_dcf77_frame>>30)>>26)&(0x1))+80*(((rtc_dcf77_frame>>30)>>27)&(0x1)); // read year of the century (00-99) if (to_return[5]>99) { // year should be <100 return NULL; }