helpfor studient
Dependents: STM32_F103-C8T6basecanblink_led
Fork of mbed-dev by
Diff: targets/TARGET_NXP/TARGET_LPC176X/rtc_api.c
- Revision:
- 185:08ed48f1de7f
- Parent:
- 167:e84263d55307
diff -r 5166a824ec1a -r 08ed48f1de7f targets/TARGET_NXP/TARGET_LPC176X/rtc_api.c --- a/targets/TARGET_NXP/TARGET_LPC176X/rtc_api.c Tue Mar 20 17:01:51 2018 +0000 +++ b/targets/TARGET_NXP/TARGET_LPC176X/rtc_api.c Thu Apr 19 17:12:19 2018 +0100 @@ -89,7 +89,10 @@ timeinfo.tm_year = LPC_RTC->YEAR - 1900; // Convert to timestamp - time_t t = _rtc_mktime(&timeinfo); + time_t t; + if (_rtc_maketime(&timeinfo, &t, RTC_4_YEAR_LEAP_YEAR_SUPPORT) == false) { + return 0; + } return t; } @@ -97,10 +100,10 @@ void rtc_write(time_t t) { // Convert the time in to a tm struct tm timeinfo; - if (_rtc_localtime(t, &timeinfo) == false) { + if (_rtc_localtime(t, &timeinfo, RTC_4_YEAR_LEAP_YEAR_SUPPORT) == false) { return; } - + // Pause clock, and clear counter register (clears us count) LPC_RTC->CCR |= 2;