diff options
author | patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3> | 2011-10-02 14:16:30 +0000 |
---|---|---|
committer | patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3> | 2011-10-02 14:16:30 +0000 |
commit | bbadecee80cf2f48a43097328bb24b73f236934c (patch) | |
tree | e3a769b2f63c911bbc57c0e60b863aa996ea9dbb /nuttx/sched/clock_initialize.c | |
parent | 078ff53de7f505ba714be768a94c1e52e7261b3e (diff) | |
download | px4-nuttx-bbadecee80cf2f48a43097328bb24b73f236934c.tar.gz px4-nuttx-bbadecee80cf2f48a43097328bb24b73f236934c.tar.bz2 px4-nuttx-bbadecee80cf2f48a43097328bb24b73f236934c.zip |
Remove support for UTC time; add support for 64-bit time
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@4006 42af7a65-404d-4744-a932-0658087f49c3
Diffstat (limited to 'nuttx/sched/clock_initialize.c')
-rw-r--r-- | nuttx/sched/clock_initialize.c | 84 |
1 files changed, 10 insertions, 74 deletions
diff --git a/nuttx/sched/clock_initialize.c b/nuttx/sched/clock_initialize.c index ed3a25828..2ffdd5819 100644 --- a/nuttx/sched/clock_initialize.c +++ b/nuttx/sched/clock_initialize.c @@ -38,6 +38,7 @@ ****************************************************************************/ #include <nuttx/config.h> +#include <nuttx/compiler.h> #include <stdint.h> #include <time.h> @@ -53,27 +54,12 @@ /**************************************************************************** * Definitions ****************************************************************************/ - -#ifdef CONFIG_RTC -# ifndef CONFIG_SYSTEM_UTC -# error "In order to support hardware RTC system must have set the CONFIG_SYSTEM_UTC=y" -# endif -#endif - /* Standard time definitions (in units of seconds) */ #define SEC_PER_MIN ((time_t)60) #define SEC_PER_HOUR ((time_t)60 * SEC_PER_MIN) #define SEC_PER_DAY ((time_t)24 * SEC_PER_HOUR) -/* Macro to increment the system timer -- or not */ - -#ifndef CONFIG_SYSTEM_UTC -# define incr_systimer() g_system_timer++ -#else -# define incr_systimer() -#endif - /**************************************************************************** * Private Type Declarations ****************************************************************************/ @@ -90,59 +76,23 @@ * Public Variables ****************************************************************************/ -#if CONFIG_SYSTEM_UTC -volatile time_t g_system_utc; +#ifdef CONFIG_SYSTEM_TIME64 +volatile uint64_t g_system_timer; +uint64_t g_tickbias; #else -volatile clock_t g_system_timer; -struct timespec g_basetime; -uint32_t g_tickbias; +volatile uint32_t g_system_timer; +uint32_t g_tickbias; #endif +struct timespec g_basetime; + /************************************************************************** * Private Variables **************************************************************************/ -/* This variable is used to count ticks and to increment the one-second - * UTC variable. - */ - -#if CONFIG_SYSTEM_UTC -#if TICK_PER_SEC > 32767 -volatile uint32_t g_tickcount; -#elif TICK_PER_SEC > 255 -volatile uint16_t g_tickcount; -#else -volatile uint8_t g_tickcount; -#endif -#endif /* CONFIG_SYSTEM_UTC */ - /************************************************************************** * Private Functions **************************************************************************/ -/**************************************************************************** - * Function: incr_utc - * - * Description: - * This function must be called once every time the real - * time clock interrupt occurs. The interval of this - * clock interrupt must be MSEC_PER_TICK - * - ****************************************************************************/ - -#if CONFIG_SYSTEM_UTC -static inline void incr_utc(void) -{ - g_tickcount++; - - if (g_tickcount >= TICK_PER_SEC) - { - g_system_utc++; - g_tickcount -= TICK_PER_SEC; - } -} -#else -# define incr_utc() -#endif /**************************************************************************** * Function: clock_inittime @@ -210,27 +160,17 @@ static inline void clock_inittime(FAR struct timespec *tp) void clock_initialize(void) { -#ifdef CONFIG_SYSTEM_UTC - struct timespec ts; -#endif - /* Initialize the RTC hardware */ #ifdef CONFIG_RTC up_rtcinitialize(); #endif - /* Initialize the time value */ + /* Initialize the time value to match */ -#ifdef CONFIG_SYSTEM_UTC - clock_inittime(&ts); - g_system_utc = ts.tv_sec; - g_tickcount = ((ts.tv_nsec > 10) * CLOCKS_PER_SEC) / (1000000000 >> 10); -#else clock_inittime(&g_basetime); g_system_timer = 0; g_tickbias = 0; -#endif } /**************************************************************************** @@ -247,9 +187,5 @@ void clock_timer(void) { /* Increment the per-tick system counter */ - incr_systimer(); - - /* Increment the per-second UTC counter */ - - incr_utc(); + g_system_timer++; } |