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.

This commit is contained in:
anschrammh 2023-03-24 15:02:22 +01:00
parent 061fdb729b
commit b31cc96c10
2 changed files with 19 additions and 0 deletions

View File

@ -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
*

View File

@ -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 */