krnl 1
Loading...
Searching...
No Matches
fixexsampling.ino
Go to the documentation of this file.
1
2#include <krnl.h>
3struct k_t *pSem, *pTask;
4
5#define STK 100
6char stak[STK];
7
9 static boolean light = false;
10 k_eat_time(5); // to simulate code running
11
12 if (light) { // debug :-) blinking
13 light = false;
14 digitalWrite(13, HIGH);
15
16 }
17 else {
18 light = true;
19 digitalWrite(13, LOW);
20 }
21}
22
23void task()
24{
25
26 k_set_sem_timer(pSem, 1000); // let OS send a signal to semaphore every 1000th kernel timer tick
27
28 while (1) {
29 k_wait(pSem, 0);
31 }
32}
33
34void setup()
35{
36 pinMode(13, OUTPUT); // for debugging only
37 k_init(1, 1, 0); // 1 task, 1 semaphore, 0 message boxes
38 pSem = k_crt_sem(0, 10); // 0 start value missing max value for clipping
39 pTask = k_crt_task(task, 10, stak, STK);
40 k_start(1);
41}
42
43void loop() {}
44
char stak[100]
Definition k02.ino:12
#define STK
struct k_t * pTask
int k_wait(struct k_t *sem, int timeout)
stand wait on semaphore call with timeout facility
Definition krnl.c:683
struct k_t * k_crt_task(void(*pTask)(void), char prio, char *pStk, int stkSize)
create a task - only to be called before k_start creates a task and put it in the active Q
Definition krnl.c:328
int k_set_sem_timer(struct k_t *sem, int val)
attach a periodic timer to a semaphore, to be used for realtime
Definition krnl.c:586
struct k_t * k_crt_sem(int init_val, int maxvalue)
change task priority and reinserts it in task Q and do a task shift
Definition krnl.c:544
int k_init(int nrTask, int nrSem, int nrMsg)
Definition krnl.c:1108
int k_start()
Definition krnl.c:1149
struct k_t * pSem
void setup()
void doSamplingAlgorithmsAndControl()
void task()
void loop()
struct k_t * task
Definition krnl.h:323