/vhost/mculabs/snippet_db/ptask/ptask.h
1 /*
2 file: ptask.h
3 description: priority (out of order) task manager
4 written by : Michael Bradley
5
6 Changelog:
7 12/31/09 This file created
8
9 This will allow you to run several tasks out of order, with the important
10 tasks running more often than the others.
11
12 Give each task a number from 1 to 255, the lower the number,
13 the higher the priority the task has. (more often it runs)
14
15 Basicaly, each task gets run the N'th time the task manager is entered
16
17 example:
18
19 // global define
20 mpDefineTask mainTasks;
21
22 void main(void)
23 {
24
25 mpTaskManager(mainTasks)
26 {
27 mpTask(mainTasks, 1, task_procGPS() ); // this task runs every time
28 mpTask(mainTasks, 2, task_procMode() ); // this task runs every other time
29 mpTask(mainTasks, 5, task_procTarget() ); // this task runs every 5th time
30 mpTask(mainTasks, 12, task_termUpdate() ); // this task runs every 12th time
31 }
32
33 }
34
35 */
36
37
38
39 #ifndef __PTASK_MANAGER
40 #define __PTASK_MANAGER
41
42
43 #define mpDefineTask unsigned int8
44 #define mpTaskManager(wtask) wtask++;
45 #define mpTask(wtask,pri,fn) if ( (wtask - ( (wtask/pri) * pri)) == 0 ) { fn; }
46
47 #endif
48
49
|