kernel: Deprecate sys_clock_us_per_tick variable.
On some architectures tick time cannot be expressed as integer number of microseconds, introducing error in calculations using sys_clock_us_per_tick variable. This commit deprecates the sys_clock_us_per_tick variable and replaces its usage by more precise calculations based on sys_clock_hw_cycles_per_sec and sys_clock_ticks_per_sec. Signed-off-by: Piotr Zięcik <piotr.ziecik@nordicsemi.no>
This commit is contained in:
parent
408a580644
commit
2fe998cdef
7 changed files with 14 additions and 14 deletions
|
@ -21,6 +21,7 @@ extern "C" {
|
|||
#endif
|
||||
|
||||
#ifndef _ASMLANGUAGE
|
||||
#include <toolchain.h>
|
||||
#include <zephyr/types.h>
|
||||
|
||||
#if defined(CONFIG_SYS_CLOCK_EXISTS) && \
|
||||
|
@ -46,8 +47,10 @@ extern int sys_clock_hw_cycles_per_sec;
|
|||
/*
|
||||
* sys_clock_us_per_tick global variable represents a number
|
||||
* of microseconds in one OS timer tick
|
||||
*
|
||||
* Note: This variable is deprecated and will be removed soon!
|
||||
*/
|
||||
extern int sys_clock_us_per_tick;
|
||||
__deprecated extern int sys_clock_us_per_tick;
|
||||
|
||||
/*
|
||||
* sys_clock_hw_cycles_per_tick global variable represents a number
|
||||
|
@ -75,8 +78,7 @@ extern int sys_clock_hw_cycles_per_tick;
|
|||
|
||||
/* SYS_CLOCK_HW_CYCLES_TO_NS64 converts CPU clock cycles to nanoseconds */
|
||||
#define SYS_CLOCK_HW_CYCLES_TO_NS64(X) \
|
||||
(((u64_t)(X) * sys_clock_us_per_tick * NSEC_PER_USEC) / \
|
||||
sys_clock_hw_cycles_per_tick)
|
||||
(((u64_t)(X) * NSEC_PER_SEC) / sys_clock_hw_cycles_per_sec)
|
||||
|
||||
/*
|
||||
* SYS_CLOCK_HW_CYCLES_TO_NS_AVG converts CPU clock cycles to nanoseconds
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue