Skip to content

Commit 4e5611c

Browse files
robert-hhdpgeorge
authored andcommitted
mimxrt/machine_rtc: Improve the RTC init at boot.
By clearing the tamper bits and enabling access to the registers for all code, just in case that this was set. It keeps the clock running on battery and the calibration setting. Signed-off-by: robert-hh <robert@hammelrath.com>
1 parent 6482eb1 commit 4e5611c

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

ports/mimxrt/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,7 @@ SRC_HAL_IMX_C += \
137137
$(MCU_DIR)/drivers/fsl_pit.c \
138138
$(MCU_DIR)/drivers/fsl_pwm.c \
139139
$(MCU_DIR)/drivers/fsl_sai.c \
140+
$(MCU_DIR)/drivers/fsl_snvs_hp.c \
140141
$(MCU_DIR)/drivers/fsl_snvs_lp.c \
141142
$(MCU_DIR)/drivers/fsl_wdog.c \
142143
$(MCU_DIR)/system_$(MCU_SERIES)$(MCU_CORE).c \

ports/mimxrt/machine_rtc.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
#include "modmachine.h"
3131
#include "ticks.h"
3232
#include "fsl_snvs_lp.h"
33+
#include "fsl_snvs_hp.h"
3334

3435
typedef struct _machine_rtc_obj_t {
3536
mp_obj_base_t base;
@@ -41,6 +42,12 @@ STATIC const machine_rtc_obj_t machine_rtc_obj = {{&machine_rtc_type}};
4142

4243
// Start the RTC Timer.
4344
void machine_rtc_start(void) {
45+
// Enable Non-Privileged Software Access
46+
SNVS->HPCOMR |= SNVS_HPCOMR_NPSWA_EN_MASK;
47+
// Do a basic init.
48+
SNVS_LP_Init(SNVS);
49+
// Disable all external Tamper
50+
SNVS_LP_DisableAllExternalTamper(SNVS);
4451

4552
SNVS_LP_SRTC_StartTimer(SNVS);
4653
// If the date is not set, set it to a more recent start date,

0 commit comments

Comments
 (0)