aboutsummaryrefslogtreecommitdiff
path: root/stmhal/modutime.c
diff options
context:
space:
mode:
Diffstat (limited to 'stmhal/modutime.c')
-rw-r--r--stmhal/modutime.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/stmhal/modutime.c b/stmhal/modutime.c
index 889229558..8502e0fd6 100644
--- a/stmhal/modutime.c
+++ b/stmhal/modutime.c
@@ -57,6 +57,7 @@ STATIC mp_obj_t time_localtime(mp_uint_t n_args, const mp_obj_t *args) {
if (n_args == 0 || args[0] == mp_const_none) {
// get current date and time
// note: need to call get time then get date to correctly access the registers
+ rtc_init_finalise();
RTC_DateTypeDef date;
RTC_TimeTypeDef time;
HAL_RTC_GetTime(&RTCHandle, &time, FORMAT_BIN);
@@ -119,6 +120,7 @@ MP_DEFINE_CONST_FUN_OBJ_1(time_mktime_obj, time_mktime);
STATIC mp_obj_t time_time(void) {
// get date and time
// note: need to call get time then get date to correctly access the registers
+ rtc_init_finalise();
RTC_DateTypeDef date;
RTC_TimeTypeDef time;
HAL_RTC_GetTime(&RTCHandle, &time, FORMAT_BIN);