Skip to content

Commit 1bb2ca6

Browse files
committed
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.
1 parent f526f19 commit 1bb2ca6

File tree

1 file changed

+5
-3
lines changed
  • targets/TARGET_RENESAS/TARGET_RZ_A1H

1 file changed

+5
-3
lines changed

targets/TARGET_RENESAS/TARGET_RZ_A1H/rtc_api.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
#define SHIFT_1BYTE (8u)
4949
#define SHIFT_2BYTE (16u)
5050

51-
#define TIME_ERROR_VAL (0xFFFFFFFFu)
51+
#define TIME_ERROR_VAL (0u)
5252

5353
static int rtc_dec8_to_hex(uint8_t dec_val, uint8_t offset, int *hex_val);
5454
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) {
214214

215215
if (err == 0) {
216216
// Convert to timestamp
217-
t = _rtc_mktime(&timeinfo);
217+
if (_rtc_maketime(&timeinfo, &t, RTC_FULL_LEAP_YEAR_SUPPORT) == false) {
218+
return TIME_ERROR_VAL;
219+
}
218220
} else {
219221
// Error
220222
t = TIME_ERROR_VAL;
@@ -305,7 +307,7 @@ static int rtc_dec16_to_hex(uint16_t dec_val, uint16_t offset, int *hex_val) {
305307
void rtc_write(time_t t) {
306308

307309
struct tm timeinfo;
308-
if (_rtc_localtime(t, &timeinfo) == false) {
310+
if (_rtc_localtime(t, &timeinfo, RTC_FULL_LEAP_YEAR_SUPPORT) == false) {
309311
return;
310312
}
311313

0 commit comments

Comments
 (0)