From 93afe69c90f93cf713513e3fcf18e7f6515b21bf Mon Sep 17 00:00:00 2001 From: heyuanjie Date: Sat, 12 May 2018 12:08:47 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0mdelay=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- include/rtthread.h | 1 + src/thread.c | 17 +++++++++++++++++ 2 files changed, 18 insertions(+) diff --git a/include/rtthread.h b/include/rtthread.h index 9378b83cf7..1e9409b97b 100644 --- a/include/rtthread.h +++ b/include/rtthread.h @@ -149,6 +149,7 @@ rt_err_t rt_thread_delete(rt_thread_t thread); rt_err_t rt_thread_yield(void); rt_err_t rt_thread_delay(rt_tick_t tick); +rt_err_t rt_thread_mdelay(rt_int32_t ms); rt_err_t rt_thread_control(rt_thread_t thread, int cmd, void *arg); rt_err_t rt_thread_suspend(rt_thread_t thread); rt_err_t rt_thread_resume(rt_thread_t thread); diff --git a/src/thread.c b/src/thread.c index ea0ba0bfc9..0f0265fc35 100644 --- a/src/thread.c +++ b/src/thread.c @@ -537,6 +537,23 @@ rt_err_t rt_thread_delay(rt_tick_t tick) } RTM_EXPORT(rt_thread_delay); +/** + * This function will let current thread delay for some milliseconds. + * + * @param tick the delay time + * + * @return RT_EOK + */ +rt_err_t rt_thread_mdelay(rt_int32_t ms) +{ + rt_tick_t tick; + + tick = rt_tick_from_millisecond(ms); + + return rt_thread_sleep(tick); +} +RTM_EXPORT(rt_thread_mdelay); + /** * This function will control thread behaviors according to control command. *