summaryrefslogtreecommitdiff
path: root/src/timer.c
diff options
context:
space:
mode:
authorbernard.xiong <[email protected]>2009-10-19 12:11:17 +0000
committerbernard.xiong <[email protected]>2009-10-19 12:11:17 +0000
commit39ff7577053ab59dfe363280421df1236bffa01c (patch)
treea36152c1e16f8cd418f9ab4785ea970c55da2054 /src/timer.c
parent597015a3fefc678390369d2b668ac4918799c5ab (diff)
fix timer re-start issue if stop a timer in itself timeout_func.
git-svn-id: https://rt-thread.googlecode.com/svn/trunk@107 bbd45198-f89e-11dd-88c7-29a3b14d5316
Diffstat (limited to 'src/timer.c')
-rw-r--r--src/timer.c15
1 files changed, 11 insertions, 4 deletions
diff --git a/src/timer.c b/src/timer.c
index 558cbfac35..f35ce8e964 100644
--- a/src/timer.c
+++ b/src/timer.c
@@ -270,6 +270,9 @@ rt_err_t rt_timer_stop(rt_timer_t timer)
/* disable interrupt */
level = rt_hw_interrupt_disable();
+ /* change stat */
+ timer->parent.flag &= ~RT_TIMER_FLAG_ACTIVATED;
+
/* remove it from timer list */
rt_list_remove(&(timer->list));
@@ -361,14 +364,18 @@ void rt_timer_check()
rt_kprintf("current tick: %d\n", current_tick);
#endif
- /* change timer state */
- t->parent.flag &= ~RT_TIMER_FLAG_ACTIVATED;
-
- if (t->parent.flag & RT_TIMER_FLAG_PERIODIC)
+ if ((t->parent.flag & RT_TIMER_FLAG_PERIODIC) &&
+ (t->parent.flag & RT_TIMER_FLAG_ACTIVATED))
{
/* start it */
+ t->parent.flag &= ~RT_TIMER_FLAG_ACTIVATED;
rt_timer_start(t);
}
+ else
+ {
+ /* stop timer */
+ t->parent.flag &= ~RT_TIMER_FLAG_ACTIVATED;
+ }
}
else break;
}