From 501bc15fbd0a54c8869f79dd1c500e574b7fe3f2 Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Fri, 13 Feb 2015 08:41:34 -0600 Subject: [PATCH] RTC: Remove all backdoor interfaces from rtc.h --- arch/arm/src/efm32/efm32_rtc_burtc.c | 11 +++--- arch/arm/src/lpc17xx/lpc176x_rtc.c | 11 +++--- arch/arm/src/lpc17xx/lpc17_rtc.h | 26 ++++++++++++- arch/arm/src/sam34/sam_rtc.c | 11 +++--- arch/arm/src/sam34/sam_rtc.h | 37 ++++++++++++++++++- arch/arm/src/sama5/sam_rtc.c | 8 ++-- arch/arm/src/sama5/sam_rtc.h | 37 ++++++++++++++++++- arch/arm/src/stm32/stm32_rtc.c | 1 + arch/arm/src/stm32/stm32_rtc.h | 55 ++++++++++++++++++++++++++-- arch/arm/src/stm32/stm32_rtcc.c | 11 +++--- arch/arm/src/stm32/stm32_rtcounter.c | 22 +++++------ 11 files changed, 184 insertions(+), 46 deletions(-) diff --git a/arch/arm/src/efm32/efm32_rtc_burtc.c b/arch/arm/src/efm32/efm32_rtc_burtc.c index 0450b7aadaa..2b58b4a9ec6 100644 --- a/arch/arm/src/efm32/efm32_rtc_burtc.c +++ b/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/arch/arm/src/lpc17xx/lpc176x_rtc.c b/arch/arm/src/lpc17xx/lpc176x_rtc.c index 5423335c101..0aaf6eb33d8 100644 --- a/arch/arm/src/lpc17xx/lpc176x_rtc.c +++ b/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/arch/arm/src/lpc17xx/lpc17_rtc.h b/arch/arm/src/lpc17xx/lpc17_rtc.h index 9011cd84ae4..1ee2ea91b27 100644 --- a/arch/arm/src/lpc17xx/lpc17_rtc.h +++ b/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/arch/arm/src/sam34/sam_rtc.c b/arch/arm/src/sam34/sam_rtc.c index 9b4e8b40fb5..c92672aa97e 100644 --- a/arch/arm/src/sam34/sam_rtc.c +++ b/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/arch/arm/src/sam34/sam_rtc.h b/arch/arm/src/sam34/sam_rtc.h index 03b123a6ddf..03ab3166935 100644 --- a/arch/arm/src/sam34/sam_rtc.h +++ b/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/arch/arm/src/sama5/sam_rtc.c b/arch/arm/src/sama5/sam_rtc.c index e9221898d25..db1be973892 100644 --- a/arch/arm/src/sama5/sam_rtc.c +++ b/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/arch/arm/src/sama5/sam_rtc.h b/arch/arm/src/sama5/sam_rtc.h index c119d4c9c9f..bb97c5ea566 100644 --- a/arch/arm/src/sama5/sam_rtc.h +++ b/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/arch/arm/src/stm32/stm32_rtc.c b/arch/arm/src/stm32/stm32_rtc.c index 5d4e0896e67..9dc5b2097cc 100644 --- a/arch/arm/src/stm32/stm32_rtc.c +++ b/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/arch/arm/src/stm32/stm32_rtc.h b/arch/arm/src/stm32/stm32_rtc.h index 8e529cb6198..b27a4ffb9ed 100644 --- a/arch/arm/src/stm32/stm32_rtc.h +++ b/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 + * + ************************************************************************************/ -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) diff --git a/arch/arm/src/stm32/stm32_rtcc.c b/arch/arm/src/stm32/stm32_rtcc.c index ea49fa2e6ad..29840b7b6aa 100644 --- a/arch/arm/src/stm32/stm32_rtcc.c +++ b/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/arch/arm/src/stm32/stm32_rtcounter.c b/arch/arm/src/stm32/stm32_rtcounter.c index 5ffb1a313bf..5613b05aa46 100644 --- a/arch/arm/src/stm32/stm32_rtcounter.c +++ b/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;