From 633cc9be98102aaf6e6ea07775f1b41f6c4fad2e Mon Sep 17 00:00:00 2001 From: gdisirio Date: Mon, 22 Dec 2014 09:19:37 +0000 Subject: Fixed STM32 RTCv1 initialization problem. git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@7592 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- os/hal/ports/STM32/LLD/RTCv1/rtc_lld.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'os/hal/ports/STM32') diff --git a/os/hal/ports/STM32/LLD/RTCv1/rtc_lld.c b/os/hal/ports/STM32/LLD/RTCv1/rtc_lld.c index 1d02c353b..37fca80c1 100644 --- a/os/hal/ports/STM32/LLD/RTCv1/rtc_lld.c +++ b/os/hal/ports/STM32/LLD/RTCv1/rtc_lld.c @@ -60,7 +60,8 @@ RTCDriver RTCD1; * @notapi */ static void rtc_apb1_sync(void) { - while ((RTCD1.rtc->CRL & RTC_CRL_RSF) == 0) + + while ((RTC->CRL & RTC_CRL_RSF) == 0) ; } @@ -71,7 +72,8 @@ static void rtc_apb1_sync(void) { * @notapi */ static void rtc_wait_write_completed(void) { - while ((RTCD1.rtc->CRL & RTC_CRL_RTOFF) == 0) + + while ((RTC->CRL & RTC_CRL_RTOFF) == 0) ; } @@ -84,8 +86,9 @@ static void rtc_wait_write_completed(void) { * @notapi */ static void rtc_acquire_access(void) { + rtc_wait_write_completed(); - RTCD1.rtc->CRL |= RTC_CRL_CNF; + RTC->CRL |= RTC_CRL_CNF; } /** @@ -94,7 +97,8 @@ static void rtc_acquire_access(void) { * @notapi */ static void rtc_release_access(void) { - RTCD1.rtc->CRL &= ~RTC_CRL_CNF; + + RTC->CRL &= ~RTC_CRL_CNF; } /** @@ -189,8 +193,8 @@ void rtc_lld_set_prescaler(void) { sts = chSysGetStatusAndLockX(); rtc_acquire_access(); - RTCD1.rtc->PRLH = (uint16_t)((STM32_RTCCLK - 1) >> 16) & 0x000F; - RTCD1.rtc->PRLL = (uint16_t)(((STM32_RTCCLK - 1)) & 0xFFFF); + RTC->PRLH = (uint16_t)((STM32_RTCCLK - 1) >> 16) & 0x000F; + RTC->PRLL = (uint16_t)(((STM32_RTCCLK - 1)) & 0xFFFF); rtc_release_access(); /* Leaving a reentrant critical zone.*/ -- cgit v1.2.3