summaryrefslogtreecommitdiff
path: root/components/libc/posix/src/delay.c
diff options
context:
space:
mode:
Diffstat (limited to 'components/libc/posix/src/delay.c')
-rw-r--r--components/libc/posix/src/delay.c50
1 files changed, 50 insertions, 0 deletions
diff --git a/components/libc/posix/src/delay.c b/components/libc/posix/src/delay.c
new file mode 100644
index 0000000000..1638caafbf
--- /dev/null
+++ b/components/libc/posix/src/delay.c
@@ -0,0 +1,50 @@
+/*
+ * Copyright (c) 2006-2021, RT-Thread Development Team
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ *
+ * Change Logs:
+ * Date Author Notes
+ * 2021-05-07 Meco Man first Version
+ */
+#include <rtthread.h>
+#include <rthw.h>
+#define DBG_TAG "POSIX.delay"
+#define DBG_LVL DBG_INFO
+#include <rtdbg.h>
+
+RT_WEAK void rt_hw_us_delay(rt_uint32_t us)
+{
+ (void) us;
+ LOG_W("Please consider implementing rt_hw_us_delay() in another file.");
+}
+
+void msleep(unsigned int msecs)
+{
+ rt_thread_mdelay(msecs);
+}
+RTM_EXPORT(msleep);
+
+void ssleep(unsigned int seconds)
+{
+ msleep(seconds * 1000);
+}
+RTM_EXPORT(ssleep);
+
+void mdelay(unsigned long msecs)
+{
+ rt_hw_us_delay(msecs * 1000);
+}
+RTM_EXPORT(mdelay);
+
+void udelay(unsigned long usecs)
+{
+ rt_hw_us_delay(usecs);
+}
+RTM_EXPORT(udelay);
+
+void ndelay(unsigned long nsecs)
+{
+ rt_hw_us_delay(1);
+}
+RTM_EXPORT(ndelay);