sys_clock: make public some timing utilities
Make these public: - SECONDS(x): macro that gives the number of ticks in x seconds - MSEC(x): macro that gives the number of ticks in x milliseconds - MSEC_PER_SEC: number of milliseconds per second - USEC_PER_MSEC: number of microseconds per millisecond Change-Id: Ic5dbf9349651a477b066edb0c6b6721da2b7e5bb Signed-off-by: Benjamin Walsh <benjamin.walsh@windriver.com>
This commit is contained in:
parent
4dca2dfad3
commit
2d12752637
5 changed files with 15 additions and 7 deletions
|
@ -68,6 +68,12 @@ extern int sys_clock_hw_cycles_per_tick;
|
|||
/* number of nsec per usec */
|
||||
#define NSEC_PER_USEC 1000
|
||||
|
||||
/* number of microseconds per millisecond */
|
||||
#define USEC_PER_MSEC 1000
|
||||
|
||||
/* number of milliseconds per second */
|
||||
#define MSEC_PER_SEC 1000
|
||||
|
||||
/* SYS_CLOCK_HW_CYCLES_TO_NS64 converts CPU clock cycles to nanoseconds */
|
||||
#define SYS_CLOCK_HW_CYCLES_TO_NS64(X) \
|
||||
(((uint64_t)(X) * sys_clock_us_per_tick * NSEC_PER_USEC) / \
|
||||
|
@ -85,6 +91,14 @@ extern int sys_clock_hw_cycles_per_tick;
|
|||
extern int64_t _nano_ticks;
|
||||
extern struct nano_timer *_nano_timer_list;
|
||||
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
#define SECONDS(x) ((x) * sys_clock_ticks_per_sec)
|
||||
#define MSEC(x) (SECONDS(x) / 1000)
|
||||
|
||||
#endif /* !_ASMLANGUAGE */
|
||||
|
||||
#endif /* _SYS_CLOCK__H_ */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue