码迷,mamicode.com
首页 > 其他好文 > 详细

CMSIS Example - osTimer osTimerCreate osTimerStart

时间:2014-07-19 14:38:22      阅读:282      评论:0      收藏:0      [点我收藏+]

标签:style   blog   color   os   art   io   

 1 osTimerId timer;
 2 
 3 uint32_t cnt=0;
 4 void timerHandler( void * arg )
 5 {
 6   cnt++;
 7   osTimerStart( timer, 100 );
 8 }
 9 
10 osTimerDef( timer, timerHandler );
11 
12 
13 void Thread0( void * arg);
14 void Thread1( void * arg);
15 
16 osThreadDef( Thread0, Thread0, osPriorityNormal, 512 );
17 osThreadDef( Thread1, Thread1, osPriorityAboveNormal, 512 );
18 
19 
20 void Thread0( void * arg)
21 {
22   while(1)
23   {
24     osDelay( 100 );
25   }
26 }
27 
28 void Thread1( void * arg)
29 {
30   osTimerStart( timer, 100 );
31 
32   while(1)
33   {
34     osDelay( 10 );
35   }
36 }
37 
38 int main( void )
39 {
40   osKernelInitialize();
41 
42   osThreadCreate( osThread(Thread0), (void *)100 );
43   osThreadCreate( osThread(Thread1), (void *)200 );
44 
45   timer = osTimerCreate( osTimer(timer), osTimerOnce, 0 );
46 
47   osKernelStart();
48 
49   return 0;
50 }

CMSIS Example - osTimer osTimerCreate osTimerStart,布布扣,bubuko.com

CMSIS Example - osTimer osTimerCreate osTimerStart

标签:style   blog   color   os   art   io   

原文地址:http://www.cnblogs.com/shangdawei/p/3854200.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!