From 67781c25c17b2df24e9350bc6e4e18bd3ccb6bcc Mon Sep 17 00:00:00 2001 From: TomoYamanaka Date: Thu, 14 Dec 2017 20:30:45 +0900 Subject: [PATCH] Supplement the lack of "extended RTC" in RZ_A1H/rtc_api.c Although the extened RTC is supported by #5363 commit ("Add support and tests for extended RTC"), it seems that the changes was overlooked in RZ_A1H_api.c. So I added the changes with reference to other rtc_api.c. --- targets/TARGET_RENESAS/TARGET_RZ_A1H/rtc_api.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/targets/TARGET_RENESAS/TARGET_RZ_A1H/rtc_api.c b/targets/TARGET_RENESAS/TARGET_RZ_A1H/rtc_api.c index f526a221c3..2be14483c1 100644 --- a/targets/TARGET_RENESAS/TARGET_RZ_A1H/rtc_api.c +++ b/targets/TARGET_RENESAS/TARGET_RZ_A1H/rtc_api.c @@ -48,7 +48,7 @@ #define SHIFT_1BYTE (8u) #define SHIFT_2BYTE (16u) -#define TIME_ERROR_VAL (0xFFFFFFFFu) +#define TIME_ERROR_VAL (0u) static int rtc_dec8_to_hex(uint8_t dec_val, uint8_t offset, int *hex_val); static int rtc_dec16_to_hex(uint16_t dec_val, uint16_t offset, int *hex_val); @@ -214,7 +214,9 @@ time_t rtc_read(void) { if (err == 0) { // Convert to timestamp - t = _rtc_mktime(&timeinfo); + if (_rtc_maketime(&timeinfo, &t, RTC_FULL_LEAP_YEAR_SUPPORT) == false) { + return TIME_ERROR_VAL; + } } else { // Error t = TIME_ERROR_VAL; @@ -305,7 +307,7 @@ static int rtc_dec16_to_hex(uint16_t dec_val, uint16_t offset, int *hex_val) { void rtc_write(time_t t) { struct tm timeinfo; - if (_rtc_localtime(t, &timeinfo) == false) { + if (_rtc_localtime(t, &timeinfo, RTC_FULL_LEAP_YEAR_SUPPORT) == false) { return; } volatile uint16_t dummy_read;