krnl
1
Loading...
Searching...
No Matches
examples
oldexamples
old
krnldebugdmyled13
krnldebugdmyled13.ino
Go to the documentation of this file.
1
#include <
krnl.h
>
2
3
// LED 13 is on when dummy is running - otherwise no light
4
// can be used as skeletonfor extended debug LEDing
5
6
struct
k_t
*
p
;
7
char
stak
[100];
8
9
// LED 13 not used from user space bq we use led for indicating dummy i srunning
10
// when dummy is running it indicates enough cpu power
11
// if dummy is not running for a longer time you may have problems ....
12
void
t1
()
13
{
14
while
(1) {
15
16
Serial.println(
"I am running"
);
17
k_eat_msec_time(1000);
// you are running
18
Serial.println(
"dummy is now running"
);
19
k_sleep
(1000);
// you are NOT running so dummmy is running
20
}
21
}
22
23
void
setup
()
24
{
25
26
Serial.begin(9600);
27
pinMode(13, OUTPUT);
28
k_init
(1, 0, 0);
// init with space for one task
29
30
// priority low number higher priority than higher number
31
p
=
k_crt_task
(
t1
, 10,
stak
, 100);
// t1 as task, priority 10, 100 B stak
32
33
k_start
(1);
// 1 milli sec tick speed
34
}
35
36
void
loop
() {
37
}
38
39
40
41
extern
"C"
{
42
43
44
void
k_breakout
()
// called every task shift from dispatcher
45
{
46
static
char
c = 0;
47
48
if
(
pRun
->nr == 0) {
49
//PORTB = PORTB | B00010000; // LED 12 on if dmy is running
50
PORTB = PORTB | B00100000;
// LED 13 ..
51
}
52
else
{
53
//PORTB = PORTB & B11101111;
54
PORTB = PORTB & B11011111;
// led 13 ...
55
}
56
}
57
}
58
59
60
/*
61
62
Suggested PORTS TO USE
63
uno
64
pin port
65
8 PB0
66
9 PB1
67
10 PB2
68
11 PB3
69
12 PB4
70
13 PB5 (led)
71
PB6,7 etc not to be used !
72
73
74
MEGA
75
pin port
76
78 PA0
77
77 PA1
78
76 PA2
79
75 PA3
80
74 PA4
81
73 PA5
82
72 PA6
83
71 PA7
84
85
MICRO
86
8 PB4
87
9 PB5
88
10 PB6
89
11 PB7
90
91
NANO
92
D8 PD0
93
D9 PD1
94
D2 PD2
95
D3 PD3
96
D4 PD4
97
D5 PD5
98
D6 PD6
99
D7 PD7
100
101
PRO MINI
102
2 PD2
103
3 PD3
104
4 PD4
105
5 PD5
106
6 PD6
107
108
* */
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
setup
void setup()
Definition
krnldebugdmyled13.ino:23
k_breakout
void k_breakout()
Definition
krnldebugdmyled13.ino:44
t1
void t1()
Definition
krnldebugdmyled13.ino:12
loop
void loop()
Definition
krnldebugdmyled13.ino:36
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