10 #include "interface.h"
12 struct task tasks
[MAXTASKS
];
16 memset(&tasks
, 0, sizeof(struct task
)*MAXTASKS
);
19 void task_register(void)
24 for(ct
= 0; ct
<MAXTASKS
; ct
++)
28 die("Trying to add too much tasks...");
30 memset(&tasks
[ct
], 0, sizeof(struct task
));
32 tasks
[ct
].interval
= read16();
35 if(is_interrupt_task(&tasks
[ct
])) {
40 tasks
[ct
].tlen
= read16();
41 debug("task interval: %d, length: %d\n",
42 tasks
[ct
].interval
, tasks
[ct
].tlen
);
44 if(tasks
[ct
].tlen
> MAXTASKSIZE
)
45 die("Task is too long: %d", tasks
[ct
].tlen
);
47 for(i
= 0; i
<tasks
[ct
].tlen
; i
++){
48 tasks
[ct
].bc
[i
] = read_byte();
49 // debug("t[][%i]: 0x%02x %d", i,
50 // tasks[ct].bc[i], tasks[ct].bc[i]);
52 //Return the task number for later removal
53 debug("Received a task of length %d", tasks
[ct
].tlen
);
54 tasks
[ct
].used
= true;
55 tasks
[ct
].lastrun
= 0L;
62 bool is_interrupt_task(struct task
*t
)
64 return t
->interval
& (2 <<14);
67 bool had_interrupt(struct task
* t
)
69 //Not implemented yet...
74 void task_delete(void)
77 tasks
[c
].used
= false;
83 struct task
*task_get(int num
)
85 return tasks
[num
].used
? &tasks
[num
] : NULL
;