提交 b8cd8123 编写于 作者: O openharmony_ci 提交者: Gitee

!83 fix:Provide a system CPU wait interface

Merge pull request !83 from zhushengle/master
......@@ -639,7 +639,7 @@ osStatus_t osDelay(uint32_t ticks)
return osOK;
}
if (osKernelGetState() != osKernelRunning) {
HalDelay(ticks);
LOS_UDelay(ticks * OS_US_PER_TICK);
} else {
uwRet = LOS_TaskDelay(ticks);
}
......
......@@ -67,9 +67,7 @@ VOID HalClearSysSleepFlag(VOID);
VOID HalEnterSleep(LOS_SysSleepEnum sleep);
VOID HalDelay(UINT32 ticks);
/**
/**
* @ingroup los_timer
* @brief Get systick cycle.
*
......
......@@ -1088,25 +1088,24 @@ extern UINT32 LOS_NewTaskIDGet(VOID);
*/
extern CHAR* LOS_TaskNameGet(UINT32 taskID);
/* *
* @ingroup los_hw
* @brief: Function to determine whether task scheduling is required.
* @ingroup los_task
* @brief: cpu delay.
*
* @par Description:
* This API is used to Judge and entry task scheduling.
* This API is used to cpu delay, no task switching.
*
* @attention:
* <ul><li>None.</li></ul>
*
* @param None.
* @param UINT64 [IN] delay times, microseconds.
*
* @retval: None.
* @par Dependency:
* <ul><li>los_hw.h: the header file that contains the API declaration.</li></ul>
* <ul><li>los_task.h: the header file that contains the API declaration.</li></ul>
* @see None.
*/
extern VOID LOS_Schedule(VOID);
extern VOID LOS_UDelay(UINT64 microseconds);
/**
* @ingroup los_cpup
......
......@@ -1296,3 +1296,19 @@ LITE_OS_SEC_TEXT_MINOR VOID LOS_Msleep(UINT32 mSecs)
(VOID)LOS_TaskDelay(interval);
}
VOID LOS_UDelay(UINT64 microseconds)
{
UINT64 endTime;
if (microseconds == 0) {
return;
}
endTime = (microseconds / OS_SYS_US_PER_SECOND) * OS_SYS_CLOCK +
(microseconds % OS_SYS_US_PER_SECOND) * OS_SYS_CLOCK / OS_SYS_US_PER_SECOND;
endTime = LOS_SysCycleGet() + endTime;
while (LOS_SysCycleGet() < endTime) {
}
return;
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册