Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of mbed-dev by
Diff: targets/TARGET_NXP/TARGET_LPC176X/rtc_api.c
- Revision:
- 167:e84263d55307
- Parent:
- 149:156823d33999
--- a/targets/TARGET_NXP/TARGET_LPC176X/rtc_api.c Thu Jun 08 15:02:37 2017 +0100 +++ b/targets/TARGET_NXP/TARGET_LPC176X/rtc_api.c Wed Jun 21 17:46:44 2017 +0100 @@ -14,6 +14,7 @@ * limitations under the License. */ #include "rtc_api.h" +#include "mbed_mktime.h" // ensure rtc is running (unchanged if already running) @@ -88,25 +89,28 @@ timeinfo.tm_year = LPC_RTC->YEAR - 1900; // Convert to timestamp - time_t t = mktime(&timeinfo); + time_t t = _rtc_mktime(&timeinfo); return t; } void rtc_write(time_t t) { // Convert the time in to a tm - struct tm *timeinfo = localtime(&t); + struct tm timeinfo; + if (_rtc_localtime(t, &timeinfo) == false) { + return; + } // Pause clock, and clear counter register (clears us count) LPC_RTC->CCR |= 2; // Set the RTC - LPC_RTC->SEC = timeinfo->tm_sec; - LPC_RTC->MIN = timeinfo->tm_min; - LPC_RTC->HOUR = timeinfo->tm_hour; - LPC_RTC->DOM = timeinfo->tm_mday; - LPC_RTC->MONTH = timeinfo->tm_mon + 1; - LPC_RTC->YEAR = timeinfo->tm_year + 1900; + LPC_RTC->SEC = timeinfo.tm_sec; + LPC_RTC->MIN = timeinfo.tm_min; + LPC_RTC->HOUR = timeinfo.tm_hour; + LPC_RTC->DOM = timeinfo.tm_mday; + LPC_RTC->MONTH = timeinfo.tm_mon + 1; + LPC_RTC->YEAR = timeinfo.tm_year + 1900; // Restart clock LPC_RTC->CCR &= ~((uint32_t)2);