Latest FM Code with EEPROM
Dependencies: FreescaleIAP SimpleDMA eeprom mbed-rtos mbed
Fork of CDMS_QM_03MAR2017_Flash_with_obsrs by
Diff: cdms_rtc.h
- Revision:
- 356:4484bf39526f
- Parent:
- 354:eb6c863756a8
diff -r a5e72222ff26 -r 4484bf39526f cdms_rtc.h --- a/cdms_rtc.h Tue Mar 28 08:50:07 2017 +0000 +++ b/cdms_rtc.h Sat Feb 24 10:28:56 2018 +0000 @@ -76,17 +76,17 @@ gCS_RTC=0; spi.write(0x87); - spi.write(0x00); //set year to 00(2000) + spi.write(0x16); //set year to 00(2000) gCS_RTC=1; gPC.puts("\n\r rtc initalised \n"); RTC_INIT_STATUS = 1; - FCTN_CDMS_WR_FLASH(5,1); + WRITE_TO_EEPROM(5,1); SPI_mutex.unlock(); } uint64_t FCTN_CDMS_RD_RTC() { - if(EN_RTC == 0) + if(EN_RTC == 0) return 0; SPI_mutex.lock(); uint8_t response; @@ -140,19 +140,19 @@ gCS_RTC=1; gCS_RTC=0; - response =spi.write(0x00); + spi.write(0x07); + response = spi.write(0x01); uint8_t year = ((response&0xF0)>>4)*10+(response&0x0F)*1; year = (year == 16)?0x00:(year == 17)?0x01:(year == 18)?0x02:(year == 19)?0x03:0x00; gCS_RTC=1; - uint8_t Time_stamp[8] = {year, month, date, day, hours, minutes, seconds, centiseconds}; time = time|(((uint64_t)(centiseconds&0x7F))); time = time|(((uint64_t)(seconds&0x3F))<<7); time = time|(((uint64_t)(minutes&0x3F))<<13); time = time|(((uint64_t)(hours&0x1F))<<19); - time = time|(((uint64_t)(day&0x1F))<<24); - time = time|(((uint64_t)(month&0x07))<<29); + time = time|(((uint64_t)(date&0x1F))<<24); + time = time|(((uint64_t)(month&0x0F))<<29); time = time|(((uint64_t)(year&0x03))<<33); time = (time&0x00000007FFFFFFFF); SPI_mutex.unlock();