MegaThread
thread.h
Go to the documentation of this file.
1 /*
2  * thread.h
3  *
4  * Created: 17.04.2017 12:45:50
5  * Author: Detlev Tietjen
6  * Licence: LGPL 3.0
7  */
8 
9 #ifndef THREAD_H_
10 #define THREAD_H_
11 
12 #include <stdint.h>
13 #include <avr/io.h>
14 
16 #define THREAD_MAX 2
17 
22 #define THREAD_MS_PER_TICK 10
23 #define THREAD_STATUS_DEFAULT 1
25 
30 struct threadTCBData_t;
32 typedef int8_t threadStatus_t;
33 
34 typedef struct threadTCBData_t * pThread_t;
35 
47 typedef threadStatus_t (*threadFunc_t)(threadStatus_t state, void * pArgument);
48 
63 pThread_t threadAdd(threadFunc_t f, void * pArgument, uint16_t periodTicks);
64 
68 void threadStart();
69 
76 inline void threadBeginCriticalBlock() {
77  TIMSK0 = 0;
78 }
79 
84 inline void threadEndCriticalBlock() {
85  TIMSK0 = (1 << OCIE0A);
86 }
87 
88 #endif /* THREAD_H_ */
pThread_t threadAdd(threadFunc_t f, void *pArgument, uint16_t periodTicks)
Definition: thread.c:35
threadStatus_t(* threadFunc_t)(threadStatus_t state, void *pArgument)
Definition: thread.h:47
void threadStart()
Definition: thread.c:50
struct threadTCBData_t * pThread_t
Definition: thread.h:34
void threadEndCriticalBlock()
Definition: thread.h:84
void threadBeginCriticalBlock()
Definition: thread.h:76
int8_t threadStatus_t
defines the integer type used for the thread state.
Definition: thread.h:30