summaryrefslogtreecommitdiff
path: root/nuttx/sched/clock_initialize.c
diff options
context:
space:
mode:
authorpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2011-12-14 14:47:42 +0000
committerpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2011-12-14 14:47:42 +0000
commit8d4650b7597e5653bd1fb67fc7212793967d0673 (patch)
treeca365bb83241b1f0b5e40f4bd8163a07b9b0eb46 /nuttx/sched/clock_initialize.c
parent891096cafd0ea56d923fb06ea81190bfb8d956e9 (diff)
downloadpx4-nuttx-8d4650b7597e5653bd1fb67fc7212793967d0673.tar.gz
px4-nuttx-8d4650b7597e5653bd1fb67fc7212793967d0673.tar.bz2
px4-nuttx-8d4650b7597e5653bd1fb67fc7212793967d0673.zip
Re-arrange some files and interfaces to support the STM32 F4 date/time RTC
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@4175 42af7a65-404d-4744-a932-0658087f49c3
Diffstat (limited to 'nuttx/sched/clock_initialize.c')
-rw-r--r--nuttx/sched/clock_initialize.c25
1 files changed, 23 insertions, 2 deletions
diff --git a/nuttx/sched/clock_initialize.c b/nuttx/sched/clock_initialize.c
index 8041333c4..b7c5cdd9d 100644
--- a/nuttx/sched/clock_initialize.c
+++ b/nuttx/sched/clock_initialize.c
@@ -103,7 +103,26 @@ struct timespec g_basetime;
****************************************************************************/
#ifdef CONFIG_RTC
-#ifdef CONFIG_RTC_HIRES
+#if defined(CONFIG_RTC_DATETIME)
+/* Initialize the system time using a broken out date/time structure */
+
+static inline void clock_inittime(FAR struct timespec *tp)
+{
+ struct tm rtctime;
+
+ /* Get the broken-out time from the date/time RTC. */
+
+ (void)up_rtc_getdatetime(&rtctime);
+
+ /* And use the broken-out time to initialize the system time */
+
+ tp->tv_sec = mktime(&rtctime);
+ tp->tv_nsec = 0;
+}
+
+#elif defined(CONFIG_RTC_HIRES)
+
+/* Initialize the system time using a high-resolution structure */
static inline void clock_inittime(FAR struct timespec *tp)
{
@@ -114,9 +133,11 @@ static inline void clock_inittime(FAR struct timespec *tp)
#else
+/* Initialize the system time using seconds only */
+
static inline void clock_inittime(FAR struct timespec *tp)
{
- /* Get the seconds (only) from the lo-res RTC */
+ /* Get the seconds (only) from the lo-resolution RTC */
tp->tv_sec = up_rtc_time();
tp->tv_nsec = 0;