diff options
| author | guo <[email protected]> | 2021-06-15 18:49:57 +0800 |
|---|---|---|
| committer | GitHub <[email protected]> | 2021-06-15 18:49:57 +0800 |
| commit | 302c8bf23f93a74f2b4f40f6b2c1dc45fe43aa0b (patch) | |
| tree | bd8f7c79d79556366a3b058e6cf6e2e02820e3a3 | |
| parent | 8a274211f12214345cbcd82e8e92b658a54154f1 (diff) | |
| parent | 66b7289ee75653f6024ca3b9c0bdff96fe0bc046 (diff) | |
Merge pull request #4797 from Guozhanxin/usleep
[update] usleep supports calling in interrupts.
| -rw-r--r-- | components/libc/compilers/common/unistd.c | 9 |
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; } |
