From b3260ea37bc255d781477bec9e8706205fd9b46f Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Fri, 13 Feb 2015 08:41:34 -0600 Subject: RTC: Remove all backdoor interfaces from rtc.h --- nuttx/Documentation/NuttxPortingGuide.html | 3 - nuttx/arch/arm/src/efm32/efm32_rtc_burtc.c | 11 +- nuttx/arch/arm/src/lpc17xx/lpc176x_rtc.c | 11 +- nuttx/arch/arm/src/lpc17xx/lpc17_rtc.h | 26 +++- nuttx/arch/arm/src/sam34/sam_rtc.c | 11 +- nuttx/arch/arm/src/sam34/sam_rtc.h | 37 +++++- nuttx/arch/arm/src/sama5/sam_rtc.c | 8 +- nuttx/arch/arm/src/sama5/sam_rtc.h | 37 +++++- nuttx/arch/arm/src/stm32/stm32_rtc.c | 1 + nuttx/arch/arm/src/stm32/stm32_rtc.h | 55 +++++++- nuttx/arch/arm/src/stm32/stm32_rtcc.c | 11 +- nuttx/arch/arm/src/stm32/stm32_rtcounter.c | 22 ++-- nuttx/configs/mikroe-stm32f4/src/up_idle.c | 4 +- nuttx/configs/stm3210e-eval/src/stm32_idle.c | 6 +- nuttx/configs/stm32f429i-disco/src/stm32_idle.c | 4 +- nuttx/configs/stm32f4discovery/src/stm32_idle.c | 4 +- nuttx/configs/vsn/src/sif.c | 2 +- nuttx/drivers/Kconfig | 2 +- nuttx/include/nuttx/arch.h | 118 +++++++++++++++++ nuttx/include/nuttx/rtc.h | 168 +----------------------- nuttx/sched/clock/clock_gettime.c | 1 - nuttx/sched/clock/clock_initialize.c | 2 +- nuttx/sched/clock/clock_settime.c | 3 +- nuttx/sched/clock/clock_systimespec.c | 5 - 24 files changed, 322 insertions(+), 230 deletions(-) diff --git a/nuttx/Documentation/NuttxPortingGuide.html b/nuttx/Documentation/NuttxPortingGuide.html index f685d92ab..ddd2086bf 100644 --- a/nuttx/Documentation/NuttxPortingGuide.html +++ b/nuttx/Documentation/NuttxPortingGuide.html @@ -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. -
  • up_rtc_setalarm(). - Set up an alarm. -
  • 4.3.3 System Tick and Time

    diff --git a/nuttx/arch/arm/src/efm32/efm32_rtc_burtc.c b/nuttx/arch/arm/src/efm32/efm32_rtc_burtc.c index 0450b7aad..2b58b4a9e 100644 --- a/nuttx/arch/arm/src/efm32/efm32_rtc_burtc.c +++ b/nuttx/arch/arm/src/efm32/efm32_rtc_burtc.c @@ -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, ®vals); + efm32_rtc_breakout(tp, ®vals); /* 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; diff --git a/nuttx/arch/arm/src/lpc17xx/lpc176x_rtc.c b/nuttx/arch/arm/src/lpc17xx/lpc176x_rtc.c index 5423335c1..0aaf6eb33 100644 --- a/nuttx/arch/arm/src/lpc17xx/lpc176x_rtc.c +++ b/nuttx/arch/arm/src/lpc17xx/lpc176x_rtc.c @@ -39,14 +39,13 @@ #include -#include -#include -#include - #include #include #include +#include +#include + #include #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; diff --git a/nuttx/arch/arm/src/lpc17xx/lpc17_rtc.h b/nuttx/arch/arm/src/lpc17xx/lpc17_rtc.h index 9011cd84a..1ee2ea91b 100644 --- a/nuttx/arch/arm/src/lpc17xx/lpc17_rtc.h +++ b/nuttx/arch/arm/src/lpc17xx/lpc17_rtc.h @@ -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 * * 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 */ diff --git a/nuttx/arch/arm/src/sam34/sam_rtc.c b/nuttx/arch/arm/src/sam34/sam_rtc.c index 9b4e8b40f..c92672aa9 100644 --- a/nuttx/arch/arm/src/sam34/sam_rtc.c +++ b/nuttx/arch/arm/src/sam34/sam_rtc.c @@ -40,15 +40,14 @@ #include -#include -#include -#include - #include #include #include +#include +#include #include + #include #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; diff --git a/nuttx/arch/arm/src/sam34/sam_rtc.h b/nuttx/arch/arm/src/sam34/sam_rtc.h index 03b123a6d..03ab31669 100644 --- a/nuttx/arch/arm/src/sam34/sam_rtc.h +++ b/nuttx/arch/arm/src/sam34/sam_rtc.h @@ -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 * 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) } diff --git a/nuttx/arch/arm/src/sama5/sam_rtc.c b/nuttx/arch/arm/src/sama5/sam_rtc.c index e9221898d..db1be9738 100644 --- a/nuttx/arch/arm/src/sama5/sam_rtc.c +++ b/nuttx/arch/arm/src/sama5/sam_rtc.c @@ -41,13 +41,15 @@ #include #include -#include #include #include #include +#include +#include #include + #include #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; diff --git a/nuttx/arch/arm/src/sama5/sam_rtc.h b/nuttx/arch/arm/src/sama5/sam_rtc.h index c119d4c9c..bb97c5ea5 100644 --- a/nuttx/arch/arm/src/sama5/sam_rtc.h +++ b/nuttx/arch/arm/src/sama5/sam_rtc.h @@ -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 * * 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) } diff --git a/nuttx/arch/arm/src/stm32/stm32_rtc.c b/nuttx/arch/arm/src/stm32/stm32_rtc.c index 5d4e0896e..9dc5b2097 100644 --- a/nuttx/arch/arm/src/stm32/stm32_rtc.c +++ b/nuttx/arch/arm/src/stm32/stm32_rtc.c @@ -40,6 +40,7 @@ #include #include "chip.h" +#include "stm32_rtc.h" /**************************************************************************** * Pre-processor Definitions diff --git a/nuttx/arch/arm/src/stm32/stm32_rtc.h b/nuttx/arch/arm/src/stm32/stm32_rtc.h index 8e529cb61..b27a4ffb9 100644 --- a/nuttx/arch/arm/src/stm32/stm32_rtc.h +++ b/nuttx/arch/arm/src/stm32/stm32_rtc.h @@ -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 (Original for the F1) * Gregory Nutt (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 + * + ************************************************************************************/ + +#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 + * + ************************************************************************************/ -EXTERN void stm32_rtc_settalarmpin(bool activate); +#ifdef CONFIG_RTC_ALARM +int stm32_rtc_cancelalarm(void); +#endif #undef EXTERN #if defined(__cplusplus) diff --git a/nuttx/arch/arm/src/stm32/stm32_rtcc.c b/nuttx/arch/arm/src/stm32/stm32_rtcc.c index ea49fa2e6..29840b7b6 100644 --- a/nuttx/arch/arm/src/stm32/stm32_rtcc.c +++ b/nuttx/arch/arm/src/stm32/stm32_rtcc.c @@ -39,14 +39,13 @@ #include -#include -#include -#include - #include #include #include +#include +#include + #include #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; diff --git a/nuttx/arch/arm/src/stm32/stm32_rtcounter.c b/nuttx/arch/arm/src/stm32/stm32_rtcounter.c index 5ffb1a313..5613b05aa 100644 --- a/nuttx/arch/arm/src/stm32/stm32_rtcounter.c +++ b/nuttx/arch/arm/src/stm32/stm32_rtcounter.c @@ -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, ®vals); + stm32_rtc_breakout(tp, ®vals); /* 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, ®vals); + stm32_rtc_breakout(tp, ®vals); /* 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; diff --git a/nuttx/configs/mikroe-stm32f4/src/up_idle.c b/nuttx/configs/mikroe-stm32f4/src/up_idle.c index 71928876f..22b5bc738 100644 --- a/nuttx/configs/mikroe-stm32f4/src/up_idle.c +++ b/nuttx/configs/mikroe-stm32f4/src/up_idle.c @@ -43,12 +43,12 @@ #include #include +#include + #include #include #include -#include -#include #include #include "up_internal.h" diff --git a/nuttx/configs/stm3210e-eval/src/stm32_idle.c b/nuttx/configs/stm3210e-eval/src/stm32_idle.c index 84d6032cd..045b101c6 100644 --- a/nuttx/configs/stm3210e-eval/src/stm32_idle.c +++ b/nuttx/configs/stm3210e-eval/src/stm32_idle.c @@ -45,7 +45,6 @@ #include #include #include -#include #include @@ -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"); diff --git a/nuttx/configs/stm32f429i-disco/src/stm32_idle.c b/nuttx/configs/stm32f429i-disco/src/stm32_idle.c index d4951f531..24e325535 100644 --- a/nuttx/configs/stm32f429i-disco/src/stm32_idle.c +++ b/nuttx/configs/stm32f429i-disco/src/stm32_idle.c @@ -42,12 +42,12 @@ #include #include +#include + #include #include #include -#include -#include #include #include "up_internal.h" diff --git a/nuttx/configs/stm32f4discovery/src/stm32_idle.c b/nuttx/configs/stm32f4discovery/src/stm32_idle.c index 861df5123..46dc3b766 100644 --- a/nuttx/configs/stm32f4discovery/src/stm32_idle.c +++ b/nuttx/configs/stm32f4discovery/src/stm32_idle.c @@ -42,12 +42,12 @@ #include #include +#include + #include #include #include -#include -#include #include #include "up_internal.h" diff --git a/nuttx/configs/vsn/src/sif.c b/nuttx/configs/vsn/src/sif.c index 4488357af..18b3d51a4 100644 --- a/nuttx/configs/vsn/src/sif.c +++ b/nuttx/configs/vsn/src/sif.c @@ -71,9 +71,9 @@ #include #include #include +#include #include #include -#include #include #include diff --git a/nuttx/drivers/Kconfig b/nuttx/drivers/Kconfig index 34ea89a13..cd6b6b1a7 100644 --- a/nuttx/drivers/Kconfig +++ b/nuttx/drivers/Kconfig @@ -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. diff --git a/nuttx/include/nuttx/arch.h b/nuttx/include/nuttx/arch.h index 836407c20..ceb1c9b98 100644 --- a/nuttx/include/nuttx/arch.h +++ b/nuttx/include/nuttx/arch.h @@ -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 * diff --git a/nuttx/include/nuttx/rtc.h b/nuttx/include/nuttx/rtc.h index b7801fd36..09440f08e 100644 --- a/nuttx/include/nuttx/rtc.h +++ b/nuttx/include/nuttx/rtc.h @@ -47,10 +47,6 @@ #include -#include -#include -#include - /**************************************************************************** * 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 - * - ************************************************************************************/ - -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 - * - ************************************************************************************/ +/**************************************************************************** + * Public Functions + ****************************************************************************/ -#ifdef CONFIG_RTC_ALARM -int up_rtc_cancelalarm(void); -#endif #undef EXTERN #if defined(__cplusplus) diff --git a/nuttx/sched/clock/clock_gettime.c b/nuttx/sched/clock/clock_gettime.c index c422252bc..0c8c9be80 100644 --- a/nuttx/sched/clock/clock_gettime.c +++ b/nuttx/sched/clock/clock_gettime.c @@ -38,7 +38,6 @@ ************************************************************************/ #include -#include #include #include diff --git a/nuttx/sched/clock/clock_initialize.c b/nuttx/sched/clock/clock_initialize.c index eab7e2d23..a807af37d 100644 --- a/nuttx/sched/clock/clock_initialize.c +++ b/nuttx/sched/clock/clock_initialize.c @@ -49,9 +49,9 @@ # include #endif +#include #include #include -#include #include "clock/clock.h" diff --git a/nuttx/sched/clock/clock_settime.c b/nuttx/sched/clock/clock_settime.c index 2649243ca..93b4d3386 100644 --- a/nuttx/sched/clock/clock_settime.c +++ b/nuttx/sched/clock/clock_settime.c @@ -38,14 +38,15 @@ ************************************************************************/ #include -#include #include #include #include #include +#include #include + #include "clock/clock.h" /************************************************************************ diff --git a/nuttx/sched/clock/clock_systimespec.c b/nuttx/sched/clock/clock_systimespec.c index 81d16fa67..30a5ccbc1 100644 --- a/nuttx/sched/clock/clock_systimespec.c +++ b/nuttx/sched/clock/clock_systimespec.c @@ -44,11 +44,6 @@ #include #include -#include - -#ifdef CONFIG_RTC_HIRES -# include -#endif #include "clock/clock.h" -- cgit v1.2.3