uTask 0.3.3
|
Defines | |
#define | utask_wait_nzero(utask, sem, timeout) utask_wait_neq(utask, sem, 0, timeout) |
#define | utask_wait_zero(utask, sem, timeout) utask_wait_eq(utask, sem, 0, timeout) |
Functions | |
void | utask_init () |
Intializes internal variables. Must be run before all other utask functions. | |
void | utask_sleep (utask_t *t, utask_timer_t ticks) |
Sleep task t for ticks ticks of clock. | |
utask_t * | utask_add_name (utask_fun fun, const char *name) |
Add new task with function function and name name for execution. | |
utask_t * | utask_add (utask_fun fun) |
Add new task with function function for execution. | |
utask_data_t | utask_check_sleep () |
void | utask_schedule () |
Scheduling function, must be called forever. | |
void | utask_sleep_process () |
Timekeeping function, should be called from ISR. | |
void | utask_exit (utask_t *t) |
Terminate task t. | |
void | utask_wait_eq (utask_t *t, utask_sem_t *sem, utask_sem_t sem_val, utask_timer_t timeout) |
Wait for the semaphore sem value to be set to sem_value with timeout ticks of timeout. | |
void | utask_wait_neq (utask_t *t, utask_sem_t *sem, utask_sem_t sem_val, utask_timer_t timeout) |
Wait for the semaphore sem value to be changed from sem_value with timeout ticks of timeout. | |
void | utask_suspend (utask_t *t) |
Suspend task exectuion. | |
void | utask_resume (utask_t *t) |
Resume task t. | |
utask_data_t | utask_get_free_slots (void) |
Returns free task slots. | |
utask_data_t | utask_get_task_cnt (utask_fun fun) |
Function returns number of tasks executing fun function. | |
utask_t * | utask_get_by_tid (utask_data_t tid) |
Returns task structure pointer by task id. | |
Variables | |
void(* | utask_put_mcu_to_sleep )(utask_data_t d) = (void*)0 |
Add new task with function function for execution. Can be one of two versions:
After add is called following structure members are set to as follows:
fun | pointer to function to be executed |
Add new task with function function and name name for execution. This is simple wrapper. See utask_add() for details.
fun | pointer to function to be executed |
name | name of the task |
void utask_exit | ( | utask_t * | t | ) |
Ends task t. utask_exit() can terminate other tasks. Do not reference t after it has been freed with utask_exit().
t | pointer to utask structure |
utask_t* utask_get_by_tid | ( | utask_data_t | tid | ) |
Returns task structure pointer by task id.
tid | task id |
utask_data_t utask_get_free_slots | ( | void | ) |
Returns free task slots.
utask_data_t utask_get_task_cnt | ( | utask_fun | fun | ) |
Function returns number of tasks executing fun function.
fun | function |
void utask_init | ( | void | ) |
Intializes internal variables. Must be run before all other utask functions.
void utask_resume | ( | utask_t * | t | ) |
Resume task t. It works on both on tasks put to sleep and suspended.
t | pointer to utask structure |
void utask_schedule | ( | void | ) |
Scheduling function, must be called forever (e.g. in main() in while(1) {} loop) or utask will not work!
void utask_sleep | ( | utask_t * | t, |
utask_timer_t | ticks | ||
) |
Sleep task t for ticks ticks of clock. This function can put to sleep another task.
t | pointer to utask structure |
ticks | number of ticks of clock for task to sleep |
void utask_sleep_process | ( | void | ) |
Function decreasing tasks' sleep timers. Must be called periodically (e.g. from timer ISR) or utask_sleep() and utask_wait_*() will not work properly! Calling frequency selects timeout tick resolution. Calling this function at 1kHz rate gives you tick equal to 1 ms. Call this function as often (or as rarely) as you need.
void utask_suspend | ( | utask_t * | t | ) |
Suspend task exectuion. This function can suspend another task.
t | pointer to utask structure |
void utask_wait_eq | ( | utask_t * | t, |
utask_sem_t * | sem, | ||
utask_sem_t | sem_val, | ||
utask_timer_t | timeout | ||
) |
Wait for the semaphore sem value to be set to sem_value with timeout ticks of timeout. If contidion was met t->sleep != 0.
t | pointer to utask structure |
sem | pointer to semaphore |
sem_val | value waited for |
timeout | waiting timeout |
void utask_wait_neq | ( | utask_t * | t, |
utask_sem_t * | sem, | ||
utask_sem_t | sem_val, | ||
utask_timer_t | timeout | ||
) |
Wait for the semaphore sem value to be changed from sem_value with timeout ticks of timeout. If contidion was met t->sleep != 0.
t | pointer to utask structure |
sem | pointer to semaphore |
sem_val | value waited for |
timeout | waiting timeout |