#include <stdint.h>
#include <avr/io.h>
Go to the source code of this file.
defines the maximum number of threads
#define THREAD_MS_PER_TICK 10 |
Defines the milliseconds per timeslice and must be a positive integer literal. It should be the greatest common divisor of all periods, but must not exceed the value of 261/[CPU-clock in MHz]
#define THREAD_STATUS_DEFAULT 1 |
defines a default status which should returned by the thread function if no state machine is used.
Prototype for thread function. The function must return a state value, which is passed back on the next call. This value can be used for a state machine and is not used outside the function, but the return value should never be zero, because this marks the first call of the function. You should use the macro 'THREAD_STATUS_DEFAULT' if you do not use a state machine.
- Parameters
-
state | actual state of the state machine, if a state machine is used. This value was returned by the last call and is set to zero at the first call of the function. |
pArgument | this parameter is defined in threadAdd and is provided to the thread function at every call. |
- See also
- threadAdd
defines the integer type used for the thread state.
Adds a new thread to the list. This function must not be called after starting the scheduling. The priority of the task depends on the order of the adding of the threads. The first function has the highest, the last the lowest priority.
- See also
- threadStart
- Parameters
-
f | pointer to the thread function |
pArgument | this parameter is delivered to the thread function at every call. Typically it would be a pointer to struct with parameters and/or a pointer to a struct holding the static data of the function. (You should avoid using static variables in function used for a thread) |
periodTicks | number of ticks between to calls. You should use ' [period in ms]/THREAD_MS_PER_TICK' here. |
- Returns
- NULL if the list was already full, not NULL if the task was successfully added.
void threadBeginCriticalBlock |
( |
| ) |
|
|
inline |
Marks the beginning of instructions, which must not interrupted by another thread. This function only affects the timetick of the scheduler, all another interrupts remain active. This block must be closed by 'threadEndCriticalBlock'.
- See also
- threadEndCriticalBlock
void threadEndCriticalBlock |
( |
| ) |
|
|
inline |
Configures the timer, enables global interrupts and starts executing of the tasks.