4
0
mirror of https://github.com/RT-Thread/rt-thread.git synced 2025-02-18 19:59:13 +08:00

[libc]优化usleep函数

This commit is contained in:
chinky 2023-03-30 11:25:18 +08:00 committed by Man, Jianting (Meco)
parent 38eb3fc40f
commit b9f5bf7d91

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2006-2021, RT-Thread Development Team * Copyright (c) 2006-2023, RT-Thread Development Team
* *
* SPDX-License-Identifier: Apache-2.0 * SPDX-License-Identifier: Apache-2.0
* *
@ -66,12 +66,12 @@ int usleep(useconds_t usec)
if (rt_thread_self() != RT_NULL) if (rt_thread_self() != RT_NULL)
{ {
msleep(usec / 1000u); msleep(usec / 1000u);
udelay(usec % 1000u);
} }
else /* scheduler has not run yet */ else /* scheduler has not run yet */
{ {
udelay(usec / 1000u * 1000u); udelay(usec);
} }
udelay(usec % 1000u);
return 0; return 0;
} }