From f7b14218800ad7ed6c47c67d4d043a3340d63116 Mon Sep 17 00:00:00 2001 From: Grissiom Date: Sat, 21 Dec 2013 12:51:52 +0800 Subject: TC: expand TABs --- examples/kernel/timer_timeout.c | 132 ++++++++++++++++++++-------------------- 1 file changed, 66 insertions(+), 66 deletions(-) (limited to 'examples/kernel/timer_timeout.c') diff --git a/examples/kernel/timer_timeout.c b/examples/kernel/timer_timeout.c index 80241e53f2..d1a7099e2e 100644 --- a/examples/kernel/timer_timeout.c +++ b/examples/kernel/timer_timeout.c @@ -20,94 +20,94 @@ static struct rt_timer timer; static rt_uint16_t no = 0; static void timer_timeout(void* parameter) { - char buf[32]; - rt_uint32_t length; + char buf[32]; + rt_uint32_t length; - length = rt_snprintf(buf, sizeof(buf), "message %d", no++); - rt_mq_send(&mq, &buf[0], length); + length = rt_snprintf(buf, sizeof(buf), "message %d", no++); + rt_mq_send(&mq, &buf[0], length); } /* 线程入口函数 */ static void thread_entry(void* parameter) { - char buf[64]; - rt_err_t result; - - /* 初始化定时器 */ - rt_timer_init(&timer, "timer", /* 定时器名字是 timer1 */ - timer_timeout, /* 超时时回调的处理函数 */ - RT_NULL, /* 超时函数的入口参数 */ - 1, /* 定时长度,以OS Tick为单位,即1个OS Tick */ - RT_TIMER_FLAG_PERIODIC); /* 周期性定时器 */ - - while (1) - { - rt_memset(&buf[0], 0, sizeof(buf)); - - /* 从消息队列中接收消息 */ - result = rt_mq_recv(&mq, &buf[0], sizeof(buf), 1); - if (result == RT_EOK) - { - rt_kprintf("recv msg: %s\n", buf); - } - else if (result == -RT_ETIMEOUT) - { - rt_kprintf("recv msg timeout\n"); - } - } + char buf[64]; + rt_err_t result; + + /* 初始化定时器 */ + rt_timer_init(&timer, "timer", /* 定时器名字是 timer1 */ + timer_timeout, /* 超时时回调的处理函数 */ + RT_NULL, /* 超时函数的入口参数 */ + 1, /* 定时长度,以OS Tick为单位,即1个OS Tick */ + RT_TIMER_FLAG_PERIODIC); /* 周期性定时器 */ + + while (1) + { + rt_memset(&buf[0], 0, sizeof(buf)); + + /* 从消息队列中接收消息 */ + result = rt_mq_recv(&mq, &buf[0], sizeof(buf), 1); + if (result == RT_EOK) + { + rt_kprintf("recv msg: %s\n", buf); + } + else if (result == -RT_ETIMEOUT) + { + rt_kprintf("recv msg timeout\n"); + } + } } int timer_timeout_init() { - /* 初始化消息队列 */ - rt_mq_init(&mq, "mqt", - &msg_pool[0], /* 内存池指向msg_pool */ - 128 - sizeof(void*), /* 每个消息的大小是 128 - void* */ - sizeof(msg_pool), /* 内存池的大小是msg_pool的大小 */ - RT_IPC_FLAG_FIFO); /* 如果有多个线程等待,按照先来先得到的方法分配消息 */ - - /* 创建线程 */ - tid = rt_thread_create("t", - thread_entry, RT_NULL, /* 线程入口是thread_entry, 入口参数是RT_NULL */ - THREAD_STACK_SIZE, THREAD_PRIORITY, THREAD_TIMESLICE); - if (tid != RT_NULL) - rt_thread_startup(tid); - else - tc_stat(TC_STAT_END | TC_STAT_FAILED); - - return 0; + /* 初始化消息队列 */ + rt_mq_init(&mq, "mqt", + &msg_pool[0], /* 内存池指向msg_pool */ + 128 - sizeof(void*), /* 每个消息的大小是 128 - void* */ + sizeof(msg_pool), /* 内存池的大小是msg_pool的大小 */ + RT_IPC_FLAG_FIFO); /* 如果有多个线程等待,按照先来先得到的方法分配消息 */ + + /* 创建线程 */ + tid = rt_thread_create("t", + thread_entry, RT_NULL, /* 线程入口是thread_entry, 入口参数是RT_NULL */ + THREAD_STACK_SIZE, THREAD_PRIORITY, THREAD_TIMESLICE); + if (tid != RT_NULL) + rt_thread_startup(tid); + else + tc_stat(TC_STAT_END | TC_STAT_FAILED); + + return 0; } #ifdef RT_USING_TC static void _tc_cleanup() { - /* 调度器上锁,上锁后,将不再切换到其他线程,仅响应中断 */ - rt_enter_critical(); + /* 调度器上锁,上锁后,将不再切换到其他线程,仅响应中断 */ + rt_enter_critical(); - /* 删除线程 */ - if (tid != RT_NULL && tid->stat != RT_THREAD_CLOSE) - rt_thread_delete(tid); + /* 删除线程 */ + if (tid != RT_NULL && tid->stat != RT_THREAD_CLOSE) + rt_thread_delete(tid); - /* 执行消息队列对象脱离 */ - rt_mq_detach(&mq); - /* 执行定时器脱离 */ - rt_timer_detach(&timer); + /* 执行消息队列对象脱离 */ + rt_mq_detach(&mq); + /* 执行定时器脱离 */ + rt_timer_detach(&timer); - /* 调度器解锁 */ - rt_exit_critical(); + /* 调度器解锁 */ + rt_exit_critical(); - /* 设置TestCase状态 */ - tc_done(TC_STAT_PASSED); + /* 设置TestCase状态 */ + tc_done(TC_STAT_PASSED); } int _tc_timer_timeout() { - /* 设置TestCase清理回调函数 */ - tc_cleanup(_tc_cleanup); - timer_timeout_init(); + /* 设置TestCase清理回调函数 */ + tc_cleanup(_tc_cleanup); + timer_timeout_init(); - /* 返回TestCase运行的最长时间 */ - return 100; + /* 返回TestCase运行的最长时间 */ + return 100; } /* 输出函数命令到finsh shell中 */ FINSH_FUNCTION_EXPORT(_tc_timer_timeout, a thread timer testcase); @@ -115,8 +115,8 @@ FINSH_FUNCTION_EXPORT(_tc_timer_timeout, a thread timer testcase); /* 用户应用入口 */ int rt_application_init() { - timer_timeout_init(); + timer_timeout_init(); - return 0; + return 0; } #endif -- cgit v1.3.1