Browse Source

[update] usleep supports calling in interrupts.

guozhanxin 3 years ago
parent
commit
66b7289ee7
1 changed files with 8 additions and 1 deletions
  1. 8 1
      components/libc/compilers/common/unistd.c

+ 8 - 1
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;
 }