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