
CDMS code for testing sbc
Dependencies: FreescaleIAP SimpleDMA mbed-rtos mbed
Fork of CDMS_CODE by
Diff: cdms_rtc.h
- Revision:
- 216:570251b23c7b
- Parent:
- 209:63e9c8f8b5d2
- Child:
- 218:c63cdba0550f
--- a/cdms_rtc.h Sun Jul 03 09:26:42 2016 +0000 +++ b/cdms_rtc.h Sun Jul 03 09:47:05 2016 +0000 @@ -1,5 +1,9 @@ void FCTN_CDMS_INIT_RTC() { + if(RTC_INIT_STATUS = 1) + { + + } SPI_mutex.lock(); gCS_RTC=1; spi.format(8,0); @@ -82,11 +86,16 @@ { SPI_mutex.lock(); uint8_t response; - + uint64_t time = 0; + gCS_RTC=1; gCS_RTC=0; spi.write(0x0F); response = (spi.write(0x00))&0x04; + if(response == 0x04) + { + goto END; + } gCS_RTC=1; gCS_RTC=0; @@ -116,7 +125,6 @@ year = (year == 17)?0x00:(year == 18)?0x01:(year == 19)?0x02:(year == 20)?0x03:0x00; gCS_RTC=1; - uint64_t time; time = 0; time = time|(((uint64_t)(centiseconds&0x7F))); time = time|(((uint64_t)(seconds&0x3F))<<7); @@ -128,6 +136,8 @@ time = (time&0x00000007FFFFFFFF); SPI_mutex.unlock(); + TIME_LATEST_RTC = time >> 7; + END: return time; }