summaryrefslogtreecommitdiff
path: root/nuttx/arch/arm
diff options
context:
space:
mode:
authorGregory Nutt <gnutt@nuttx.org>2015-02-13 13:56:22 -0600
committerGregory Nutt <gnutt@nuttx.org>2015-02-13 13:56:22 -0600
commitf32a6053b427c5490a225aa2504d41acf50de8f0 (patch)
treee31702b4e09bd90fa1a2e2ab1a721dee9a21e285 /nuttx/arch/arm
parent8eaf8c0dd5573f1a909e159567e17bc759d9771c (diff)
downloadnuttx-f32a6053b427c5490a225aa2504d41acf50de8f0.tar.gz
nuttx-f32a6053b427c5490a225aa2504d41acf50de8f0.tar.bz2
nuttx-f32a6053b427c5490a225aa2504d41acf50de8f0.zip
STM32 RTC: Implement the rdtime() method of the RTC lower half interface
Diffstat (limited to 'nuttx/arch/arm')
-rw-r--r--nuttx/arch/arm/src/stm32/stm32_rtc_lowerhalf.c34
1 files changed, 33 insertions, 1 deletions
diff --git a/nuttx/arch/arm/src/stm32/stm32_rtc_lowerhalf.c b/nuttx/arch/arm/src/stm32/stm32_rtc_lowerhalf.c
index ff300c6a4..0d3fd8e86 100644
--- a/nuttx/arch/arm/src/stm32/stm32_rtc_lowerhalf.c
+++ b/nuttx/arch/arm/src/stm32/stm32_rtc_lowerhalf.c
@@ -42,6 +42,7 @@
#include <sys/types.h>
#include <stdbool.h>
+#include <nuttx/arch.h>
#include <nuttx/rtc.h>
#include "chip.h"
@@ -79,6 +80,8 @@ struct stm32_lowerhalf_s
/* Prototypes for static methods in struct rtc_ops_s */
#ifdef CONFIG_RTC_DATETIME
+static int stm32_rdtime(FAR struct rtc_lowerhalf_s *lower,
+ FAR struct rtc_time *rtctime);
static int stm32_settime(FAR struct rtc_lowerhalf_s *lower,
FAR const struct rtc_time *rtctime);
#endif
@@ -90,10 +93,11 @@ static int stm32_settime(FAR struct rtc_lowerhalf_s *lower,
static const struct rtc_ops_s g_rtc_ops =
{
- .rdtime = NULL,
#ifdef CONFIG_RTC_DATETIME
+ .rdtime = stm32_rdtime,
.settime = stm32_settime,
#else
+ .rdtime = NULL,
.settime = NULL,
#endif
.almread = NULL,
@@ -122,6 +126,34 @@ static struct stm32_lowerhalf_s g_rtc_lowerhalf =
****************************************************************************/
/****************************************************************************
+ * Name: stm32_rdtime
+ *
+ * Description:
+ * Implements the rdtime() method of the RTC driver interface
+ *
+ * Input Parameters:
+ * lower - A reference to RTC lower half driver state structure
+ * rcttime - The location in which to return the current RTC time.
+ *
+ * Returned Value:
+ * Zero (OK) is returned on success; a negated errno value is returned
+ * on any failure.
+ *
+ ****************************************************************************/
+
+#ifdef CONFIG_RTC_DATETIME
+static int stm32_rdtime(FAR struct rtc_lowerhalf_s *lower,
+ FAR struct rtc_time *rtctime)
+{
+ /* This operation depends on the fact that struct rtc_time is cast
+ * compatible with struct tm.
+ */
+
+ return up_rtc_getdatetime((FAR struct tm *)rtctime);
+}
+#endif
+
+/****************************************************************************
* Name: stm32_settime
*
* Description: