2016-10-31 09:14:22 +01:00
|
|
|
#ifndef GUARD_TASK_H
|
|
|
|
#define GUARD_TASK_H
|
|
|
|
|
2019-02-07 17:24:09 +01:00
|
|
|
#define HEAD_SENTINEL 0xFE
|
|
|
|
#define TAIL_SENTINEL 0xFF
|
2021-02-20 05:22:26 +01:00
|
|
|
#define TASK_NONE TAIL_SENTINEL
|
2019-02-07 17:24:09 +01:00
|
|
|
|
2017-03-07 14:44:41 +01:00
|
|
|
#define NUM_TASKS 16
|
2019-09-15 21:30:35 +02:00
|
|
|
#define NUM_TASK_DATA 16
|
2017-03-07 14:44:41 +01:00
|
|
|
|
2016-10-31 09:14:22 +01:00
|
|
|
typedef void (*TaskFunc)(u8 taskId);
|
|
|
|
|
|
|
|
struct Task
|
|
|
|
{
|
|
|
|
TaskFunc func;
|
|
|
|
bool8 isActive;
|
|
|
|
u8 prev;
|
|
|
|
u8 next;
|
|
|
|
u8 priority;
|
2019-09-15 21:30:35 +02:00
|
|
|
s16 data[NUM_TASK_DATA];
|
2016-10-31 09:14:22 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
extern struct Task gTasks[];
|
|
|
|
|
2017-03-05 05:43:34 +01:00
|
|
|
void ResetTasks(void);
|
2016-10-31 09:14:22 +01:00
|
|
|
u8 CreateTask(TaskFunc func, u8 priority);
|
|
|
|
void DestroyTask(u8 taskId);
|
2017-03-05 05:43:34 +01:00
|
|
|
void RunTasks(void);
|
2016-10-31 09:14:22 +01:00
|
|
|
void TaskDummy(u8 taskId);
|
|
|
|
void SetTaskFuncWithFollowupFunc(u8 taskId, TaskFunc func, TaskFunc followupFunc);
|
|
|
|
void SwitchTaskToFollowupFunc(u8 taskId);
|
|
|
|
bool8 FuncIsActiveTask(TaskFunc func);
|
|
|
|
u8 FindTaskIdByFunc(TaskFunc func);
|
2017-03-05 05:43:34 +01:00
|
|
|
u8 GetTaskCount(void);
|
|
|
|
void SetWordTaskArg(u8 taskId, u8 dataElem, u32 value);
|
|
|
|
u32 GetWordTaskArg(u8 taskId, u8 dataElem);
|
2016-10-31 09:14:22 +01:00
|
|
|
|
|
|
|
#endif // GUARD_TASK_H
|