root/webserver/example/Crossworks_taskinglib/main_ctl.c

Revision 13, 1.3 kB (checked in by phil, 15 years ago)

Crossworks Lib Example (multiple tasks)

Line 
1 #include <ctl_api.h>
2
3 CTL_TASK_t main_task, new_task;
4
5 #define CALLSTACKSIZE 16 // this is only required for AVR builds
6 #define STACKSIZE 64         
7 unsigned new_task_stack[1+STACKSIZE+1];
8
9 void
10 new_task_code(void *p)
11
12   unsigned int v=0;
13   while (1)
14     {     
15       // task logic goes here     
16       v++;
17     } 
18 }
19
20 void
21 ctl_handle_error(CTL_ERROR_CODE_t e)
22 {
23   while (1);
24 }
25
26 #if 0
27 //*********************************
28       int main(void)
29       {
30         unsigned int v=0;
31         ctl_task_init(&main_task, 255, "main"); // create subsequent tasks whilst running at the highest priority.
32         ctl_start_timer(ctl_increment_tick_from_isr); // start the timer
33         memset(new_task_stack, 0xcd, sizeof(new_task_stack));  // write known values into the stack
34         new_task_stack[0]=new_task_stack[1+STACKSIZE]=0xfacefeed; // put marker values at the words before/after the stack
35         ctl_task_run(&new_task, 1, new_task_code, 0, "new_task", STACKSIZE, new_task_stack+1, CALLSTACKSIZE);
36         ctl_task_set_priority(&main_task, 0); // drop to lowest priority to start created tasks running.
37         while (1)
38           {   
39             // power down can go here if supported     
40             v++;
41           }
42         return 0;
43       }
44 //*********************************
45 #endif
Note: See TracBrowser for help on using the browser.