summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGregory Nutt <gnutt@nuttx.org>2015-02-13 13:36:15 -0600
committerGregory Nutt <gnutt@nuttx.org>2015-02-13 13:36:15 -0600
commit4bac7ce0209a23605a6ec833527ff18ec3e68400 (patch)
treeec14345b6064c5d9ce98da4623488aced83f59d4
parent9a5662c5298351941c747823115472b3d1c02879 (diff)
downloadnuttx-4bac7ce0209a23605a6ec833527ff18ec3e68400.tar.gz
nuttx-4bac7ce0209a23605a6ec833527ff18ec3e68400.tar.bz2
nuttx-4bac7ce0209a23605a6ec833527ff18ec3e68400.zip
STM32 RTC driver lower half: Implement the settime method of the RTC interface
-rw-r--r--nuttx/arch/arm/src/stm32/stm32_rtc.h2
-rw-r--r--nuttx/arch/arm/src/stm32/stm32_rtc_lowerhalf.c42
-rw-r--r--nuttx/include/nuttx/rtc.h3
3 files changed, 42 insertions, 5 deletions
diff --git a/nuttx/arch/arm/src/stm32/stm32_rtc.h b/nuttx/arch/arm/src/stm32/stm32_rtc.h
index 0021aa2c4..095b2f838 100644
--- a/nuttx/arch/arm/src/stm32/stm32_rtc.h
+++ b/nuttx/arch/arm/src/stm32/stm32_rtc.h
@@ -181,7 +181,7 @@ int stm32_rtc_cancelalarm(void);
#ifdef CONFIG_RTC_DRIVER
struct rtc_lower_half_s;
-struct rtc_lower_half_s *stm32_rtc_lowerhalf(void);
+FAR struct rtc_lower_half_s *stm32_rtc_lowerhalf(void);
#endif
#undef EXTERN
diff --git a/nuttx/arch/arm/src/stm32/stm32_rtc_lowerhalf.c b/nuttx/arch/arm/src/stm32/stm32_rtc_lowerhalf.c
index 394d95e4e..ff300c6a4 100644
--- a/nuttx/arch/arm/src/stm32/stm32_rtc_lowerhalf.c
+++ b/nuttx/arch/arm/src/stm32/stm32_rtc_lowerhalf.c
@@ -77,7 +77,11 @@ struct stm32_lowerhalf_s
* Private Function Prototypes
****************************************************************************/
/* Prototypes for static methods in struct rtc_ops_s */
-/* To be provided */
+
+#ifdef CONFIG_RTC_DATETIME
+static int stm32_settime(FAR struct rtc_lowerhalf_s *lower,
+ FAR const struct rtc_time *rtctime);
+#endif
/****************************************************************************
* Private Data
@@ -87,7 +91,11 @@ struct stm32_lowerhalf_s
static const struct rtc_ops_s g_rtc_ops =
{
.rdtime = NULL,
+#ifdef CONFIG_RTC_DATETIME
+ .settime = stm32_settime,
+#else
.settime = NULL,
+#endif
.almread = NULL,
.almset = NULL,
.irqpread = NULL,
@@ -114,6 +122,34 @@ static struct stm32_lowerhalf_s g_rtc_lowerhalf =
****************************************************************************/
/****************************************************************************
+ * Name: stm32_settime
+ *
+ * Description:
+ * Implements the settime() method of the RTC driver interface
+ *
+ * Input Parameters:
+ * lower - A reference to RTC lower half driver state structure
+ * rcttime - The new time to set
+ *
+ * Returned Value:
+ * Zero (OK) is returned on success; a negated errno value is returned
+ * on any failure.
+ *
+ ****************************************************************************/
+
+#ifdef CONFIG_RTC_DATETIME
+static int stm32_settime(FAR struct rtc_lowerhalf_s *lower,
+ FAR const struct rtc_time *rtctime)
+{
+ /* This operation depends on the fact that struct rtc_time is cast
+ * compatible with struct tm.
+ */
+
+ return stm32_rtc_setdatetime((FAR const struct tm *)rtctime);
+}
+#endif
+
+/****************************************************************************
* Public Functions
****************************************************************************/
@@ -139,9 +175,9 @@ static struct stm32_lowerhalf_s g_rtc_lowerhalf =
*
****************************************************************************/
-struct rtc_lower_half_s *stm32_rtc_lowerhalf(void)
+FAR struct rtc_lower_half_s *stm32_rtc_lowerhalf(void)
{
- return (struct rtc_lower_half_s *)&g_rtc_lowerhalf;
+ return (FAR struct rtc_lower_half_s *)&g_rtc_lowerhalf;
}
#endif /* CONFIG_RTC_DRIVER */
diff --git a/nuttx/include/nuttx/rtc.h b/nuttx/include/nuttx/rtc.h
index 213fbd90c..1c30d2a33 100644
--- a/nuttx/include/nuttx/rtc.h
+++ b/nuttx/include/nuttx/rtc.h
@@ -269,7 +269,8 @@
/* Broken-out time representation used with RTC IOCTL commands:
*
* The fields in this structure have the same meaning and ranges as for the
- * tm structure described in gmtime().
+ * tm structure described in gmtime(). Further, it is REQUIRED that the
+ * structure be cast compatible with struct tm! They must be interchangeable.
*/
struct rtc_time