xref: /nrf52832-nimble/rt-thread/examples/kernel/thread_static.c (revision 104654410c56c573564690304ae786df310c91fc)
1 #include <rtthread.h>
2 #include "tc_comm.h"
3 
4 /*
5  * This is an example for static thread
6  */
7 static struct rt_thread thread;
8 static char thread_stack[THREAD_STACK_SIZE];
thread_entry(void * parameter)9 static void thread_entry(void* parameter)
10 {
11     rt_kprintf("thread staticly inited ok\n");
12     rt_thread_delay(10);
13     rt_kprintf("thread exit\n");
14 
15     tc_done(TC_STAT_PASSED);
16 }
17 
thread_static_init()18 rt_err_t thread_static_init()
19 {
20     rt_err_t result;
21 
22     result = rt_thread_init(&thread,
23         "test",
24         thread_entry, RT_NULL,
25         &thread_stack[0], sizeof(thread_stack),
26         THREAD_PRIORITY, 10);
27 
28     if (result == RT_EOK)
29         rt_thread_startup(&thread);
30     else
31         tc_stat(TC_STAT_END | TC_STAT_FAILED);
32 
33     return result;
34 }
35 
36 #ifdef RT_USING_TC
_tc_thread_static()37 int _tc_thread_static()
38 {
39     thread_static_init();
40 
41     return 20;
42 }
43 FINSH_FUNCTION_EXPORT(_tc_thread_static, a static thread test);
44 #else
rt_application_init()45 int rt_application_init()
46 {
47     thread_static_init();
48 
49     return 0;
50 }
51 #endif
52 
53