STM32 RTC: Implement the rdtime() method of the RTC lower half interface

This commit is contained in:
Gregory Nutt 2015-02-13 13:56:22 -06:00
parent 8cb4b8c101
commit f4e7e14e00

View File

@ -42,6 +42,7 @@
#include <sys/types.h> #include <sys/types.h>
#include <stdbool.h> #include <stdbool.h>
#include <nuttx/arch.h>
#include <nuttx/rtc.h> #include <nuttx/rtc.h>
#include "chip.h" #include "chip.h"
@ -79,6 +80,8 @@ struct stm32_lowerhalf_s
/* Prototypes for static methods in struct rtc_ops_s */ /* Prototypes for static methods in struct rtc_ops_s */
#ifdef CONFIG_RTC_DATETIME #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, static int stm32_settime(FAR struct rtc_lowerhalf_s *lower,
FAR const struct rtc_time *rtctime); FAR const struct rtc_time *rtctime);
#endif #endif
@ -90,10 +93,11 @@ static int stm32_settime(FAR struct rtc_lowerhalf_s *lower,
static const struct rtc_ops_s g_rtc_ops = static const struct rtc_ops_s g_rtc_ops =
{ {
.rdtime = NULL,
#ifdef CONFIG_RTC_DATETIME #ifdef CONFIG_RTC_DATETIME
.rdtime = stm32_rdtime,
.settime = stm32_settime, .settime = stm32_settime,
#else #else
.rdtime = NULL,
.settime = NULL, .settime = NULL,
#endif #endif
.almread = NULL, .almread = NULL,
@ -121,6 +125,34 @@ static struct stm32_lowerhalf_s g_rtc_lowerhalf =
* Private Functions * 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 * Name: stm32_settime
* *