更新日期: 2022/06/01 来源: https://gitee.com/weharmony/kernel_liteos_a_note
System time
System time 的协作图:

函数

UINT32 OsNS2Tick (UINT64 nanoseconds)
 纳秒转化成 tick 更多...
 
UINT64 LOS_TickCountGet (VOID)
 Obtain the number of Ticks. 更多...
 
UINT32 LOS_CyclePerTickGet (VOID)
 Obtain the number of cycles in one second. 更多...
 
UINT32 LOS_Tick2MS (UINT32 tick)
 Convert Ticks to milliseconds. 更多...
 
UINT32 LOS_MS2Tick (UINT32 millisec)
 Convert milliseconds to Ticks. 更多...
 

详细描述

函数说明

◆ LOS_CyclePerTickGet()

UINT32 LOS_CyclePerTickGet ( VOID  )

Obtain the number of cycles in one second.

Description:
This API is used to obtain the number of cycles in one second.
注意
  • None
参数
None
返回值
UINT32Number of cycles obtained in one second.
Dependency:
  • los_sys.h: the header file that contains the API declaration.
参见
None

Obtain the number of cycles in one second.

返回
LITE_OS_SEC_TEXT_MINOR

在文件 los_sys.c91 行定义.

92{
93 return g_sysClock / LOSCFG_BASE_CORE_TICK_PER_SECOND;
94}
LITE_OS_SEC_DATA_INIT UINT32 g_sysClock
系统时钟,是绝大部分部件工作的时钟源,也是其他所有外设的时钟的来源
Definition: los_tick.c:40

◆ LOS_MS2Tick()

UINT32 LOS_MS2Tick ( UINT32  millisec)

Convert milliseconds to Ticks.

Description:
This API is used to convert milliseconds to Ticks.
注意
  • If the parameter passed in is equal to 0xFFFFFFFF, the retval is 0xFFFFFFFF. Pay attention to the value to be converted because data possibly overflows.
参数
millisec[IN] Number of milliseconds.
返回值
UINT32Number of Ticks obtained through the conversion.
Dependency:
  • los_sys.h: the header file that contains the API declaration.
参见
LOS_Tick2MS

Convert milliseconds to Ticks.

参数
millisec
返回
LITE_OS_SEC_TEXT_MINOR

在文件 los_sys.c101 行定义.

102{
103 if (millisec == OS_MAX_VALUE) {
104 return OS_MAX_VALUE;
105 }
106
107 return ((UINT64)millisec * LOSCFG_BASE_CORE_TICK_PER_SECOND) / OS_SYS_MS_PER_SECOND;
108}
long unsigned int UINT64
Definition: los_typedef.h:66
这是这个函数的调用关系图:

◆ LOS_Tick2MS()

UINT32 LOS_Tick2MS ( UINT32  tick)

Convert Ticks to milliseconds.

Description:
This API is used to convert Ticks to milliseconds.
注意
  • The number of milliseconds obtained through the conversion is 32-bit.
参数
tick[IN] Number of Ticks. The value range is (0,OS_SYS_CLOCK).
返回值
UINT32Number of milliseconds obtained through the conversion. Ticks are successfully converted to milliseconds.
Dependency:
  • los_sys.h: the header file that contains the API declaration.
参见
LOS_MS2Tick

Convert Ticks to milliseconds.

参数
tick
返回
LITE_OS_SEC_TEXT_MINOR

在文件 los_sys.c115 行定义.

116{
117 return ((UINT64)tick * OS_SYS_MS_PER_SECOND) / LOSCFG_BASE_CORE_TICK_PER_SECOND;
118}

◆ LOS_TickCountGet()

UINT64 LOS_TickCountGet ( VOID  )

Obtain the number of Ticks.

Description:
This API is used to obtain the number of Ticks.
注意
  • None
参数
None
返回值
UINT64The number of Ticks.
Dependency:
  • los_sys.h: the header file that contains the API declaration.
参见
None

Obtain the number of Ticks.

返回
LITE_OS_SEC_TEXT_MINOR

在文件 los_sys.c82 行定义.

83{
84 return OsGetCurrSchedTimeCycle() / OS_CYCLE_PER_TICK;
85}
STATIC INLINE UINT64 OsGetCurrSchedTimeCycle(VOID)
Definition: los_sched_pri.h:75
函数调用图:
这是这个函数的调用关系图:

◆ OsNS2Tick()

UINT32 OsNS2Tick ( UINT64  nanoseconds)

纳秒转化成 tick

Convert nanoseconds to Ticks.

参数
nanoseconds
返回
LITE_OS_SEC_TEXT_MINOR

在文件 los_sys.c125 行定义.

126{
127 const UINT32 nsPerTick = OS_SYS_NS_PER_SECOND / LOSCFG_BASE_CORE_TICK_PER_SECOND;
128
129 UINT64 ticks = (nanoseconds + nsPerTick - 1) / nsPerTick;
130 if (ticks > OS_MAX_VALUE) {
131 ticks = OS_MAX_VALUE;
132 }
133 return (UINT32)ticks;
134}
unsigned int UINT32
Definition: los_typedef.h:57
这是这个函数的调用关系图: