aboutsummaryrefslogtreecommitdiffstats
path: root/os/hal
diff options
context:
space:
mode:
authorbarthess <barthess@35acf78f-673a-0410-8e92-d51de3d6d3f4>2011-08-31 15:31:32 +0000
committerbarthess <barthess@35acf78f-673a-0410-8e92-d51de3d6d3f4>2011-08-31 15:31:32 +0000
commit3da3cc27891650180b1e725d1efb6f07005e9d3e (patch)
tree955d422078fdaf7384aaaac2a4096320b93246b6 /os/hal
parent6cc29ee5c81b3c6f745ae80ab242514b073d3d3f (diff)
downloadChibiOS-3da3cc27891650180b1e725d1efb6f07005e9d3e.tar.gz
ChibiOS-3da3cc27891650180b1e725d1efb6f07005e9d3e.tar.bz2
ChibiOS-3da3cc27891650180b1e725d1efb6f07005e9d3e.zip
RTC. Copyrights added.
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/branches/rtc_dev@3274 35acf78f-673a-0410-8e92-d51de3d6d3f4
Diffstat (limited to 'os/hal')
-rw-r--r--os/hal/include/rtc.h33
-rw-r--r--os/hal/platforms/STM32/rtc_lld.c28
-rw-r--r--os/hal/platforms/STM32/rtc_lld.h30
-rw-r--r--os/hal/src/rtc.c33
4 files changed, 103 insertions, 21 deletions
diff --git a/os/hal/include/rtc.h b/os/hal/include/rtc.h
index 474862910..aa1a61f49 100644
--- a/os/hal/include/rtc.h
+++ b/os/hal/include/rtc.h
@@ -1,3 +1,23 @@
+/*
+ ChibiOS/RT - Copyright (C) 2006,2007,2008,2009,2010,
+ 2011 Giovanni Di Sirio.
+
+ This file is part of ChibiOS/RT.
+
+ ChibiOS/RT is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ ChibiOS/RT is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
+
/**
* @file rtc.h
* @brief RTC Driver macros and structures.
@@ -58,10 +78,15 @@ typedef void (*rtccb_t)(RTCDriver *rtcp);
extern "C" {
#endif
void rtcInit(void);
-#if RTC_SUPPORTS_CALLBACKS
- void rtcStart(RTCDriver *rtcp, const RTCConfig *rtccfgp);
- void rtcStop(void);
-#endif /* RTC_SUPPORTS_CALLBACKS */
+
+ #if RTC_SUPPORTS_CALLBACKS
+ void rtcStart(RTCDriver *rtcp, const RTCConfig *rtccfgp);
+ void rtcStop(void);
+ #else /* RTC_SUPPORTS_CALLBACKS */
+ #define rtcStart(rtcp, rtccfgp){;}
+ #define rtcStop(){;}
+ #endif /* RTC_SUPPORTS_CALLBACKS */
+
void rtcSetTime(uint32_t tv_sec);
uint32_t rtcGetSec(void);
uint16_t rtcGetMsec(void);
diff --git a/os/hal/platforms/STM32/rtc_lld.c b/os/hal/platforms/STM32/rtc_lld.c
index 59699028d..ed458190d 100644
--- a/os/hal/platforms/STM32/rtc_lld.c
+++ b/os/hal/platforms/STM32/rtc_lld.c
@@ -1,3 +1,23 @@
+/*
+ ChibiOS/RT - Copyright (C) 2006,2007,2008,2009,2010,
+ 2011 Giovanni Di Sirio.
+
+ This file is part of ChibiOS/RT.
+
+ ChibiOS/RT is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ ChibiOS/RT is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
+
/**
* @file STM32/rtc_lld.c
* @brief STM32 RTC subsystem low level driver header.
@@ -139,6 +159,7 @@ void rtc_lld_init(void){
/**
* @brief Configure and start interrupt servicing routines.
+ * This function do nothing if callbacks disabled.
*
* @param[in] rtcp pointer to a @p RTCDriver object
* @param[in] rtccfgp pointer to a @p RTCDriver config object
@@ -174,7 +195,6 @@ void rtc_lld_stop(void){
#endif /* RTC_SUPPORTS_CALLBACKS */
-
/**
* @brief Set current time.
*
@@ -200,14 +220,14 @@ void rtc_lld_set_time(uint32_t tv_sec){
/**
* @brief Return current time in UNIX notation.
*/
-uint32_t rtc_lld_get_sec(void){
+inline uint32_t rtc_lld_get_sec(void){
return ((RTC->CNTH << 16) + RTC->CNTL);
}
/**
* @brief Return fractional part of current time (milliseconds).
*/
-uint16_t rtc_lld_get_msec(void){
+inline uint16_t rtc_lld_get_msec(void){
uint32_t time_frac = 0;
time_frac = (((uint32_t)RTC->DIVH) << 16) + (RTC->DIVL);
return(((STM32_LSECLK - time_frac) * 1000) / STM32_LSECLK);
@@ -234,7 +254,7 @@ void rtc_lld_set_alarm(uint32_t tv_alarm){
* @brief Get current alarm date in UNIX notation.
* @note Default value after reset is 0xFFFFFFFF
*/
-uint32_t rtc_lld_get_alarm(void){
+inline uint32_t rtc_lld_get_alarm(void){
return ((RTC->ALRH << 16) + RTC->ALRL);
}
diff --git a/os/hal/platforms/STM32/rtc_lld.h b/os/hal/platforms/STM32/rtc_lld.h
index f26315784..fe51df254 100644
--- a/os/hal/platforms/STM32/rtc_lld.h
+++ b/os/hal/platforms/STM32/rtc_lld.h
@@ -1,3 +1,22 @@
+/*
+ ChibiOS/RT - Copyright (C) 2006,2007,2008,2009,2010,
+ 2011 Giovanni Di Sirio.
+
+ This file is part of ChibiOS/RT.
+
+ ChibiOS/RT is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ ChibiOS/RT is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
/**
* @file STM32/rtc_lld.h
@@ -85,10 +104,13 @@ extern RTCDriver RTCD;
extern "C" {
#endif
void rtc_lld_init(void);
-#if RTC_SUPPORTS_CALLBACKS
- void rtc_lld_start(RTCDriver *rtcp, const RTCConfig *rtccfgp);
- void rtc_lld_stop(void);
-#endif /* RTC_SUPPORTS_CALLBACKS */
+ #if RTC_SUPPORTS_CALLBACKS
+ void rtc_lld_start(RTCDriver *rtcp, const RTCConfig *rtccfgp);
+ void rtc_lld_stop(void);
+ #else /* RTC_SUPPORTS_CALLBACKS */
+ #define rtc_lld_start(rtcp, rtccfgp){;}
+ #define rtc_lld_stop(){;}
+ #endif /* RTC_SUPPORTS_CALLBACKS */
void rtc_lld_set_time(uint32_t tv_sec);
uint32_t rtc_lld_get_sec(void);
uint16_t rtc_lld_get_msec(void);
diff --git a/os/hal/src/rtc.c b/os/hal/src/rtc.c
index c6edca4a2..0db21d4d5 100644
--- a/os/hal/src/rtc.c
+++ b/os/hal/src/rtc.c
@@ -1,3 +1,23 @@
+/*
+ ChibiOS/RT - Copyright (C) 2006,2007,2008,2009,2010,
+ 2011 Giovanni Di Sirio.
+
+ This file is part of ChibiOS/RT.
+
+ ChibiOS/RT is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ ChibiOS/RT is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
+
/**
* @file rtc.c
* @brief Real Time Clock Abstraction Layer code.
@@ -40,12 +60,14 @@ void rtcInit(void){
rtc_lld_init();
}
-#if RTC_SUPPORTS_CALLBACKS
/**
- * @brief Configure and start interrupt servicing routines.
+ * @brief Configure and start interrupt servicing routines.
+ * This function do nothing if callbacks disabled.
+ *
* @param[in] rtcp - pointer to RTC driver structure.
* @param[in] rtccfgp - pointer to RTC config structure.
*/
+#if RTC_SUPPORTS_CALLBACKS
void rtcStart(RTCDriver *rtcp, const RTCConfig *rtccfgp){
chDbgCheck(((rtcp != NULL) && (rtccfgp != NULL)), "rtcStart");
rtc_lld_start(rtcp, rtccfgp);
@@ -95,15 +117,8 @@ uint32_t rtcGetAlarm(void){
return rtc_lld_get_alarm();
}
-
-
-
-
-
#endif /* HAL_USE_RTC */
-
-
/** @} */