CMSIS Example - osTimer osTimerCreate osTimerStart

 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)