krnl
1
Loading...
Searching...
No Matches
examples
oldexamples
old
k01myfirsttask
k01myfirsttask.ino
Go to the documentation of this file.
1
#include <
krnl.h
>
2
3
#include <
krnl.h
>
4
// one task loops and blink
5
// k_sleep is used for delay - and ensure no busy waiting
6
// if delay(...) is used then you use cpu time
7
8
struct
k_t
*
p
;
9
char
stak
[100];
10
11
void
t1
()
12
{
13
while
(1) {
14
15
k_sleep
(500);
16
digitalWrite(13,HIGH);
17
18
k_sleep
(100);
19
digitalWrite(13,LOW);
20
21
}
22
}
23
24
void
setup
()
25
{
26
int
res;
27
Serial.begin(9600);
28
while
(! Serial) ;
29
pinMode(13,OUTPUT);
30
k_init
(1,0,0);
// init with space for one task
31
32
// priority low number higher priority than higher number
33
p
=
k_crt_task
(
t1
,10,
stak
,100);
// t1 as task, priority 10, 100 B stak
34
35
res=
k_start
(1);
// 1 milli sec tick speed
36
// you will never return from k_start
37
Serial.print(
"ups an error occured: "
); Serial.println(res);
38
while
(1) ;
39
}
40
41
void
loop
() {
42
}
43
stak
char stak[100]
Definition
k02.ino:12
setup
void setup()
Definition
k01myfirsttask.ino:22
t1
void t1()
Definition
k01myfirsttask.ino:10
loop
void loop()
Definition
k01myfirsttask.ino:55
k_sleep
int k_sleep(int time)
let task sleep for a number of milliseconds
Definition
krnl.c:445
k_crt_task
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
k_init
int k_init(int nrTask, int nrSem, int nrMsg)
Definition
krnl.c:1108
k_start
int k_start()
Definition
krnl.c:1149
krnl.h
t1
struct k_t * t1
Definition
krnlgen.ino:3
p
struct k_t * p
Definition
k01myfirsttask.ino:6
k_t
Definition
krnl.h:323
Generated by
1.15.0