Skip to content

Commit 19d07a2

Browse files
fixup! adding R_RTC_ClockSourceSet when setting rtc time FIXME
1 parent 874beea commit 19d07a2

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

libraries/RTC/src/RTC.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -540,8 +540,13 @@ void set_time(time_t t)
540540
}
541541
#endif
542542

543+
bool isRtcRunning();
544+
543545
bool openRtc() {
544546
if(!rtc_ctrl.open && FSP_SUCCESS == R_RTC_Open(&rtc_ctrl, &rtc_cfg)) {
547+
if(!isRtcRunning()) {
548+
R_RTC_ClockSourceSet(&rtc_ctrl);
549+
}
545550
return true;
546551
}
547552
else {
@@ -551,8 +556,6 @@ bool openRtc() {
551556
}
552557

553558
bool setRtcTime(rtc_time_t time) {
554-
R_RTC_ClockSourceSet(&rtc_ctrl);
555-
556559
if(FSP_SUCCESS == R_RTC_CalendarTimeSet(&rtc_ctrl, &time) ) {
557560
return true;
558561
}

0 commit comments

Comments
 (0)