summaryrefslogtreecommitdiff
path: root/examples/kernel/timer_simple.c
diff options
context:
space:
mode:
authorbernard.xiong <[email protected]>2010-03-23 09:45:58 +0000
committerbernard.xiong <[email protected]>2010-03-23 09:45:58 +0000
commit8d4da31b8e909597cc898f913e1c42b271e690fe (patch)
tree6796a79075a54a40773b9a06c66c4455983731f1 /examples/kernel/timer_simple.c
parent8d19f32ac25997d0045f5abfc2d7ff7ca9bd26ed (diff)
add more Chinese comments.
git-svn-id: https://rt-thread.googlecode.com/svn/trunk@525 bbd45198-f89e-11dd-88c7-29a3b14d5316
Diffstat (limited to 'examples/kernel/timer_simple.c')
-rw-r--r--examples/kernel/timer_simple.c26
1 files changed, 17 insertions, 9 deletions
diff --git a/examples/kernel/timer_simple.c b/examples/kernel/timer_simple.c
index 30d9e63f59..2063a88119 100644
--- a/examples/kernel/timer_simple.c
+++ b/examples/kernel/timer_simple.c
@@ -1,7 +1,7 @@
/*
* 程序清单:定时器例程
*
- * 这个程序会初始化2个静态定时器,一个是一次定时,一个是周期性的定时
+ * 这个程序会初始化2个静态定时器,一个是单次定时,一个是周期性的定时
*/
#include <rtthread.h>
#include "tc_comm.h"
@@ -22,6 +22,17 @@ void timeout2(void* parameter)
rt_kprintf("one shot timer is timeout\n");
}
+void timer_simple_init()
+{
+ /* 初始化定时器 */
+ rt_timer_init(&timer1, "timer1", timeout1, RT_NULL, 10, RT_TIMER_FLAG_PERIODIC);
+ rt_timer_init(&timer2, "timer2", timeout2, RT_NULL, 30, RT_TIMER_FLAG_ONE_SHOT);
+
+ /* 启动定时器 */
+ rt_timer_start(&timer1);
+ rt_timer_start(&timer2);
+}
+
#ifdef RT_USING_TC
static void _tc_cleanup()
{
@@ -39,27 +50,24 @@ static void _tc_cleanup()
tc_done(TC_STAT_PASSED);
}
-int _tc_thread_timer_simple()
+int _tc_timer_simple()
{
/* 设置TestCase清理回调函数 */
tc_cleanup(_tc_cleanup);
- rt_timer_init(&timer1, "timer1", timeout1, RT_NULL, 10, RT_TIMER_FLAG_PERIODIC);
- rt_timer_init(&timer2, "timer2", timeout2, RT_NULL, 30, RT_TIMER_FLAG_ONE_SHOT);
-
- rt_timer_start(&timer1);
- rt_timer_start(&timer2);
+ /* 执行定时器例程 */
+ timer_simple_init();
/* 返回TestCase运行的最长时间 */
return 100;
}
/* 输出函数命令到finsh shell中 */
-FINSH_FUNCTION_EXPORT(_tc_thread_timer_simple, a simple timer example);
+FINSH_FUNCTION_EXPORT(_tc_timer_simple, a simple timer example);
#else
/* 用户应用入口 */
int rt_application_init()
{
- _tc_thread_timer_simple();
+ timer_simple_init();
return 0;
}