WS63 SDK 文档 7021f4f@fbb_ws63
ws63 和 ws63e 解决方案的 SDK 文档
载入中...
搜索中...
未找到
Tick
Tick 的协作图:

结构体

struct  tagSysTime
 

宏定义

#define OS_SYS_MS_PER_SECOND   1000
 
#define OS_SYS_US_PER_SECOND   1000000
 
#define OS_SYS_NS_PER_SECOND   1000000000
 
#define OS_SYS_US_PER_MS   1000
 
#define OS_SYS_NS_PER_MS   1000000
 
#define OS_SYS_NS_PER_US   1000
 
#define LOS_ERRNO_TICK_CFG_INVALID   LOS_ERRNO_OS_ERROR(LOS_MOD_TICK, 0x00)
 
#define LOS_ERRNO_TICK_NO_HWTIMER   LOS_ERRNO_OS_ERROR(LOS_MOD_TICK, 0x01)
 
#define LOS_ERRNO_TICK_PER_SEC_TOO_SMALL   LOS_ERRNO_OS_ERROR(LOS_MOD_TICK, 0x02)
 

类型定义

typedef struct tagSysTime SYS_TIME_S
 

函数

UINT64 LOS_TickCountGet (void)
 Obtain the number of Ticks.
 
UINT32 LOS_CyclePerTickGet (void)
 Obtain the number of cycles in one tick.
 
UINT32 LOS_Tick2MS (UINT32 tick)
 Convert Ticks to milliseconds.
 
UINT32 LOS_MS2Tick (UINT32 millisec)
 Convert milliseconds to Ticks.
 
void LOS_GetCpuCycle (UINT32 *puwCntHi, UINT32 *puwCntLo)
 Obtain system cycle count.
 
UINT64 LOS_CurrNanosec (void)
 Obtain system time in nanoseconds.
 
void LOS_Udelay (UINT32 usecs)
 spinning-delay in microsecond (us).
 
void LOS_Mdelay (UINT32 msecs)
 spinning-delay in millisecond (ms).
 

详细描述

宏定义说明

◆ LOS_ERRNO_TICK_CFG_INVALID

#define LOS_ERRNO_TICK_CFG_INVALID   LOS_ERRNO_OS_ERROR(LOS_MOD_TICK, 0x00)

Tick error code: The Tick configuration is incorrect.

Value: 0x02000400.

Solution: Change values of the OS_SYS_CLOCK and #LOSCFG_BASE_CORE_TICK_PER_SECOND in los_config.h.

◆ LOS_ERRNO_TICK_NO_HWTIMER

#define LOS_ERRNO_TICK_NO_HWTIMER   LOS_ERRNO_OS_ERROR(LOS_MOD_TICK, 0x01)

Tick error code: This error code is not in use temporarily.

Value: 0x02000401

弃用:
This error code is obsolete since LiteOS 5.0.0.

◆ LOS_ERRNO_TICK_PER_SEC_TOO_SMALL

#define LOS_ERRNO_TICK_PER_SEC_TOO_SMALL   LOS_ERRNO_OS_ERROR(LOS_MOD_TICK, 0x02)

Tick error code: This error code is not in use temporarily.

Value: 0x02000402

弃用:
This error code is obsolete since LiteOS 5.0.0.

◆ OS_SYS_MS_PER_SECOND

#define OS_SYS_MS_PER_SECOND   1000

Number of milliseconds in one second.

◆ OS_SYS_NS_PER_MS

#define OS_SYS_NS_PER_MS   1000000

Number of nanoseconds in one milliseconds.

◆ OS_SYS_NS_PER_SECOND

#define OS_SYS_NS_PER_SECOND   1000000000

Number of nanoseconds in one second.

◆ OS_SYS_NS_PER_US

#define OS_SYS_NS_PER_US   1000

Number of nanoseconds in one microsecond.

◆ OS_SYS_US_PER_MS

#define OS_SYS_US_PER_MS   1000

Number of microseconds in one milliseconds.

◆ OS_SYS_US_PER_SECOND

#define OS_SYS_US_PER_SECOND   1000000

Number of microseconds in one second.

类型定义说明

◆ SYS_TIME_S

typedef struct tagSysTime SYS_TIME_S

system time structure.

函数说明

◆ LOS_CurrNanosec()

UINT64 LOS_CurrNanosec ( void  )
extern

Obtain system time in nanoseconds.

Description:
This API is used to obtain system time in nanoseconds.
注意
  • Depending on the clock frequency, the returned value may be incorrect after a long time (about 213.5 days based on the 1 GHz clock frequency). Do not use this function to obtain the exact time when the function is running continuously for a long time.
参数
None.
返回值
UINT64system time in nanoseconds.
Dependency:
  • los_tick.h: the header file that contains the API declaration.
自从
Huawei LiteOS V100R001C00

◆ LOS_CyclePerTickGet()

UINT32 LOS_CyclePerTickGet ( void  )
extern

Obtain the number of cycles in one tick.

Description:
This API is used to obtain the number of cycles in one tick.
注意
None.
参数
None.
返回值
UINT32Number of cycles in one tick.
Dependency:
  • los_tick.h: the header file that contains the API declaration.
自从
Huawei LiteOS V100R001C00

◆ LOS_GetCpuCycle()

void LOS_GetCpuCycle ( UINT32 puwCntHi,
UINT32 puwCntLo 
)
extern

Obtain system cycle count.

Description:
This API is used to obtain system cycle count since the system startup.
注意
  • This count is determined by the tick source.
  • Parameters of this interface are pointers, it should be a correct value. Otherwise, the system may be abnormal.
参数
puwCntHi[OUT] Type UINT32 Pointer to the higher 32bit of cycles to be obtained.
puwCntLo[OUT] Type UINT32 Pointer to the lower 32bit of cycles to be obtained.
返回值
None.
Dependency:
  • los_tick.h: the header file that contains the API declaration.
参见
LOS_TickCountGet
自从
Huawei LiteOS V100R001C00

◆ LOS_Mdelay()

void LOS_Mdelay ( UINT32  msecs)
extern

spinning-delay in millisecond (ms).

Description:
This API is used to delay in millisecond.
注意
None.
参数
msecsmillisecond needs to delay.
返回值
None.
Dependency:
  • los_tick.h: the header file that contains the API declaration.
参见
LOS_Udelay
自从
Huawei LiteOS V100R001C00

◆ LOS_MS2Tick()

UINT32 LOS_MS2Tick ( UINT32  millisec)
extern

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 may overflows.
  • This API is not an accurate function, and the calculation result is rounded up.
参数
millisec[IN] The milliseconds need to be converted to Ticks. If KERNEL_TICK_PER_SECOND > OS_SYS_MS_PER_SECOND, the value range is (0, 0xFFFFFFFF * OS_SYS_MS_PER_SECOND / KERNEL_TICK_PER_SECOND). If KERNEL_TICK_PER_SECOND <= OS_SYS_MS_PER_SECOND, the value range is (0, 0xFFFFFFFF].
返回值
UINT32Number of Ticks obtained through the conversion. If 32-bit integer overflow occurs in the conversion, retval will be fixed at 0xFFFFFFFF.
Dependency:
  • los_tick.h: the header file that contains the API declaration.
参见
LOS_Tick2MS
自从
Huawei LiteOS V100R001C00

◆ LOS_Tick2MS()

UINT32 LOS_Tick2MS ( UINT32  tick)
extern

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. Pay attention to the value to be converted because data possibly overflows.
参数
tick[IN] Number of Ticks. If KERNEL_TICK_PER_SECOND > OS_SYS_MS_PER_SECOND, the value range is (0, 0xFFFFFFFF]. If KERNEL_TICK_PER_SECOND <= OS_SYS_MS_PER_SECOND, the value range is (0, 0xFFFFFFFF * KERNEL_TICK_PER_SECOND / OS_SYS_MS_PER_SECOND].
返回值
UINT32Milliseconds obtained through the conversion. If 32-bit integer overflow occurs in the conversion, retval will be fixed at 0xFFFFFFFF.
Dependency:
  • los_tick.h: the header file that contains the API declaration.
参见
LOS_MS2Tick
自从
Huawei LiteOS V100R001C00

◆ LOS_TickCountGet()

UINT64 LOS_TickCountGet ( void  )
extern

Obtain the number of Ticks.

Description:
This API is used to obtain the number of Ticks since the system startup.
注意
None.
参数
None
返回值
UINT64The number of Ticks.
Dependency:
  • los_tick.h: the header file that contains the API declaration.
参见
LOS_GetCpuCycle
自从
Huawei LiteOS V100R001C00

◆ LOS_Udelay()

void LOS_Udelay ( UINT32  usecs)
extern

spinning-delay in microsecond (us).

Description:
This API is used to delay in microsecond.
注意
None.
参数
usecsmicrosecond needs to delay.
返回值
None.
Dependency:
  • los_tick.h: the header file that contains the API declaration.
参见
LOS_Mdelay
自从
Huawei LiteOS V100R001C00