summaryrefslogtreecommitdiff
path: root/src/timer.c
diff options
context:
space:
mode:
authorlongtengmcu <[email protected]>2020-02-07 16:43:39 +0800
committerlongtengmcu <[email protected]>2020-02-07 16:43:39 +0800
commit720d8479a574746020747ef36bc33a8159206289 (patch)
tree7abc7d2dc04325098542f1d7519026d30a4d9a6c /src/timer.c
parentbad4f924514a287b75af189c8bd1418935188a47 (diff)
给软件定时器增加定时器工作状态查询的功能
Diffstat (limited to 'src/timer.c')
-rw-r--r--src/timer.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/timer.c b/src/timer.c
index d85ee080b5..0034f0246c 100644
--- a/src/timer.c
+++ b/src/timer.c
@@ -488,6 +488,19 @@ rt_err_t rt_timer_control(rt_timer_t timer, int cmd, void *arg)
case RT_TIMER_CTRL_SET_PERIODIC:
timer->parent.flag |= RT_TIMER_FLAG_PERIODIC;
break;
+ /* zhaoshimin 20191204 add query the timer state */
+ case RT_TIMER_CTRL_GET_STATE:
+ if(timer->parent.flag & RT_TIMER_FLAG_ACTIVATED)
+ {
+ /*timer is start and run*/
+ *(rt_tick_t *)arg = RT_TIMER_FLAG_ACTIVATED;
+ }
+ else
+ {
+ /*timer is stop*/
+ *(rt_tick_t *)arg = RT_TIMER_FLAG_DEACTIVATED;
+ }
+ break;
}
return RT_EOK;