lib/rtc_dcf77: make library compilable again

This commit is contained in:
King Kévin 2017-10-08 17:30:22 +02:00
parent 042d9dfec5
commit df67204cc8
1 changed files with 8 additions and 7 deletions

View File

@ -24,18 +24,19 @@
#include <stdlib.h> // general utilities
/* STM32 (including CM3) libraries */
#include <libopencmsis/core_cm3.h> // Cortex M3 utilities
#include <libopencm3/stm32/rcc.h> // real-time control clock library
#include <libopencm3/stm32/gpio.h> // general purpose input output library
#include <libopencm3/stm32/spi.h> // SPI library
#include <libopencm3/stm32/timer.h> // timer library
#include <libopencm3/cm3/nvic.h> // interrupt handler
#include <libopencmsis/core_cm3.h> // Cortex M3 utilities
#include <libopencm3/stm32/exti.h> // 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;
}