![]() |
Task scheduler library
1.0
Arduino library for simply executing tasks in parallel
|
#include "Task_scheduler.h"
Go to the source code of this file.
Functions | |
void | Scheduler_Init (void) |
Initialize and reset the tasks library. More... | |
bool | Scheduler_Task_Add (Task func, int16_t period, int16_t delay) |
Add a task to the task scheduler. More... | |
bool | Scheduler_Task_Remove (Task func) |
Remove a task from the task scheduler. More... | |
bool | Scheduler_Task_Delay (Task func, int16_t delay) |
Delay execution of a task. More... | |
bool | Scheduler_Task_Start (Task func) |
Activate a task in the scheduler. More... | |
bool | Scheduler_Task_Pause (Task func) |
Deactivate a task in the scheduler. More... | |
void | Scheduler_Start (void) |
Start the task scheduler. More... | |
void | Scheduler_Pause (void) |
Pause the task scheduler. More... | |
Library providing a simple task scheduler for multitasking.
For more details please refer to Task_scheduler.h
Definition in file Task_scheduler.cpp.
void Scheduler_Init | ( | void | ) |
Initialize and reset the tasks library.
This function initializes the task scheduler and related timer.
Used HW blocks:
- Arduino MEGA: TIMER0_COMPA_vect
- Arduino DUE: TC3
Definition at line 117 of file Task_scheduler.cpp.
void Scheduler_Pause | ( | void | ) |
Pause the task scheduler.
Pause execution of the scheduler. All tasks are paused.
Used HW blocks:
- Arduino MEGA: TIMER0_COMPA_vect
- Arduino DUE: TC3
Definition at line 561 of file Task_scheduler.cpp.
void Scheduler_Start | ( | void | ) |
Start the task scheduler.
Resume execution of the scheduler. All active tasks are resumed.
Used HW blocks:
- Arduino MEGA: TIMER0_COMPA_vect
- Arduino DUE: TC3
Definition at line 538 of file Task_scheduler.cpp.
bool Scheduler_Task_Add | ( | Task | func, |
int16_t | period, | ||
int16_t | delay = 0 |
||
) |
Add a task to the task scheduler.
A new task is added to the scheduler with a given execution period and delay until first execution.
If no delay is given the task is executed at once or after starting the task scheduler (see Scheduler_Start())
If a period of 0ms is given, the task is executed only once and then removed automatically.
To avoid ambiguities, a function can only be added once to the scheduler. Trying to add it a second time will reset and overwrite the settings of the existing task.
Used HW blocks:
- Arduino MEGA: TIMER0_COMPA_vect
- Arduino DUE: TC3
[in] | func | Function to be executed. The function prototype should be similar to this: "void userFunction(void)" |
[in] | period | Execution period of the task in ms (0 to 32767) |
[in] | delay | Delay until first execution of task in ms (0 to 32767) |
MAX_TASK_CNT
in file Task_scheduler.h
Definition at line 155 of file Task_scheduler.cpp.
bool Scheduler_Task_Delay | ( | Task | func, |
int16_t | delay | ||
) |
Delay execution of a task.
The task is delayed starting from the last 1ms timer tick which means the delay time is accurate to -1ms to 0ms.
This overwrites any previously set delay setting for this task and thus even allows earlier execution of a task. Delaying the task by <2ms forces it to be executed during the next 1ms timer tick. This means that the task might be called at any time anyway in case it was added multiple times to the task scheduler.
Used HW blocks:
- Arduino MEGA: TIMER0_COMPA_vect
- Arduino DUE: TC3
[in] | func | Function that should be delayed |
[in] | delay | Delay in ms (0 to 32767) |
Definition at line 339 of file Task_scheduler.cpp.
bool Scheduler_Task_Pause | ( | Task | func | ) |
Deactivate a task in the scheduler.
Pause execution of the specified task. Possible parallel tasks are not affected.
Used HW blocks:
- Arduino MEGA: TIMER0_COMPA_vect
- Arduino DUE: TC3
[in] | func | Function to be paused |
Definition at line 477 of file Task_scheduler.cpp.
bool Scheduler_Task_Remove | ( | Task | func | ) |
Remove a task from the task scheduler.
Remove the specified task from the scheduler and free the slot again.
Used HW blocks:
- Arduino MEGA: TIMER0_COMPA_vect
- Arduino DUE: TC3
[in] | func | Function name that should be removed. |
Definition at line 274 of file Task_scheduler.cpp.
bool Scheduler_Task_Start | ( | Task | func | ) |
Activate a task in the scheduler.
Resume execution of the specified task. Possible parallel tasks are not affected.
Used HW blocks:
- Arduino MEGA: TIMER0_COMPA_vect
- Arduino DUE: TC3
[in] | func | Function to be activated |
Definition at line 413 of file Task_scheduler.cpp.