!83 fix:Provide a system CPU wait interface

Merge pull request !83 from zhushengle/master
This commit is contained in:
openharmony_ci 2021-04-25 17:32:38 +08:00 committed by Gitee
commit b8cd812303
4 changed files with 24 additions and 11 deletions

View File

@ -639,7 +639,7 @@ osStatus_t osDelay(uint32_t ticks)
return osOK; return osOK;
} }
if (osKernelGetState() != osKernelRunning) { if (osKernelGetState() != osKernelRunning) {
HalDelay(ticks); LOS_UDelay(ticks * OS_US_PER_TICK);
} else { } else {
uwRet = LOS_TaskDelay(ticks); uwRet = LOS_TaskDelay(ticks);
} }

View File

@ -67,8 +67,6 @@ VOID HalClearSysSleepFlag(VOID);
VOID HalEnterSleep(LOS_SysSleepEnum sleep); VOID HalEnterSleep(LOS_SysSleepEnum sleep);
VOID HalDelay(UINT32 ticks);
/** /**
* @ingroup los_timer * @ingroup los_timer
* @brief Get systick cycle. * @brief Get systick cycle.

View File

@ -1088,25 +1088,24 @@ extern UINT32 LOS_NewTaskIDGet(VOID);
*/ */
extern CHAR* LOS_TaskNameGet(UINT32 taskID); extern CHAR* LOS_TaskNameGet(UINT32 taskID);
/* * /* *
* @ingroup los_hw * @ingroup los_task
* @brief: Function to determine whether task scheduling is required. * @brief: cpu delay.
* *
* @par Description: * @par Description:
* This API is used to Judge and entry task scheduling. * This API is used to cpu delay, no task switching.
* *
* @attention: * @attention:
* <ul><li>None.</li></ul> * <ul><li>None.</li></ul>
* *
* @param None. * @param UINT64 [IN] delay times, microseconds.
* *
* @retval: None. * @retval: None.
* @par Dependency: * @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. * @see None.
*/ */
extern VOID LOS_Schedule(VOID); extern VOID LOS_UDelay(UINT64 microseconds);
/** /**
* @ingroup los_cpup * @ingroup los_cpup

View File

@ -1296,3 +1296,19 @@ LITE_OS_SEC_TEXT_MINOR VOID LOS_Msleep(UINT32 mSecs)
(VOID)LOS_TaskDelay(interval); (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;
}