From b31cc96c10887fd7d02a8a539baec423fcd0aa44 Mon Sep 17 00:00:00 2001 From: anschrammh Date: Fri, 24 Mar 2023 15:02:22 +0100 Subject: [PATCH] Added the tls_is_rtc_running function which is not part of the official SDK. This allows to start the RTC after a reset and to know when it stopped running. --- src/W800_SDK_v1.00.10/include/driver/wm_rtc.h | 12 ++++++++++++ src/W800_SDK_v1.00.10/platform/drivers/rtc/wm_rtc.c | 7 +++++++ 2 files changed, 19 insertions(+) diff --git a/src/W800_SDK_v1.00.10/include/driver/wm_rtc.h b/src/W800_SDK_v1.00.10/include/driver/wm_rtc.h index 513f21b..d352010 100644 --- a/src/W800_SDK_v1.00.10/include/driver/wm_rtc.h +++ b/src/W800_SDK_v1.00.10/include/driver/wm_rtc.h @@ -58,6 +58,18 @@ void tls_set_rtc(struct tm *tblock); */ void tls_get_rtc(struct tm *tblock); +/** NOT PART OF THE OFFICIAL SDK **/ + +/** + * @brief Checks if the RTC peripheral is running or not + * + * @return true + * @return false + */ +bool tls_is_rtc_running(void); + +/**********************************/ + /** * @brief This function is used to register pmu rtc interrupt * diff --git a/src/W800_SDK_v1.00.10/platform/drivers/rtc/wm_rtc.c b/src/W800_SDK_v1.00.10/platform/drivers/rtc/wm_rtc.c index 7e947af..cd4d1fc 100644 --- a/src/W800_SDK_v1.00.10/platform/drivers/rtc/wm_rtc.c +++ b/src/W800_SDK_v1.00.10/platform/drivers/rtc/wm_rtc.c @@ -82,6 +82,13 @@ void tls_get_rtc(struct tm *tblock) tblock->tm_sec = ctrl1 & 0x0000003f; } +bool tls_is_rtc_running(void) +{ + int ctrl2 = tls_reg_read32(HR_PMU_RTC_CTRL2); + + return ctrl2 & (1 << 16) ? true : false; +} + void PMU_RTC_IRQHandler(void) { tls_reg_write32(HR_PMU_INTERRUPT_SRC, BIT(4)); /* clear rtc interrupt */