My Project - RET HER  versionsnr
k01myfirsttask.ino
Go to the documentation of this file.
1 #include <krnl.h>
2 // one task loops and blink
3 // k_sleep is used for delay - and ensure no busy waiting
4 // if delay(...) is used then you use cpu time
5 
6 struct k_t *p;
7 
8 void t1()
9 {
10  while (1) {
11 
12  k_sleep(500); // 500 * 1 msec
13  digitalWrite(13,HIGH);
14 
15  k_sleep(100);
16  digitalWrite(13,LOW);
17 
18  }
19 }
20 
22 {
23  while (1) {
24  digitalWrite(3,HIGH);
25  delay(100);
26  digitalWrite(3,LOW);
27  delay(100);
28  }
29 }
30 
31 void setup()
32 {
33  int res;
34  pinMode(13,OUTPUT);
35  k_init(1,0,0); // init with space for one task, 0 semaphores, 0 mailboxes
36 
37  p = k_crt_task(t1,10,100); // t1 as task, priority 10, 100 Bytes stak
38 
39  res= k_start(); // 1 milli sec tick speed
40 
41 
42  // you will never return from k_start if init part did succedd
43  // bad stuff can be happended and then you will come here
45 
46  while (1) ;
47 }
48 
49 void loop() {
50 }
51 
k_sleep
int k_sleep(int time)
Definition: krnl.c:677
setup
void setup()
Definition: k01myfirsttask.ino:31
k_init
int k_init(int nrTask, int nrSem, int nrMsg)
Definition: krnl.c:1261
t1
void t1()
Definition: k01myfirsttask.ino:8
p
struct k_t * p
Definition: k01myfirsttask.ino:6
emergencyBlink
void emergencyBlink()
Definition: k01myfirsttask.ino:21
k_t
Definition: krnl.h:335
k_crt_task
struct k_t * k_crt_task(void(*pTask)(void), char prio, int stkSize)
Definition: krnl.c:565
krnl.h
loop
void loop()
Definition: k01myfirsttask.ino:49
k_start
int k_start(int tick)
Definition: krnl.c:1303