RTC: Remove all backdoor interfaces from rtc.h

This commit is contained in:
Gregory Nutt 2015-02-13 08:41:34 -06:00
parent d52482606e
commit 3724a5e98e
24 changed files with 322 additions and 230 deletions

View File

@ -2380,9 +2380,6 @@ else
Set the RTC to the provided time.
All RTC implementations must be able to set their time based on a standard timespec.
</li>
<li><code>up_rtc_setalarm()</code>.
Set up an alarm.
</li>
</ul>
<h3><a name="systcktime">4.3.3 System Tick and Time</a></h3>

View File

@ -55,6 +55,7 @@
#include "chip/efm32_burtc.h"
#include "efm32_rmu.h"
#include "efm32_rtc.h"
#include "clock/clock.h"
/************************************************************************************
@ -496,7 +497,7 @@ int up_rtc_settime(FAR const struct timespec *tp)
}
/************************************************************************************
* Name: up_rtc_setalarm
* Name: efm32_rtc_setalarm
*
* Description:
* Set up an alarm.
@ -512,7 +513,7 @@ int up_rtc_settime(FAR const struct timespec *tp)
#ifdef CONFIG_RTC_ALARM
#error "Sorry ! not yet implemented, just copied from STM32"
int up_rtc_setalarm(FAR const struct timespec *tp, alarmcb_t callback)
int efm32_rtc_setalarm(FAR const struct timespec *tp, alarmcb_t callback)
{
struct rtc_regvals_s regvals;
irqstate_t flags;
@ -529,7 +530,7 @@ int up_rtc_setalarm(FAR const struct timespec *tp, alarmcb_t callback)
/* Break out the time values */
up_rtc_breakout(tp, &regvals);
efm32_rtc_breakout(tp, &regvals);
/* Enable RTC alarm */
@ -554,7 +555,7 @@ int up_rtc_setalarm(FAR const struct timespec *tp, alarmcb_t callback)
#endif
/************************************************************************************
* Name: up_rtc_cancelalarm
* Name: efm32_rtc_cancelalarm
*
* Description:
* Cancel a pending alarm alarm
@ -569,7 +570,7 @@ int up_rtc_setalarm(FAR const struct timespec *tp, alarmcb_t callback)
#ifdef CONFIG_RTC_ALARM
#error "Sorry ! not yet implemented, just copied from STM32"
int up_rtc_cancelalarm(void)
int efm32_rtc_cancelalarm(void)
{
irqstate_t flags;
int ret = -ENODATA;

View File

@ -39,14 +39,13 @@
#include <nuttx/config.h>
#include <nuttx/arch.h>
#include <nuttx/irq.h>
#include <nuttx/rtc.h>
#include <time.h>
#include <errno.h>
#include <debug.h>
#include <nuttx/arch.h>
#include <nuttx/irq.h>
#include <arch/board/board.h>
#include "up_arch.h"
@ -403,7 +402,7 @@ int up_rtc_settime(FAR const struct timespec *tp)
}
/************************************************************************************
* Name: up_rtc_setalarm
* Name: lpc17_rtc_setalarm
*
* Description:
* Set up an alarm. Up to two alarms can be supported (ALARM A and ALARM B).
@ -418,7 +417,7 @@ int up_rtc_settime(FAR const struct timespec *tp)
************************************************************************************/
#ifdef CONFIG_RTC_ALARM
int up_rtc_setalarm(FAR const struct timespec *tp, alarmcb_t callback)
int lpc17_rtc_setalarm(FAR const struct timespec *tp, alarmcb_t callback)
{
int ret = -EBUSY;

View File

@ -1,7 +1,7 @@
/************************************************************************************
* arch/arm/src/lpc17xx/lpc17_rtc.h
*
* Copyright (C) 2010, 2012-2013 Gregory Nutt. All rights reserved.
* Copyright (C) 2010, 2012-2013, 2015 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
@ -51,6 +51,10 @@
* Public Types
************************************************************************************/
/* The form of an alarm callback */
typedef void (*alarmcb_t)(void);
/************************************************************************************
* Public Data
************************************************************************************/
@ -59,4 +63,24 @@
* Public Functions
************************************************************************************/
/************************************************************************************
* Name: lpc17_rtc_setalarm
*
* Description:
* Set up an alarm.
*
* Input Parameters:
* tp - the time to set the alarm
* callback - the function to call when the alarm expires.
*
* Returned Value:
* Zero (OK) on success; a negated errno on failure
*
************************************************************************************/
#ifdef CONFIG_RTC_ALARM
struct timespec;
int lpc17_rtc_setalarm(FAR const struct timespec *tp, alarmcb_t callback);
#endif
#endif /* __ARCH_ARM_SRC_LPC17XX_LPC17_RTC_H */

View File

@ -40,15 +40,14 @@
#include <nuttx/config.h>
#include <nuttx/arch.h>
#include <nuttx/irq.h>
#include <nuttx/rtc.h>
#include <time.h>
#include <errno.h>
#include <debug.h>
#include <nuttx/arch.h>
#include <nuttx/irq.h>
#include <nuttx/wqueue.h>
#include <arch/board/board.h>
#include "up_arch.h"
@ -651,7 +650,7 @@ int up_rtc_settime(FAR const struct timespec *tp)
}
/************************************************************************************
* Name: up_rtc_setalarm
* Name: sam_rtc_setalarm
*
* Description:
* Set up an alarm. Up to two alarms can be supported (ALARM A and ALARM B).
@ -666,7 +665,7 @@ int up_rtc_settime(FAR const struct timespec *tp)
************************************************************************************/
#ifdef CONFIG_RTC_ALARM
int up_rtc_setalarm(FAR const struct timespec *tp, alarmcb_t callback)
int sam_rtc_setalarm(FAR const struct timespec *tp, alarmcb_t callback)
{
FAR struct tm newalarm;
irqstate_t flags;

View File

@ -1,7 +1,7 @@
/************************************************************************************
* arch/arm/src/sam34/sam_rtc.h
*
* Copyright (C) 2014 Gregory Nutt. All rights reserved.
* Copyright (C) 2014-2015 Gregory Nutt. All rights reserved.
* Authors: Gregory Nutt <gnutt@nuttx.org>
* Bob Doiron
*
@ -50,12 +50,25 @@
* Pre-processor Definitions
************************************************************************************/
/************************************************************************************
* Public Types
************************************************************************************/
#ifndef __ASSEMBLY__
/* The form of an alarm callback */
typedef void (*alarmcb_t)(void);
/************************************************************************************
* Public Data
************************************************************************************/
#undef EXTERN
#if defined(__cplusplus)
#define EXTERN extern "C"
extern "C" {
extern "C"
{
#else
#define EXTERN extern
#endif
@ -64,6 +77,26 @@ extern "C" {
* Public Functions
************************************************************************************/
/************************************************************************************
* Name: sam_rtc_setalarm
*
* Description:
* Set up an alarm.
*
* Input Parameters:
* tp - the time to set the alarm
* callback - the function to call when the alarm expires.
*
* Returned Value:
* Zero (OK) on success; a negated errno on failure
*
************************************************************************************/
#ifdef CONFIG_RTC_ALARM
struct timespec;
int sam_rtc_setalarm(FAR const struct timespec *tp, alarmcb_t callback);
#endif
#undef EXTERN
#if defined(__cplusplus)
}

View File

@ -41,13 +41,15 @@
#include <nuttx/arch.h>
#include <nuttx/irq.h>
#include <nuttx/rtc.h>
#include <time.h>
#include <errno.h>
#include <debug.h>
#include <nuttx/arch.h>
#include <nuttx/irq.h>
#include <nuttx/wqueue.h>
#include <arch/board/board.h>
#include "up_arch.h"
@ -579,7 +581,7 @@ int up_rtc_settime(FAR const struct timespec *tp)
}
/************************************************************************************
* Name: up_rtc_setalarm
* Name: sam_rtc_setalarm
*
* Description:
* Set up an alarm. Up to two alarms can be supported (ALARM A and ALARM B).
@ -594,7 +596,7 @@ int up_rtc_settime(FAR const struct timespec *tp)
************************************************************************************/
#ifdef CONFIG_RTC_ALARM
int up_rtc_setalarm(FAR const struct timespec *tp, alarmcb_t callback)
int sam_rtc_setalarm(FAR const struct timespec *tp, alarmcb_t callback)
{
FAR struct tm newalarm;
irqstate_t flags;

View File

@ -1,7 +1,7 @@
/************************************************************************************
* arch/arm/src/sama5/sam_rtc.h
*
* Copyright (C) 2013 Gregory Nutt. All rights reserved.
* Copyright (C) 2013, 2015 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
@ -49,12 +49,25 @@
* Pre-processor Definitions
************************************************************************************/
/************************************************************************************
* Public Types
************************************************************************************/
#ifndef __ASSEMBLY__
/* The form of an alarm callback */
typedef void (*alarmcb_t)(void);
/************************************************************************************
* Public Data
************************************************************************************/
#undef EXTERN
#if defined(__cplusplus)
#define EXTERN extern "C"
extern "C" {
extern "C"
{
#else
#define EXTERN extern
#endif
@ -63,6 +76,26 @@ extern "C" {
* Public Functions
************************************************************************************/
/************************************************************************************
* Name: sam_rtc_setalarm
*
* Description:
* Set up an alarm.
*
* Input Parameters:
* tp - the time to set the alarm
* callback - the function to call when the alarm expires.
*
* Returned Value:
* Zero (OK) on success; a negated errno on failure
*
************************************************************************************/
#ifdef CONFIG_RTC_ALARM
struct timespec;
int sam_rtc_setalarm(FAR const struct timespec *tp, alarmcb_t callback);
#endif
#undef EXTERN
#if defined(__cplusplus)
}

View File

@ -40,6 +40,7 @@
#include <nuttx/config.h>
#include "chip.h"
#include "stm32_rtc.h"
/****************************************************************************
* Pre-processor Definitions

View File

@ -2,7 +2,7 @@
* arch/arm/src/stm32/stm32_rtc.h
*
* Copyright (C) 2011 Uros Platise. All rights reserved.
* Copyright (C) 2011-2013 Gregory Nutt. All rights reserved.
* Copyright (C) 2011-2013, 2015 Gregory Nutt. All rights reserved.
* Author: Uros Platise <uros.platise@isotel.eu> (Original for the F1)
* Gregory Nutt <gnutt@nuttx.org> (On-going support and development)
*
@ -71,12 +71,25 @@
#define STM32_RTC_PRESCALER_SECOND 32767 /* Default prescaler to get a second base */
#define STM32_RTC_PRESCALER_MIN 1 /* Maximum speed of 16384 Hz */
/****************************************************************************
* Public Types
****************************************************************************/
#ifndef __ASSEMBLY__
/* The form of an alarm callback */
typedef CODE void (*alarmcb_t)(void);
/****************************************************************************
* Public Data
****************************************************************************/
#undef EXTERN
#if defined(__cplusplus)
#define EXTERN extern "C"
extern "C" {
extern "C"
{
#else
#define EXTERN extern
#endif
@ -85,9 +98,43 @@ extern "C" {
* Public Functions
************************************************************************************/
/* Set alarm output pin */
/************************************************************************************
* Name: stm32_rtc_setalarm
*
* Description:
* Set up an alarm.
*
* Input Parameters:
* tp - the time to set the alarm
* callback - the function to call when the alarm expires.
*
* Returned Value:
* Zero (OK) on success; a negated errno on failure
*
************************************************************************************/
EXTERN void stm32_rtc_settalarmpin(bool activate);
#ifdef CONFIG_RTC_ALARM
struct timespec;
int stm32_rtc_setalarm(FAR const struct timespec *tp, alarmcb_t callback);
#endif
/************************************************************************************
* Name: stm32_rtc_cancelalarm
*
* Description:
* Cancel a pending alarm alarm
*
* Input Parameters:
* none
*
* Returned Value:
* Zero (OK) on success; a negated errno on failure
*
************************************************************************************/
#ifdef CONFIG_RTC_ALARM
int stm32_rtc_cancelalarm(void);
#endif
#undef EXTERN
#if defined(__cplusplus)

View File

@ -39,14 +39,13 @@
#include <nuttx/config.h>
#include <nuttx/arch.h>
#include <nuttx/irq.h>
#include <nuttx/rtc.h>
#include <time.h>
#include <errno.h>
#include <debug.h>
#include <nuttx/arch.h>
#include <nuttx/irq.h>
#include <arch/board/board.h>
#include "up_arch.h"
@ -904,7 +903,7 @@ int up_rtc_settime(FAR const struct timespec *tp)
}
/************************************************************************************
* Name: up_rtc_setalarm
* Name: stm32_rtc_setalarm
*
* Description:
* Set up an alarm. Up to two alarms can be supported (ALARM A and ALARM B).
@ -919,7 +918,7 @@ int up_rtc_settime(FAR const struct timespec *tp)
************************************************************************************/
#ifdef CONFIG_RTC_ALARM
int up_rtc_setalarm(FAR const struct timespec *tp, alarmcb_t callback)
int stm32_rtc_setalarm(FAR const struct timespec *tp, alarmcb_t callback)
{
irqstate_t flags;
int ret = -EBUSY;

View File

@ -247,7 +247,7 @@ static inline void stm32_rtc_wait4rsf(void)
}
/************************************************************************************
* Name: up_rtc_breakout
* Name: stm32_rtc_breakout
*
* Description:
* Set the RTC to the provided time.
@ -261,8 +261,8 @@ static inline void stm32_rtc_wait4rsf(void)
************************************************************************************/
#ifdef CONFIG_RTC_HIRES
static void up_rtc_breakout(FAR const struct timespec *tp,
FAR struct rtc_regvals_s *regvals)
static void stm32_rtc_breakout(FAR const struct timespec *tp,
FAR struct rtc_regvals_s *regvals)
{
uint64_t frac;
uint32_t cnt;
@ -281,8 +281,8 @@ static void up_rtc_breakout(FAR const struct timespec *tp,
regvals->ovf = ovf;
}
#else
static inline void up_rtc_breakout(FAR const struct timespec *tp,
FAR struct rtc_regvals_s *regvals)
static inline void stm32_rtc_breakout(FAR const struct timespec *tp,
FAR struct rtc_regvals_s *regvals)
{
/* The low-res timer is easy... tv_sec holds exactly the value needed by the
* CNTH/CNTL registers.
@ -572,7 +572,7 @@ int up_rtc_settime(FAR const struct timespec *tp)
/* Break out the time values */
up_rtc_breakout(tp, &regvals);
stm32_rtc_breakout(tp, &regvals);
/* Then write the broken out values to the RTC counter and BKP overflow register
* (hi-res mode only)
@ -592,7 +592,7 @@ int up_rtc_settime(FAR const struct timespec *tp)
}
/************************************************************************************
* Name: up_rtc_setalarm
* Name: stm32_rtc_setalarm
*
* Description:
* Set up an alarm.
@ -607,7 +607,7 @@ int up_rtc_settime(FAR const struct timespec *tp)
************************************************************************************/
#ifdef CONFIG_RTC_ALARM
int up_rtc_setalarm(FAR const struct timespec *tp, alarmcb_t callback)
int stm32_rtc_setalarm(FAR const struct timespec *tp, alarmcb_t callback)
{
struct rtc_regvals_s regvals;
irqstate_t flags;
@ -624,7 +624,7 @@ int up_rtc_setalarm(FAR const struct timespec *tp, alarmcb_t callback)
/* Break out the time values */
up_rtc_breakout(tp, &regvals);
stm32_rtc_breakout(tp, &regvals);
/* Enable RTC alarm */
@ -648,7 +648,7 @@ int up_rtc_setalarm(FAR const struct timespec *tp, alarmcb_t callback)
#endif
/************************************************************************************
* Name: up_rtc_cancelalarm
* Name: stm32_rtc_cancelalarm
*
* Description:
* Cancel a pending alarm alarm
@ -662,7 +662,7 @@ int up_rtc_setalarm(FAR const struct timespec *tp, alarmcb_t callback)
************************************************************************************/
#ifdef CONFIG_RTC_ALARM
int up_rtc_cancelalarm(void)
int stm32_rtc_cancelalarm(void)
{
irqstate_t flags;
int ret = -ENODATA;

View File

@ -43,12 +43,12 @@
#include <arch/board/board.h>
#include <nuttx/config.h>
#include <debug.h>
#include <nuttx/arch.h>
#include <nuttx/clock.h>
#include <nuttx/power/pm.h>
#include <debug.h>
#include <nuttx/rtc.h>
#include <arch/irq.h>
#include "up_internal.h"

View File

@ -45,7 +45,6 @@
#include <nuttx/arch.h>
#include <nuttx/clock.h>
#include <nuttx/power/pm.h>
#include <nuttx/rtc.h>
#include <arch/irq.h>
@ -55,6 +54,7 @@
#include "stm32_pm.h"
#include "stm32_rcc.h"
#include "stm32_exti.h"
#include "stm32_rtc.h"
#include "stm3210e-eval.h"
@ -226,7 +226,7 @@ static int stm32_rtc_alarm(time_t tv_sec, time_t tv_nsec, bool exti)
/* Set the alarm */
g_alarmwakeup = false;
ret = up_rtc_setalarm(&alarmtime, stm32_alarmcb);
ret = stm32_rtc_setalarm(&alarmtime, stm32_alarmcb);
if (ret < 0)
{
lldbg("Warning: The alarm is already set\n");
@ -363,7 +363,7 @@ static void stm32_idlepm(void)
#ifdef CONFIG_RTC_ALARM
stm32_exti_cancel();
ret = up_rtc_cancelalarm();
ret = stm32_rtc_cancelalarm();
if (ret < 0)
{
lldbg("Warning: Cancel alarm failed\n");

View File

@ -42,12 +42,12 @@
#include <arch/board/board.h>
#include <nuttx/config.h>
#include <debug.h>
#include <nuttx/arch.h>
#include <nuttx/clock.h>
#include <nuttx/power/pm.h>
#include <debug.h>
#include <nuttx/rtc.h>
#include <arch/irq.h>
#include "up_internal.h"

View File

@ -42,12 +42,12 @@
#include <arch/board/board.h>
#include <nuttx/config.h>
#include <debug.h>
#include <nuttx/arch.h>
#include <nuttx/clock.h>
#include <nuttx/power/pm.h>
#include <debug.h>
#include <nuttx/rtc.h>
#include <arch/irq.h>
#include "up_internal.h"

View File

@ -71,9 +71,9 @@
#include <nuttx/config.h>
#include <nuttx/fs/fs.h>
#include <semaphore.h>
#include <nuttx/arch.h>
#include <nuttx/clock.h>
#include <nuttx/time.h>
#include <nuttx/rtc.h>
#include <nuttx/progmem.h>
#include <nuttx/i2c.h>

View File

@ -225,7 +225,7 @@ menuconfig RTC
default n
---help---
This selection enables configuration of a real time clock (RTCdriver.
See include/nuttx/rtc.h for further watchdog timer driver information.
See include/nuttx/rtc.h for further RTC driver information.
Most RTC drivers are MCU specific and may require other specific
settings.

View File

@ -145,6 +145,17 @@ extern "C"
EXTERN uint32_t g_oneshot_maxticks;
#endif
#ifdef CONFIG_RTC
/* Variable determines the state of the RTC module.
*
* After initialization value is set to 'true' if RTC starts successfully.
* The value can be changed to false also during operation if RTC for
* some reason fails.
*/
EXTERN volatile bool g_rtc_enabled;
#endif
/****************************************************************************
* Public Function Prototypes
****************************************************************************/
@ -1827,6 +1838,113 @@ uint8_t board_buttons(void);
xcpt_t board_button_irq(int id, xcpt_t irqhandler);
#endif
/****************************************************************************
* Name: up_rtcinitialize
*
* Description:
* Initialize the hardware RTC per the selected configuration. This
* function is called once during the OS initialization sequence
*
* Input Parameters:
* None
*
* Returned Value:
* Zero (OK) on success; a negated errno on failure
*
****************************************************************************/
#ifdef CONFIG_RTC
int up_rtcinitialize(void);
#endif
/************************************************************************************
* Name: up_rtc_time
*
* Description:
* Get the current time in seconds. This is similar to the standard time()
* function. This interface is only required if the low-resolution RTC/counter
* hardware implementation selected. It is only used by the RTOS during
* initialization to set up the system time when CONFIG_RTC is set but neither
* CONFIG_RTC_HIRES nor CONFIG_RTC_DATETIME are set.
*
* Input Parameters:
* None
*
* Returned Value:
* The current time in seconds
*
************************************************************************************/
#if defined(CONFIG_RTC) && !defined(CONFIG_RTC_HIRES)
time_t up_rtc_time(void);
#endif
/************************************************************************************
* Name: up_rtc_gettime
*
* Description:
* Get the current time from the high resolution RTC clock/counter. This interface
* is only supported by the high-resolution RTC/counter hardware implementation.
* It is used to replace the system timer.
*
* Input Parameters:
* tp - The location to return the high resolution time value.
*
* Returned Value:
* Zero (OK) on success; a negated errno on failure
*
************************************************************************************/
#if defined(CONFIG_RTC) && defined(CONFIG_RTC_HIRES)
int up_rtc_gettime(FAR struct timespec *tp);
#endif
/************************************************************************************
* Name: up_rtc_getdatetime
*
* Description:
* Get the current date and time from the date/time RTC. This interface
* is only supported by the date/time RTC hardware implementation.
* It is used to replace the system timer. It is only used by the RTOS during
* initialization to set up the system time when CONFIG_RTC and CONFIG_RTC_DATETIME
* are selected (and CONFIG_RTC_HIRES is not).
*
* NOTE: Some date/time RTC hardware is capability of sub-second accuracy. That
* sub-second accuracy is lost in this interface. However, since the system time
* is reinitialized on each power-up/reset, there will be no timing inaccuracy in
* the long run.
*
* Input Parameters:
* tp - The location to return the high resolution time value.
*
* Returned Value:
* Zero (OK) on success; a negated errno on failure
*
************************************************************************************/
#if defined(CONFIG_RTC) && defined(CONFIG_RTC_DATETIME)
int up_rtc_getdatetime(FAR struct tm *tp);
#endif
/************************************************************************************
* Name: up_rtc_settime
*
* Description:
* Set the RTC to the provided time. All RTC implementations must be able to
* set their time based on a standard timespec.
*
* Input Parameters:
* tp - the time to use
*
* Returned Value:
* Zero (OK) on success; a negated errno on failure
*
************************************************************************************/
#ifdef CONFIG_RTC
int up_rtc_settime(FAR const struct timespec *tp);
#endif
/****************************************************************************
* Name: arch_phy_irq
*

View File

@ -47,10 +47,6 @@
#include <nuttx/config.h>
#include <stdint.h>
#include <stdbool.h>
#include <time.h>
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
@ -63,7 +59,7 @@
* A full date / time RTC the provides the date and time information, often
* in BCD format. If CONFIG_RTC_DATETIME is selected, it specifies this
* second kind of RTC. In this case, the RTC is used to "seed" the normal
* NuttX timer and the NuttX system timer provides for higher resoution
* NuttX timer and the NuttX system timer provides for higher resolution
* time.
*
* CONFIG_RTC_HIRES - If CONFIG_RTC_DATETIME not selected, then the simple,
@ -72,7 +68,7 @@
* The typical RTC keeps time to resolution of 1 second, usually
* supporting a 32-bit time_t value. In this case, the RTC is used to
* "seed" the normal NuttX timer and the NuttX timer provides for higher
* resoution time.
* resolution time.
*
* If CONFIG_RTC_HIRES is enabled in the NuttX configuration, then the
* RTC provides higher resolution time and completely replaces the system
@ -106,25 +102,8 @@
* Public Types
****************************************************************************/
/* The form of an alarm callback */
typedef CODE void (*alarmcb_t)(void);
/****************************************************************************
* Public Variables
****************************************************************************/
/* Variable determines the state of the RTC module.
*
* After initialization value is set to 'true' if RTC starts successfully.
* The value can be changed to false also during operation if RTC for
* some reason fails.
*/
extern volatile bool g_rtc_enabled;
/****************************************************************************
* Public Functions
* Public Data
****************************************************************************/
#undef EXTERN
@ -136,145 +115,10 @@ extern "C"
#define EXTERN extern
#endif
/************************************************************************************
* Name: up_rtcinitialize
*
* Description:
* Initialize the hardware RTC per the selected configuration. This function is
* called once during the OS initialization sequence
*
* Input Parameters:
* None
*
* Returned Value:
* Zero (OK) on success; a negated errno on failure
*
************************************************************************************/
/****************************************************************************
* Public Functions
****************************************************************************/
int up_rtcinitialize(void);
/************************************************************************************
* Name: up_rtc_time
*
* Description:
* Get the current time in seconds. This is similar to the standard time()
* function. This interface is only required if the low-resolution RTC/counter
* hardware implementation selected. It is only used by the RTOS during
* initialization to set up the system time when CONFIG_RTC is set but neither
* CONFIG_RTC_HIRES nor CONFIG_RTC_DATETIME are set.
*
* Input Parameters:
* None
*
* Returned Value:
* The current time in seconds
*
************************************************************************************/
#ifndef CONFIG_RTC_HIRES
time_t up_rtc_time(void);
#endif
/************************************************************************************
* Name: up_rtc_gettime
*
* Description:
* Get the current time from the high resolution RTC clock/counter. This interface
* is only supported by the high-resolution RTC/counter hardware implementation.
* It is used to replace the system timer.
*
* Input Parameters:
* tp - The location to return the high resolution time value.
*
* Returned Value:
* Zero (OK) on success; a negated errno on failure
*
************************************************************************************/
#ifdef CONFIG_RTC_HIRES
int up_rtc_gettime(FAR struct timespec *tp);
#endif
/************************************************************************************
* Name: up_rtc_getdatetime
*
* Description:
* Get the current date and time from the date/time RTC. This interface
* is only supported by the date/time RTC hardware implementation.
* It is used to replace the system timer. It is only used by the RTOS during
* initialization to set up the system time when CONFIG_RTC and CONFIG_RTC_DATETIME
* are selected (and CONFIG_RTC_HIRES is not).
*
* NOTE: Some date/time RTC hardware is capability of sub-second accuracy. That
* sub-second accuracy is lost in this interface. However, since the system time
* is reinitialized on each power-up/reset, there will be no timing inaccuracy in
* the long run.
*
* Input Parameters:
* tp - The location to return the high resolution time value.
*
* Returned Value:
* Zero (OK) on success; a negated errno on failure
*
************************************************************************************/
#ifdef CONFIG_RTC_DATETIME
int up_rtc_getdatetime(FAR struct tm *tp);
#endif
/************************************************************************************
* Name: up_rtc_settime
*
* Description:
* Set the RTC to the provided time. All RTC implementations must be able to
* set their time based on a standard timespec.
*
* Input Parameters:
* tp - the time to use
*
* Returned Value:
* Zero (OK) on success; a negated errno on failure
*
************************************************************************************/
int up_rtc_settime(FAR const struct timespec *tp);
/************************************************************************************
* Name: up_rtc_setalarm
*
* Description:
* Set up an alarm.
*
* Input Parameters:
* tp - the time to set the alarm
* callback - the function to call when the alarm expires.
*
* Returned Value:
* Zero (OK) on success; a negated errno on failure
*
************************************************************************************/
#ifdef CONFIG_RTC_ALARM
int up_rtc_setalarm(FAR const struct timespec *tp, alarmcb_t callback);
#endif
/************************************************************************************
* Name: up_rtc_cancelalarm
*
* Description:
* Cancel a pending alarm alarm
*
* Input Parameters:
* none
*
* Returned Value:
* Zero (OK) on success; a negated errno on failure
*
************************************************************************************/
#ifdef CONFIG_RTC_ALARM
int up_rtc_cancelalarm(void);
#endif
#undef EXTERN
#if defined(__cplusplus)

View File

@ -38,7 +38,6 @@
************************************************************************/
#include <nuttx/config.h>
#include <nuttx/rtc.h>
#include <stdint.h>
#include <time.h>

View File

@ -49,9 +49,9 @@
# include <arch/irq.h>
#endif
#include <nuttx/arch.h>
#include <nuttx/clock.h>
#include <nuttx/time.h>
#include <nuttx/rtc.h>
#include "clock/clock.h"

View File

@ -38,14 +38,15 @@
************************************************************************/
#include <nuttx/config.h>
#include <nuttx/rtc.h>
#include <time.h>
#include <assert.h>
#include <errno.h>
#include <debug.h>
#include <nuttx/arch.h>
#include <arch/irq.h>
#include "clock/clock.h"
/************************************************************************

View File

@ -44,11 +44,6 @@
#include <nuttx/arch.h>
#include <nuttx/clock.h>
#include <nuttx/rtc.h>
#ifdef CONFIG_RTC_HIRES
# include <nuttx/rtc.h>
#endif
#include "clock/clock.h"