Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

raspberrypi: RTC: Ensure a time is set #4379

Merged
merged 1 commit into from
Mar 11, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions ports/raspberrypi/common-hal/rtc/RTC.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,23 @@

#include "py/runtime.h"
#include "src/rp2_common/hardware_rtc/include/hardware/rtc.h"
#include "src/rp2_common/hardware_clocks/include/hardware/clocks.h"

void common_hal_rtc_init(void) {
datetime_t t = {
.year = 2020,
.month = 1,
.day = 1,
.dotw = 3, // 0 is Sunday, so 3 is Wednesday
.hour = 0,
.min = 0,
.sec = 0
};

// Start the RTC
rtc_init();
rtc_set_datetime(&t);

}

void common_hal_rtc_get_time(timeutils_struct_time_t *tm) {
Expand Down