From da71f0855835ec88ce056dfd9a7ed6932f567992 Mon Sep 17 00:00:00 2001
From: gdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4>
Date: Mon, 28 Jul 2014 12:11:55 +0000
Subject: Fixed bug #518.

git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@7104 35acf78f-673a-0410-8e92-d51de3d6d3f4
---
 os/hal/ports/STM32/LLD/RTCv2/rtc_lld.c   | 7 +++----
 os/hal/ports/STM32/STM32L1xx/platform.mk | 2 ++
 2 files changed, 5 insertions(+), 4 deletions(-)

(limited to 'os')

diff --git a/os/hal/ports/STM32/LLD/RTCv2/rtc_lld.c b/os/hal/ports/STM32/LLD/RTCv2/rtc_lld.c
index 0e6e1ce82..5d38c635c 100644
--- a/os/hal/ports/STM32/LLD/RTCv2/rtc_lld.c
+++ b/os/hal/ports/STM32/LLD/RTCv2/rtc_lld.c
@@ -132,8 +132,7 @@ static void rtc_decode_time(uint32_t tr, RTCDateTime *timespec) {
  */
 static void rtc_decode_date(uint32_t dr, RTCDateTime *timespec) {
 
-  timespec->year  = RTC_BASE_YEAR +
-                    (((dr >> RTC_DR_YT_OFFSET) & 15) * 10) +
+  timespec->year  = (((dr >> RTC_DR_YT_OFFSET) & 15) * 10) +
                      ((dr >> RTC_DR_YU_OFFSET) & 15);
   timespec->month = (((dr >> RTC_TR_MNT_OFFSET) & 1) * 10) +
                      ((dr >> RTC_TR_MNU_OFFSET) & 15);
@@ -188,7 +187,7 @@ static uint32_t rtc_encode_date(const RTCDateTime *timespec) {
   uint32_t n, dr = 0;
 
   /* Year conversion. Note, only years last two digits are considered.*/
-  n = RTC_BASE_YEAR + timespec->year;
+  n = timespec->year;
   dr = dr | ((n % 10) << RTC_DR_YU_OFFSET);
   n /= 10;
   dr = dr | ((n % 10) << RTC_DR_YT_OFFSET);
@@ -293,7 +292,7 @@ void rtc_lld_get_time(RTCDriver *rtcp, RTCDateTime *timespec) {
   /* If the RTC is capable of sub-second counting then the value is
      normalized in milliseconds and added to the time.*/
 #if STM32_RTC_HAS_SUBSECONDS
-  subs = (((rtcp->rtc->SSR << 16) / STM32_RTC_PRESS_VALUE) * 1000) >> 16);
+  subs = (((rtcp->rtc->SSR << 16) / STM32_RTC_PRESS_VALUE) * 1000) >> 16;
 #else
   subs = 0;
 #endif /* STM32_RTC_HAS_SUBSECONDS */
diff --git a/os/hal/ports/STM32/STM32L1xx/platform.mk b/os/hal/ports/STM32/STM32L1xx/platform.mk
index adf6de40f..a63643be9 100644
--- a/os/hal/ports/STM32/STM32L1xx/platform.mk
+++ b/os/hal/ports/STM32/STM32L1xx/platform.mk
@@ -10,6 +10,7 @@ PLATFORMSRC = ${CHIBIOS}/os/hal/ports/common/ARMCMx/nvic.c \
               ${CHIBIOS}/os/hal/ports/STM32/LLD/SPIv1/spi_lld.c \
               ${CHIBIOS}/os/hal/ports/STM32/LLD/TIMv1/gpt_lld.c \
               ${CHIBIOS}/os/hal/ports/STM32/LLD/TIMv1/icu_lld.c \
+              ${CHIBIOS}/os/hal/ports/STM32/LLD/RTCv2/rtc_lld.c \
               ${CHIBIOS}/os/hal/ports/STM32/LLD/TIMv1/pwm_lld.c \
               ${CHIBIOS}/os/hal/ports/STM32/LLD/TIMv1/st_lld.c \
               ${CHIBIOS}/os/hal/ports/STM32/LLD/USARTv1/serial_lld.c \
@@ -22,6 +23,7 @@ PLATFORMINC = ${CHIBIOS}/os/hal/ports/common/ARMCMx \
               ${CHIBIOS}/os/hal/ports/STM32/LLD \
               ${CHIBIOS}/os/hal/ports/STM32/LLD/GPIOv2 \
               ${CHIBIOS}/os/hal/ports/STM32/LLD/I2Cv1 \
+              ${CHIBIOS}/os/hal/ports/STM32/LLD/RTCv2 \
               ${CHIBIOS}/os/hal/ports/STM32/LLD/SPIv1 \
               ${CHIBIOS}/os/hal/ports/STM32/LLD/TIMv1 \
               ${CHIBIOS}/os/hal/ports/STM32/LLD/USARTv1 \
-- 
cgit v1.2.3