Skip to content

Commit f66e865

Browse files
committed
Use low power RTC on mimxrt10xx (Teensy41) boards
There are apparently two RTC interfaces in the mimxrt10xx dev kit. The low power interface access the battery backed up hardware. I've tested this on the Teensy41 and it seems to fix issue #4574
1 parent 1c1cf1c commit f66e865

File tree

2 files changed

+16
-7
lines changed

2 files changed

+16
-7
lines changed

ports/mimxrt10xx/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ SRC_SDK := \
109109
drivers/fsl_ocotp.c \
110110
drivers/fsl_pwm.c \
111111
drivers/fsl_snvs_hp.c \
112+
drivers/fsl_snvs_lp.c \
112113
drivers/fsl_tempmon.c \
113114
drivers/fsl_trng.c \
114115
system_$(CHIP_FAMILY).c \

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

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -36,18 +36,26 @@
3636
#include "supervisor/shared/translate/translate.h"
3737

3838
#include "fsl_snvs_hp.h"
39+
#include "fsl_snvs_lp.h"
3940

4041
void rtc_init(void) {
41-
snvs_hp_rtc_config_t config;
42-
SNVS_HP_RTC_GetDefaultConfig(&config);
42+
snvs_hp_rtc_config_t hpconfig;
43+
SNVS_HP_RTC_GetDefaultConfig(&hpconfig);
4344

44-
SNVS_HP_RTC_Init(SNVS, &config);
45+
SNVS_HP_RTC_Init(SNVS, &hpconfig);
46+
47+
snvs_lp_srtc_config_t lpconfig;
48+
SNVS_LP_SRTC_GetDefaultConfig(&lpconfig);
49+
50+
SNVS_LP_SRTC_Init(SNVS, &lpconfig);
51+
52+
SNVS_LP_SRTC_StartTimer(SNVS);
4553
SNVS_HP_RTC_StartTimer(SNVS);
4654
}
4755

4856
void common_hal_rtc_get_time(timeutils_struct_time_t *tm) {
49-
snvs_hp_rtc_datetime_t rtcDate;
50-
SNVS_HP_RTC_GetDatetime(SNVS, &rtcDate);
57+
snvs_lp_srtc_datetime_t rtcDate;
58+
SNVS_LP_SRTC_GetDatetime(SNVS, &rtcDate);
5159

5260
tm->tm_year = rtcDate.year;
5361
tm->tm_mon = rtcDate.month;
@@ -58,15 +66,15 @@ void common_hal_rtc_get_time(timeutils_struct_time_t *tm) {
5866
}
5967

6068
void common_hal_rtc_set_time(timeutils_struct_time_t *tm) {
61-
snvs_hp_rtc_datetime_t rtcDate;
69+
snvs_lp_srtc_datetime_t rtcDate;
6270
rtcDate.year = tm->tm_year;
6371
rtcDate.month = tm->tm_mon;
6472
rtcDate.day = tm->tm_mday;
6573
rtcDate.hour = tm->tm_hour;
6674
rtcDate.minute = tm->tm_min;
6775
rtcDate.second = tm->tm_sec;
6876

69-
SNVS_HP_RTC_SetDatetime(SNVS, &rtcDate);
77+
SNVS_LP_SRTC_SetDatetime(SNVS, &rtcDate);
7078
}
7179

7280
int common_hal_rtc_get_calibration(void) {

0 commit comments

Comments
 (0)