From 814f5d0b5e5a70bdec9ef88cabe0409bb8701e26 Mon Sep 17 00:00:00 2001 From: Tomasz Bursztyka Date: Mon, 4 Apr 2016 12:35:48 +0200 Subject: [PATCH] sys_clock: Add a helper to compute micro seconds As for SECONDS() and MSEC, now sys_clock.h provides a USEC() macro. Change-Id: I43e8b132d2deeb862d8cfda1f785115f339d6ddb Signed-off-by: Tomasz Bursztyka --- include/sys_clock.h | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/include/sys_clock.h b/include/sys_clock.h index 1e366986eca..3e463be1a2f 100644 --- a/include/sys_clock.h +++ b/include/sys_clock.h @@ -93,12 +93,15 @@ extern int sys_clock_hw_cycles_per_tick; extern int64_t _sys_clock_tick_count; /* - * Number of ticks for x seconds. NOTE: With MSEC(), since it does an integer - * division, x must be greater or equal to 1000/sys_clock_ticks_per_sec to get - * a non-zero value. + * Number of ticks for x seconds. NOTE: With MSEC() or USEC(), + * since it does an integer division, x must be greater or equal to + * 1000/sys_clock_ticks_per_sec to get a non-zero value. + * You may want to raise CONFIG_SYS_CLOCK_TICKS_PER_SEC depending on + * your requirements. */ -#define SECONDS(x) ((x) * sys_clock_ticks_per_sec) -#define MSEC(x) (SECONDS(x) / 1000) +#define SECONDS(x) ((x) * sys_clock_ticks_per_sec) +#define MSEC(x) (SECONDS(x) / MSEC_PER_SEC) +#define USEC(x) (MSEC(x) / USEC_PER_MSEC) #endif /* !_ASMLANGUAGE */