summaryrefslogtreecommitdiff
path: root/nuttx/include
diff options
context:
space:
mode:
authorpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2011-04-16 13:00:57 +0000
committerpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2011-04-16 13:00:57 +0000
commitcbb245c0b6816c10be52a03a3ea8c66db8e0a7ae (patch)
tree15b55003014272570f06703cf7e612d9321a87e6 /nuttx/include
parent6a969146eb87c8b6bb06a64b37f7afecaa8144e6 (diff)
downloadpx4-nuttx-cbb245c0b6816c10be52a03a3ea8c66db8e0a7ae.tar.gz
px4-nuttx-cbb245c0b6816c10be52a03a3ea8c66db8e0a7ae.tar.bz2
px4-nuttx-cbb245c0b6816c10be52a03a3ea8c66db8e0a7ae.zip
More changes from Uros
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@3513 42af7a65-404d-4744-a932-0658087f49c3
Diffstat (limited to 'nuttx/include')
-rw-r--r--nuttx/include/nuttx/clock.h15
-rwxr-xr-xnuttx/include/nuttx/ptimer.h47
-rwxr-xr-xnuttx/include/nuttx/rtc.h118
3 files changed, 125 insertions, 55 deletions
diff --git a/nuttx/include/nuttx/clock.h b/nuttx/include/nuttx/clock.h
index 4d641696f..62bc29910 100644
--- a/nuttx/include/nuttx/clock.h
+++ b/nuttx/include/nuttx/clock.h
@@ -125,19 +125,18 @@
* access to kernel global data
*/
-#if !defined(CONFIG_PTIMER) && __HAVE_KERNEL_GLOBALS
+#if __HAVE_KERNEL_GLOBALS
extern volatile uint32_t g_system_timer;
-#define clock_systimer() g_system_timer
+extern volatile uint32_t g_uptime;
#endif
-/* System uptime (in seconds) is only supported by periodic timer hardware */
+#if !defined(CONFIG_RTC) && __HAVE_KERNEL_GLOBALS
+#define clock_systimer() g_system_timer
#if defined(CONFIG_UPTIME)
-extern volatile uint32_t g_uptime;
-
-#if __HAVE_KERNEL_GLOBALS
-# define clock_uptime() g_uptime
+#define clock_uptime() g_uptime
#endif
+
#endif
/****************************************************************************
@@ -170,7 +169,7 @@ extern "C" {
*
****************************************************************************/
-#if defined(CONFIG_PTIMER) || !__HAVE_KERNEL_GLOBALS
+#if defined(CONFIG_RTC) || !__HAVE_KERNEL_GLOBALS
EXTERN uint32_t clock_systimer(void);
#endif
diff --git a/nuttx/include/nuttx/ptimer.h b/nuttx/include/nuttx/ptimer.h
index 19d493bf7..a8bac82fe 100755
--- a/nuttx/include/nuttx/ptimer.h
+++ b/nuttx/include/nuttx/ptimer.h
@@ -42,21 +42,10 @@
#include <nuttx/config.h>
-#include <time.h>
-#include <stdint.h>
-#include <stdbool.h>
-
-#include <nuttx/clock.h>
-
-#ifdef CONFIG_PTIMER
-
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
-#define RTC_CLOCKS_PER_SEC 16384
-#define RTC_CLOCKS_SHIFT 14
-
/****************************************************************************
* Public Types
****************************************************************************/
@@ -65,15 +54,6 @@
* 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
****************************************************************************/
@@ -86,37 +66,10 @@ extern "C" {
#define EXTERN extern
#endif
-/****************************************************************************
- * Name: up_rtcinitialize
- *
- * Description:
- * Initialize the periodic timer interface. This function is called once
- * from the clock_initialize() function.
- *
- * Returned Value:
- * Returns OK if RTC has successfully started, otherwise ERROR.
- *
- ****************************************************************************/
-
-EXTERN int up_rtcinitialize(void);
-EXTERN int up_rtcinitialize(void);
-
-EXTERN clock_t up_rtc_getclock(void);
-EXTERN void up_rtc_setclock(clock_t clock);
-
-EXTERN time_t up_rtc_gettime(void);
-EXTERN void up_rtc_settime(time_t time);
-
-EXTERN clock_t up_rtc_setalarm(clock_t atclock);
-
-/* This callback is provided by the clock module and called by the RTC ISR */
-
-EXTERN void clock_rtcalarmcb(clock_t clock);
#undef EXTERN
#if defined(__cplusplus)
}
#endif
-#endif /* CONFIG_PTIMER */
#endif /* __INCLUDE_NUTTX_PTIMER_H */
diff --git a/nuttx/include/nuttx/rtc.h b/nuttx/include/nuttx/rtc.h
new file mode 100755
index 000000000..5d9ae6341
--- /dev/null
+++ b/nuttx/include/nuttx/rtc.h
@@ -0,0 +1,118 @@
+/****************************************************************************
+ * include/nuttx/rtc.h
+ *
+ * Copyright(C) 2011 Uros Platise. All rights reserved.
+ * Author: Uros Platise <uros.platise@isotel.eu>
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ * 3. Neither the name NuttX nor the names of its contributors may be
+ * used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES(INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ ****************************************************************************/
+
+#ifndef __INCLUDE_NUTTX_RTC_H
+#define __INCLUDE_NUTTX_RTC_H
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+
+#include <stdint.h>
+#include <stdbool.h>
+
+#include <nuttx/clock.h>
+
+/****************************************************************************
+ * Pre-processor Definitions
+ ****************************************************************************/
+
+#define RTC_CLOCKS_PER_SEC 16384
+#define RTC_CLOCKS_SHIFT 14
+
+/****************************************************************************
+ * Public Types
+ ****************************************************************************/
+
+/****************************************************************************
+ * 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
+ ****************************************************************************/
+
+#undef EXTERN
+#if defined(__cplusplus)
+#define EXTERN extern "C"
+extern "C" {
+#else
+#define EXTERN extern
+#endif
+
+/****************************************************************************
+ * Name: up_rtcinitialize
+ *
+ * Description:
+ * Initialize the periodic timer interface. This function is called once
+ * from the clock_initialize() function.
+ *
+ * Returned Value:
+ * Returns OK if RTC has successfully started, otherwise ERROR.
+ *
+ ****************************************************************************/
+
+EXTERN int up_rtcinitialize(void);
+EXTERN int up_rtcinitialize(void);
+
+EXTERN clock_t up_rtc_getclock(void);
+EXTERN void up_rtc_setclock(clock_t clock);
+
+EXTERN time_t up_rtc_gettime(void);
+EXTERN void up_rtc_settime(time_t time);
+
+EXTERN clock_t up_rtc_setalarm(clock_t atclock);
+
+/* This callback is provided by the clock module and called by the RTC ISR */
+
+EXTERN void clock_rtcalarmcb(clock_t clock);
+
+#undef EXTERN
+#if defined(__cplusplus)
+}
+#endif
+
+#endif /* __INCLUDE_NUTTX_RTC_H */