From f4e7e14e0001a05014fbc9ac1adce4aea7f90783 Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Fri, 13 Feb 2015 13:56:22 -0600 Subject: [PATCH] STM32 RTC: Implement the rdtime() method of the RTC lower half interface --- arch/arm/src/stm32/stm32_rtc_lowerhalf.c | 34 +++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) diff --git a/arch/arm/src/stm32/stm32_rtc_lowerhalf.c b/arch/arm/src/stm32/stm32_rtc_lowerhalf.c index ff300c6a4c..0d3fd8e860 100644 --- a/arch/arm/src/stm32/stm32_rtc_lowerhalf.c +++ b/arch/arm/src/stm32/stm32_rtc_lowerhalf.c @@ -42,6 +42,7 @@ #include #include +#include #include #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, @@ -121,6 +125,34 @@ static struct stm32_lowerhalf_s g_rtc_lowerhalf = * Private Functions ****************************************************************************/ +/**************************************************************************** + * 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 *