Skip to content

Commit

Permalink
sched/clock: call up_timer_gettime() to get higher resolution
Browse files Browse the repository at this point in the history
Signed-off-by: ligd <[email protected]>
  • Loading branch information
GUIDINGLI authored and xiaoxiang781216 committed Dec 12, 2024
1 parent 083027b commit 4a51c21
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 22 deletions.
6 changes: 0 additions & 6 deletions include/nuttx/clock.h
Original file line number Diff line number Diff line change
Expand Up @@ -334,10 +334,6 @@ extern "C"

#ifdef __HAVE_KERNEL_GLOBALS
EXTERN volatile clock_t g_system_ticks;

# ifndef CONFIG_SYSTEM_TIME64
# define clock_systime_ticks() g_system_ticks
# endif
#endif

/****************************************************************************
Expand Down Expand Up @@ -695,9 +691,7 @@ void clock_resynchronize(FAR struct timespec *rtc_diff);
*
****************************************************************************/

#if !defined(__HAVE_KERNEL_GLOBALS) || defined(CONFIG_SYSTEM_TIME64)
clock_t clock_systime_ticks(void);
#endif

/****************************************************************************
* Name: clock_systime_timespec
Expand Down
2 changes: 1 addition & 1 deletion sched/clock/clock.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
* Public Data
****************************************************************************/

#if !defined(CONFIG_SCHED_TICKLESS) && !defined(__HAVE_KERNEL_GLOBALS)
#if !defined(__HAVE_KERNEL_GLOBALS)
/* The system clock exists (CONFIG_SCHED_TICKLESS), but it not prototyped
* globally in include/nuttx/clock.h.
*/
Expand Down
12 changes: 3 additions & 9 deletions sched/clock/clock_systime_ticks.c
Original file line number Diff line number Diff line change
Expand Up @@ -85,19 +85,13 @@ clock_t clock_systime_ticks(void)

clock_systime_timespec(&ts);
return clock_time2ticks(&ts);
#elif defined(CONFIG_SCHED_TICKLESS_TICK_ARGUMENT)
#elif defined(CONFIG_ALARM_ARCH) || \
defined(CONFIG_TIMER_ARCH) || \
defined(CONFIG_SCHED_TICKLESS)
clock_t ticks = 0;

up_timer_gettick(&ticks);
return ticks;
#elif defined(CONFIG_SCHED_TICKLESS)
struct timespec ts =
{
0
};

up_timer_gettime(&ts);
return clock_time2ticks(&ts);
#elif defined(CONFIG_SYSTEM_TIME64)
clock_t sample;
clock_t verify;
Expand Down
9 changes: 3 additions & 6 deletions sched/clock/clock_systime_timespec.c
Original file line number Diff line number Diff line change
Expand Up @@ -77,12 +77,9 @@ int clock_systime_timespec(FAR struct timespec *ts)
ts->tv_sec = 0;
ts->tv_nsec = 0;
}
#elif defined(CONFIG_SCHED_TICKLESS_TICK_ARGUMENT)
clock_t ticks = 0;

up_timer_gettick(&ticks);
clock_ticks2time(ts, ticks);
#elif defined(CONFIG_SCHED_TICKLESS)
#elif defined(CONFIG_ALARM_ARCH) || \
defined(CONFIG_TIMER_ARCH) || \
defined(CONFIG_SCHED_TICKLESS)
up_timer_gettime(ts);
#else
clock_ticks2time(ts, g_system_ticks);
Expand Down

0 comments on commit 4a51c21

Please sign in to comment.