Telecnatron

radio, electronics, computing, telecnology.

rss icon

Support This Site.

Please consider helping to support this site by making a contribution.

avr_lib  2.0
A C library for AVR microcontrollers
task.h File Reference

Tasking (co-routine) system for AVR. More...

#include "config.h"
#include <stdint.h>

Go to the source code of this file.

Functions

void task_init (uint8_t task_num, void(*task_callback)(void *data), void *data, uint8_t run)
 Initialise a task. More...
 
void task_num_set_tick_timer (uint8_t task_num, uint16_t ticks)
 Make task number task_num unready until the passed number of ticks has occured, ie put task to sleep for this many ticks. More...
 
void task_num_cancel_tick_timer (uint8_t task_num)
 Cancel task's tick timer, if it was set. More...
 
void task_set_tick_timer (uint16_t ticks)
 Put current task to sleep (ie make unrunnable) until the passed number of ticks has occured. More...
 
void task_num_set_seconds_timer (uint8_t task_num, uint16_t seconds)
 Put task numbered task_num to sleep for passed number of seconds, ie task will be made unrunnable, and then runnable again after this number of seconds. More...
 
void task_set_seconds_timer (uint16_t seconds)
 Put current task to sleep for passed number of seconds. More...
 
void task_run ()
 Function that should be called periodically to make the tasks run. More...
 
void task_tick ()
 Function that should be called periodically to indicate that a tick period has expired. More...
 
void task_seconds_tick ()
 Function that should be called every 'second'. More...
 
void task_num_set_callback (uint8_t task_num, void(*callback)(void *data))
 Set the callback function that is to be called for task number task_num. More...
 
void task_set_callback (void(*callback)(void *data))
 Set the callback function that is to be called for the current task. More...
 
void task_num_set_user_data (uint8_t task_num, void *data)
 Sets the pointer that is passed to a task's callback function when it is called. More...
 
void task_set_user_data (void *data)
 Sets the pointer to the task's user data for the current task. More...
 
void task_num_ready (uint8_t task_num, uint8_t ready)
 Make task ready to run, or unready to run. More...
 
void task_ready (uint8_t ready)
 Make current task ready to run, or unready to run. More...
 

Detailed Description

Tasking (co-routine) system for AVR.

Author
steves
Date
2017/02/25 01:10:34

Definition in file task.h.

Function Documentation

◆ task_init()

void task_init ( uint8_t  task_num,
void(*)(void *data)  task_callback,
void *  data,
uint8_t  run 
)

Initialise a task.

Parameters
task_numThe number of the task. Must be unique amongst all tasks and within range: 0 <= task_num < TASK_NUM_TASKS
taskPointer to the task's callback function that will be called whenever the task is run
dataPointer that will be passed as parameter to task's calllback function when it is called. May be NULL.
runFlag to indicate whether the task should be made ready (ie runnable). If non-zero, task is made ready, or unready otherwise

Definition at line 116 of file task.c.

◆ task_num_cancel_tick_timer()

void task_num_cancel_tick_timer ( uint8_t  task_num)

Cancel task's tick timer, if it was set.

Parameters
task_numThe number of the task for which the tick timer is to be cancelled.

Definition at line 151 of file task.c.

◆ task_num_ready()

void task_num_ready ( uint8_t  task_num,
uint8_t  ready 
)

Make task ready to run, or unready to run.

Parameters
task_numThe number of the task to be made ready (or unready)
readyif zero then task is made unready, or ready otherwise

Definition at line 129 of file task.c.

◆ task_num_set_callback()

void task_num_set_callback ( uint8_t  task_num,
void(*)(void *data)  callback 
)

Set the callback function that is to be called for task number task_num.

Parameters
task_numThe number of the task for which callback function is to be set
callbackPointer to the callback function.

Definition at line 95 of file task.c.

◆ task_num_set_seconds_timer()

void task_num_set_seconds_timer ( uint8_t  task_num,
uint16_t  seconds 
)

Put task numbered task_num to sleep for passed number of seconds, ie task will be made unrunnable, and then runnable again after this number of seconds.

Parameters
task_numThe number of the task to be put to sleep.
secondsThe number of the task for which the second timer is to be set

Definition at line 187 of file task.c.

◆ task_num_set_tick_timer()

void task_num_set_tick_timer ( uint8_t  task_num,
uint16_t  ticks 
)

Make task number task_num unready until the passed number of ticks has occured, ie put task to sleep for this many ticks.

Parameters
task_numThe number of task for which the tick timer is to be set.
ticksThe number of ticks that the task will sleep for.

Definition at line 165 of file task.c.

◆ task_num_set_user_data()

void task_num_set_user_data ( uint8_t  task_num,
void *  data 
)

Sets the pointer that is passed to a task's callback function when it is called.

Parameters
task_numThe number of the task.
dataPointer to the task's user data.

Definition at line 105 of file task.c.

◆ task_ready()

void task_ready ( uint8_t  ready)

Make current task ready to run, or unready to run.

Parameters
readyif zero then task is made unready, or ready otherwise

Definition at line 146 of file task.c.

◆ task_run()

void task_run ( )

Function that should be called periodically to make the tasks run.

This function, in turn, calls the callback function of all tasks that are in a ready (runnable) state.

Definition at line 200 of file task.c.

◆ task_seconds_tick()

void task_seconds_tick ( )

Function that should be called every 'second'.

Makes tasks whose seconds-timer have expired runnable. Note that 'second' is defined as a time period that is close to one second.

Definition at line 238 of file task.c.

◆ task_set_callback()

void task_set_callback ( void(*)(void *data)  callback)

Set the callback function that is to be called for the current task.

Parameters
callbackPointer to the callback function.

Definition at line 100 of file task.c.

◆ task_set_seconds_timer()

void task_set_seconds_timer ( uint16_t  seconds)

Put current task to sleep for passed number of seconds.

See also
task_num_set_seconds_timer
Parameters
secondsThe number of the task for which the second timer is to be set

Definition at line 195 of file task.c.

◆ task_set_tick_timer()

void task_set_tick_timer ( uint16_t  ticks)
inline

Put current task to sleep (ie make unrunnable) until the passed number of ticks has occured.

This function would normally only be called from within a task's callback function.

See also
task_num_set_tick_timer
Parameters
ticksThe numer of ticks that the task will sleep for.

Definition at line 182 of file task.c.

◆ task_set_user_data()

void task_set_user_data ( void *  data)

Sets the pointer to the task's user data for the current task.

See also
task_num_set_user_data
Parameters
dataPointer to the user data

Definition at line 110 of file task.c.

◆ task_tick()

void task_tick ( )

Function that should be called periodically to indicate that a tick period has expired.

Checks tick timers of all sleeping tasks and make task runnable if timer has expired.

Definition at line 215 of file task.c.

Copyright 2012 - 2021 Telecnatron CSS | Login | Privacy | Sitemap Web software by Stephen Stebbing.