summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorguozhanxin <[email protected]>2021-06-15 18:29:58 +0800
committerguozhanxin <[email protected]>2021-06-15 18:37:39 +0800
commit66b7289ee75653f6024ca3b9c0bdff96fe0bc046 (patch)
treebd8f7c79d79556366a3b058e6cf6e2e02820e3a3
parent8a274211f12214345cbcd82e8e92b658a54154f1 (diff)
[update] usleep supports calling in interrupts.
-rw-r--r--components/libc/compilers/common/unistd.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/components/libc/compilers/common/unistd.c b/components/libc/compilers/common/unistd.c
index 6c81fc7662..4385643f31 100644
--- a/components/libc/compilers/common/unistd.c
+++ b/components/libc/compilers/common/unistd.c
@@ -55,7 +55,14 @@ RTM_EXPORT(sleep);
int usleep(useconds_t usec)
{
- rt_thread_mdelay(usec / 1000u);
+ if (rt_thread_self() != RT_NULL)
+ {
+ rt_thread_mdelay(usec / 1000u);
+ }
+ else
+ {
+ rt_hw_us_delay(usec / 1000u);
+ }
rt_hw_us_delay(usec % 1000u);
return 0;
}