Skip to content

Commit 15e97f1

Browse files
authored
Merge pull request #4379 from jepler/rp2040-rtc
raspberrypi: RTC: Ensure a time is set
2 parents f0965b1 + 16bfe3b commit 15e97f1

File tree

1 file changed

+14
-0
lines changed
  • ports/raspberrypi/common-hal/rtc

1 file changed

+14
-0
lines changed

ports/raspberrypi/common-hal/rtc/RTC.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,23 @@
2929

3030
#include "py/runtime.h"
3131
#include "src/rp2_common/hardware_rtc/include/hardware/rtc.h"
32+
#include "src/rp2_common/hardware_clocks/include/hardware/clocks.h"
3233

3334
void common_hal_rtc_init(void) {
35+
datetime_t t = {
36+
.year = 2020,
37+
.month = 1,
38+
.day = 1,
39+
.dotw = 3, // 0 is Sunday, so 3 is Wednesday
40+
.hour = 0,
41+
.min = 0,
42+
.sec = 0
43+
};
44+
45+
// Start the RTC
3446
rtc_init();
47+
rtc_set_datetime(&t);
48+
3549
}
3650

3751
void common_hal_rtc_get_time(timeutils_struct_time_t *tm) {

0 commit comments

Comments
 (0)