Core Function: createTask()
From ChipKit Wiki
int createTask(taskFunc task, unsigned long period, unsigned short stat, void * var)
|task||Pointer to the task function|
|period||Scheduling interval in milliseconds|
|state||Task initial enable state|
|var||Initial value for task variable|
If the task is successfully created, the task identifier is returned. If the task can't be created, the value -1 is returned.
This function creates a new task. The function specified by task will be scheduled for execution period milliseconds from the time the function was called and then repeated every period milliseconds afterwards. The initial task execution enable state is specified by state. This can have the following values:
|TASK_ENABLE||The task is enabled and will be run at the specified intervals.|
|TASK_DISABLE||The task is disabled and will not be run.|
|TASK_RUN_ONCE||The task is enabled to run once and then will become disabled after running.|
|Number 'n'||The task is enabled to run and will run 'n' times. After the 'n'th execution, the task becomes disabled.|
The initial value of the task variable is specified by var. The task variable is a 32-bit quantity stored with the task but not used by the task manager. This can be used for any purpose desired, but can in particular be used to store a pointer to a data structure containing parameters for the task function.