krnl
1
Loading...
Searching...
No Matches
examples
oldexamples
old
krnldebug01
krnldebug01.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
char
stak
[100];
8
volatile
int
cntt1
= 0,
cntt2
= 0;
9
void
t1
()
10
{
11
while
(1) {
12
13
14
digitalWrite(13, HIGH);
15
//delay(1000);
16
k_eat_msec_time(1000);
17
digitalWrite(13, LOW);
18
Serial.print(
cntt1
); Serial.print(
" "
); Serial.println(
cntt2
);
19
k_sleep
(1000);
20
21
}
22
}
23
24
void
setup
()
25
{
26
Serial.begin(9600);
27
pinMode(12, OUTPUT);
// krnl breakout
28
pinMode(13, OUTPUT);
29
k_init
(1, 0, 0);
// init with space for one task
30
31
// priority low number higher priority than higher number
32
p
=
k_crt_task
(
t1
, 10,
stak
, 100);
// t1 as task, priority 10, 100 B stak
33
34
k_start
(1);
// 1 milli sec tick speed
35
}
36
37
void
loop
() {
38
}
39
40
41
42
extern
"C"
{
43
44
45
void
k_breakout
()
// called every task shift from dispatcher
46
{
47
48
if
(
pRun
->nr == 0) {
49
PORTB |= 0x10;
50
cntt1
++;
51
52
}
53
else
{
54
cntt2
++;
55
PORTB &= 0x20;
56
}
57
58
// for a MEGA you have to find another port :-)
59
// port K (adc8-15) seems feasible
60
}
61
}
stak
char stak[100]
Definition
k02.ino:12
pRun
struct k_t * pRun
Definition
krnl.c:148
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
cntt2
volatile int cntt2
Definition
krnldebug01.ino:8
setup
void setup()
Definition
krnldebug01.ino:24
k_breakout
void k_breakout()
Definition
krnldebug01.ino:45
t1
void t1()
Definition
krnldebug01.ino:9
cntt1
volatile int cntt1
Definition
krnldebug01.ino:8
loop
void loop()
Definition
krnldebug01.ino:37
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