File tree Expand file tree Collapse file tree 1 file changed +9
-6
lines changed Expand file tree Collapse file tree 1 file changed +9
-6
lines changed Original file line number Diff line number Diff line change @@ -573,6 +573,7 @@ rt_err_t rt_thread_delay_until(rt_tick_t *tick, rt_tick_t inc_tick)
573573{
574574 register rt_base_t level ;
575575 struct rt_thread * thread ;
576+ rt_tick_t cur_tick ;
576577
577578 RT_ASSERT (tick != RT_NULL );
578579
@@ -584,15 +585,19 @@ rt_err_t rt_thread_delay_until(rt_tick_t *tick, rt_tick_t inc_tick)
584585 /* disable interrupt */
585586 level = rt_hw_interrupt_disable ();
586587
587- if (rt_tick_get () - * tick < inc_tick )
588+ cur_tick = rt_tick_get ();
589+ if (cur_tick - * tick < inc_tick )
588590 {
589- * tick = * tick + inc_tick - rt_tick_get ();
591+ rt_tick_t left_tick ;
592+
593+ * tick += inc_tick ;
594+ left_tick = * tick - cur_tick ;
590595
591596 /* suspend thread */
592597 rt_thread_suspend (thread );
593598
594599 /* reset the timeout of thread timer and start it */
595- rt_timer_control (& (thread -> thread_timer ), RT_TIMER_CTRL_SET_TIME , tick );
600+ rt_timer_control (& (thread -> thread_timer ), RT_TIMER_CTRL_SET_TIME , & left_tick );
596601 rt_timer_start (& (thread -> thread_timer ));
597602
598603 /* enable interrupt */
@@ -608,12 +613,10 @@ rt_err_t rt_thread_delay_until(rt_tick_t *tick, rt_tick_t inc_tick)
608613 }
609614 else
610615 {
616+ * tick = cur_tick ;
611617 rt_hw_interrupt_enable (level );
612618 }
613619
614- /* get the wakeup tick */
615- * tick = rt_tick_get ();
616-
617620 return RT_EOK ;
618621}
619622RTM_EXPORT (rt_thread_delay_until );
You can’t perform that action at this time.
0 commit comments