summaryrefslogtreecommitdiff
path: root/nuttx/arch/arm/src/stm32/stm32_rtcc.c
diff options
context:
space:
mode:
Diffstat (limited to 'nuttx/arch/arm/src/stm32/stm32_rtcc.c')
-rw-r--r--nuttx/arch/arm/src/stm32/stm32_rtcc.c13
1 files changed, 12 insertions, 1 deletions
diff --git a/nuttx/arch/arm/src/stm32/stm32_rtcc.c b/nuttx/arch/arm/src/stm32/stm32_rtcc.c
index fb6dbe525..413096cb1 100644
--- a/nuttx/arch/arm/src/stm32/stm32_rtcc.c
+++ b/nuttx/arch/arm/src/stm32/stm32_rtcc.c
@@ -880,6 +880,7 @@ int up_rtc_getdatetime(FAR struct tm *tp)
* Days: 1-31 match in both cases.
* Month: STM32 is 1-12, struct tm is 0-11.
* Years: STM32 is 00-99, struct tm is years since 1900.
+ * WeekDay: STM32 is 1 = Mon - 7 = Sun
*
* Issue: I am not sure what the STM32 years mean. Are these the
* years 2000-2099? I'll assume so.
@@ -894,6 +895,12 @@ int up_rtc_getdatetime(FAR struct tm *tp)
tmp = (dr & (RTC_DR_YU_MASK|RTC_DR_YT_MASK)) >> RTC_DR_YU_SHIFT;
tp->tm_year = rtc_bcd2bin(tmp) + 100;
+#if defined(CONFIG_TIME_EXTENDED)
+ tmp = (dr & RTC_DR_WDU_MASK) >> RTC_DR_WDU_SHIFT;
+ tp->tm_wday = tmp % 7;
+ tp->tm_yday = tp->tm_mday + clock_daysbeforemonth(tp->tm_mon, clock_isleapyear(tp->tm_year + 1900));
+ tp->tm_isdst = 0
+#endif
#ifdef CONFIG_STM32_HAVE_RTC_SUBSECONDS
/* Return RTC sub-seconds if no configured and if a non-NULL value
* of nsec has been provided to receive the sub-second value.
@@ -992,14 +999,18 @@ int stm32_rtc_setdatetime(FAR const struct tm *tp)
* Days: 1-31 match in both cases.
* Month: STM32 is 1-12, struct tm is 0-11.
* Years: STM32 is 00-99, struct tm is years since 1900.
- *
+ * WeekDay: STM32 is 1 = Mon - 7 = Sun
* Issue: I am not sure what the STM32 years mean. Are these the
* years 2000-2099? I'll assume so.
*/
dr = (rtc_bin2bcd(tp->tm_mday) << RTC_DR_DU_SHIFT) |
((rtc_bin2bcd(tp->tm_mon + 1)) << RTC_DR_MU_SHIFT) |
+#if defined(CONFIG_TIME_EXTENDED)
+ ((tp->tm_wday == 0 ? 7 : (tp->tm_wday & 7)) << RTC_DR_WDU_SHIFT) |
+#endif
((rtc_bin2bcd(tp->tm_year - 100)) << RTC_DR_YU_SHIFT);
+
dr &= ~RTC_DR_RESERVED_BITS;
/* Disable the write protection for RTC registers */