![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
vr1.1
Dependencies: FreescaleIAP mbed-rtos mbed
Fork of CDMS_RTOS_v1_1 by
Diff: RTC.cpp
- Revision:
- 14:cf9f12b6887d
- Parent:
- 8:607ae92fa6af
- Child:
- 15:2c8629da6ec9
diff -r ba5dca9e18d8 -r cf9f12b6887d RTC.cpp --- a/RTC.cpp Mon Jul 06 11:26:57 2015 +0000 +++ b/RTC.cpp Tue Jul 14 10:14:36 2015 +0000 @@ -84,8 +84,7 @@ printf("\n\r rtc initalised \n"); } -void FCTN_CDMS_RD_RTC(uint8_t *time) - +uint64_t FCTN_CDMS_RD_RTC() { uint8_t response; printf("\n\r Entered rtc\n"); @@ -93,7 +92,7 @@ rtc_cs=0; rtc_spi.write(0x00); //reading milliseconds register response = rtc_spi.write(0x00); // read the value by sending dummy byte - uint8_t milliseconds = (uint8_t(response&0xF0)>>4)*10+uint8_t(response&0x0F)*1; + uint8_t centiseconds = (uint8_t(response&0xF0)>>4)*10+uint8_t(response&0x0F)*1; rtc_cs=1; rtc_cs=0; @@ -137,9 +136,19 @@ uint8_t year = ((response&0xF0)>>4)*10+(response&0x0F)*1; rtc_cs=1; //sprintf(Time_stamp,"%02d%02d%02d%02d%02d%02d%02d%02d",year, month, date, day, hours, minutes, seconds, milliseconds ); - uint8_t Time_stamp[8] = {year, month, date, day, hours, minutes, seconds, milliseconds}; + uint8_t Time_stamp[8] = {year, month, date, day, hours, minutes, seconds, centiseconds}; for(int i= 0; i<8;i++) printf("%d\t",Time_stamp[i]); printf("read\r\n"); - time = Time_stamp; + uint64_t time; + time = 0; + time = time|(uint64_t)(centiseconds&0xEF); + time = time|(uint64_t)(seconds&0xDF)<<7; + time = time|(uint64_t)(minutes&0xDF)<<13; + time = time|(uint64_t)(hours&0x1F)<<19; + time = time|(uint64_t)(day&0x1F)<<24; + time = time|(uint64_t)(month&0x0F)<<29; + time = time|(uint64_t)(year&0x03)<<33; + time = time&0x00000007FFFFFFFF; + return time; } \ No newline at end of file