arch: S32K/Kinetis: Fix RTC settime prescaler

This commit is contained in:
Peter van der Perk
2020-12-28 12:58:44 +01:00
committed by Abdelatif Guettouche
parent 10adf76209
commit 673a4b5b39
2 changed files with 27 additions and 27 deletions
+6 -6
View File
@@ -209,7 +209,7 @@ static int kinetis_rtc_interrupt(int irq, void *context, FAR void *arg)
#endif #endif
/**************************************************************************** /****************************************************************************
* Name: RTC_Reset * Name: rtc_reset
* *
* Description: * Description:
* Reset the RTC to known state * Reset the RTC to known state
@@ -222,7 +222,7 @@ static int kinetis_rtc_interrupt(int irq, void *context, FAR void *arg)
* *
****************************************************************************/ ****************************************************************************/
static inline void RTC_Reset(void) static inline void rtc_reset(void)
{ {
putreg32((RTC_CR_SWR | getreg32(KINETIS_RTC_CR)), KINETIS_RTC_CR); putreg32((RTC_CR_SWR | getreg32(KINETIS_RTC_CR)), KINETIS_RTC_CR);
putreg32((~RTC_CR_SWR & getreg32(KINETIS_RTC_CR)), KINETIS_RTC_CR); putreg32((~RTC_CR_SWR & getreg32(KINETIS_RTC_CR)), KINETIS_RTC_CR);
@@ -343,7 +343,7 @@ int up_rtc_initialize(void)
else else
{ {
rtcinfo("Do setup\n"); rtcinfo("Do setup\n");
RTC_Reset(); rtc_reset();
#ifdef KINETIS_RTC_GEN2 #ifdef KINETIS_RTC_GEN2
/* Configure the RTC to be initialized */ /* Configure the RTC to be initialized */
@@ -489,7 +489,7 @@ int up_rtc_settime(FAR const struct timespec *tp)
uint32_t prescaler; uint32_t prescaler;
seconds = tp->tv_sec; seconds = tp->tv_sec;
prescaler = tp->tv_nsec * (CONFIG_RTC_FREQUENCY / 1000000000); prescaler = tp->tv_nsec / (1000000000 / CONFIG_RTC_FREQUENCY);
flags = enter_critical_section(); flags = enter_critical_section();
@@ -587,7 +587,7 @@ int kinetis_rtc_cancelalarm(void)
} }
#endif #endif
/************************************************************************************ /****************************************************************************
* Name: kinetis_rtc_rdalarm * Name: kinetis_rtc_rdalarm
* *
* Description: * Description:
@@ -599,7 +599,7 @@ int kinetis_rtc_cancelalarm(void)
* Returned Value: * Returned Value:
* Zero (OK) on success; a negated errno on failure * Zero (OK) on success; a negated errno on failure
* *
************************************************************************************/ ****************************************************************************/
#ifdef CONFIG_RTC_ALARM #ifdef CONFIG_RTC_ALARM
int kinetis_rtc_rdalarm(FAR struct timespec *tp) int kinetis_rtc_rdalarm(FAR struct timespec *tp)
+1 -1
View File
@@ -304,7 +304,7 @@ int up_rtc_settime(FAR const struct timespec *ts)
seconds = ts->tv_sec; seconds = ts->tv_sec;
#ifdef CONFIG_RTC_HIRES #ifdef CONFIG_RTC_HIRES
prescaler = ts->tv_nsec * (CONFIG_RTC_FREQUENCY / 1000000000); prescaler = ts->tv_nsec / (1000000000 / CONFIG_RTC_FREQUENCY);
#else #else
prescaler = 0; prescaler = 0;
#endif #endif