8 struct task tasks
[MAXTASKS
];
12 memset(&tasks
, 0, sizeof(struct task
)*MAXTASKS
);
15 void task_register(void)
20 for(ct
= 0; ct
<MAXTASKS
; ct
++)
24 die("Trying to add too much tasks...");
26 memset(&tasks
[ct
], 0, sizeof(struct task
));
28 tasks
[ct
].interval
= read16();
31 if(is_interrupt_task(&tasks
[ct
])) {
36 tasks
[ct
].tlen
= read16();
37 debug("task interval: %d, length: %d\n",
38 tasks
[ct
].interval
, tasks
[ct
].tlen
);
40 if(tasks
[ct
].tlen
> MAXTASKSIZE
)
41 die("Task is too long: %d", tasks
[ct
].tlen
);
43 for(i
= 0; i
<tasks
[ct
].tlen
; i
++){
44 tasks
[ct
].bc
[i
] = read_byte();
45 // debug("t[][%i]: 0x%02x %d", i,
46 // tasks[ct].bc[i], tasks[ct].bc[i]);
48 //Return the task number for later removal
49 debug("Received a task of length %d", tasks
[ct
].tlen
);
50 tasks
[ct
].used
= true;
51 tasks
[ct
].lastrun
= 0L;
58 bool is_interrupt_task(struct task
*t
)
60 return t
->interval
& (2 <<14);
63 bool had_interrupt(struct task
* t
)
65 //Not implemented yet...
70 void task_delete(void)
73 tasks
[c
].used
= false;
79 struct task
*task_get(int num
)
81 return tasks
[num
].used
? &tasks
[num
] : NULL
;