/* This function will let current thread sleep for some ticks. */
rt_err_t rt_thread_sleep(rt_tick_t tick)
/* This function will let current thread sleep for some ticks. */
rt_err_t rt_thread_sleep(rt_tick_t tick)
{
    register rt_base_t temp;
    struct rt_thread *thread;
    thread = rt_thread_self();
    RT_ASSERT(thread != RT_NULL);
    RT_ASSERT(rt_object_get_type((rt_object_t)thread) == RT_Object_Class_Thread);
    temp = rt_hw_interrupt_disable();
    rt_thread_suspend(thread);
    rt_timer_control(&(thread->thread_timer), RT_TIMER_CTRL_SET_TIME, &tick);
    rt_timer_start(&(thread->thread_timer));
    rt_hw_interrupt_enable(temp);
    rt_schedule();
    if (thread->error == -RT_ETIMEOUT)
        thread->error = RT_EOK;
    return RT_EOK;
}