krnl
1
Loading...
Searching...
No Matches
examples
oldexamples
old
k001timertest
k001timertest.ino
Go to the documentation of this file.
1
/*****************************************************
2
* TEST TEST TEST
3
* krnl.c part of kernel KRNL *
4
* this version adapted for Arduino *
5
* *
6
* (C) 2012,2013,2014 *
7
* *
8
* Jens Dalsgaard Nielsen <jdn@es.aau.dk> *
9
* http://es.aau.dk/staff/jdn *
10
* Section of Automation & Control *
11
* Aalborg University, *
12
* Denmark *
13
* *
14
* "THE BEER-WARE LICENSE" (frit efter PHK) *
15
* <jdn@es.aau.dk> wrote this file. As long as you *
16
* retain this notice you can do whatever you want *
17
* with this stuff. If we meet some day, and you think*
18
* this stuff is worth it ... *
19
* you can buy me a beer in return :-) *
20
* or if you are real happy then ... *
21
* single malt will be well received :-) *
22
* *
23
* Use it at your own risk - no warranty *
24
* *
25
* tested with duemilanove w/328, uno R3, *
26
* seeduino 1280 and mega2560 *
27
*****************************************************/
28
29
30
/*
31
First 50 mea without krnl 0.6% overhead
32
Next 59 mea witrh krnl 4.1% overhead
33
only one task created. more task and sem will increase overhead
34
because more elm will be checked in timer isr
35
36
Please note it is quite stable
37
38
/Jens april 2015
39
40
41
1000 builtin/k-eat: 1005 / 1006
42
1000 builtin/k-eat: 1007 / 1006
43
1000 builtin/k-eat: 1006 / 1007
44
1000 builtin/k-eat: 1006 / 1005
45
1000 builtin/k-eat: 1006 / 1007
46
1000 builtin/k-eat: 1007 / 1006
47
1000 builtin/k-eat: 1005 / 1006
48
1000 builtin/k-eat: 1007 / 1006
49
1000 builtin/k-eat: 1006 / 1007
50
1000 builtin/k-eat: 1006 / 1006
51
1000 builtin/k-eat: 1007 / 1006
52
1000 builtin/k-eat: 1007 / 1007
53
1000 builtin/k-eat: 1006 / 1005
54
1000 builtin/k-eat: 1006 / 1007
55
1000 builtin/k-eat: 1007 / 1006
56
1000 builtin/k-eat: 1005 / 1006
57
1000 builtin/k-eat: 1007 / 1005
58
1000 builtin/k-eat: 1006 / 1007
59
1000 builtin/k-eat: 1006 / 1005
60
1000 builtin/k-eat: 1006 / 1006
61
1000 builtin/k-eat: 1007 / 1007
62
1000 builtin/k-eat: 1005 / 1005
63
1000 builtin/k-eat: 1007 / 1006
64
1000 builtin/k-eat: 1007 / 1006
65
1000 builtin/k-eat: 1005 / 1006
66
1000 builtin/k-eat: 1007 / 1005
67
1000 builtin/k-eat: 1006 / 1007
68
1000 builtin/k-eat: 1006 / 1005
69
1000 builtin/k-eat: 1006 / 1006
70
1000 builtin/k-eat: 1007 / 1006
71
1000 builtin/k-eat: 1005 / 1006
72
1000 builtin/k-eat: 1007 / 1006
73
1000 builtin/k-eat: 1006 / 1007
74
1000 builtin/k-eat: 1006 / 1007
75
1000 builtin/k-eat: 1007 / 1005
76
1000 builtin/k-eat: 1006 / 1007
77
1000 builtin/k-eat: 1006 / 1006
78
1000 builtin/k-eat: 1005 / 1006
79
1000 builtin/k-eat: 1007 / 1006
80
1000 builtin/k-eat: 1006 / 1007
81
1000 builtin/k-eat: 1006 / 1005
82
1000 builtin/k-eat: 1006 / 1007
83
1000 builtin/k-eat: 1007 / 1007
84
1000 builtin/k-eat: 1005 / 1006
85
1000 builtin/k-eat: 1007 / 1007
86
1000 builtin/k-eat: 1007 / 1006
87
1000 builtin/k-eat: 1005 / 1006
88
1000 builtin/k-eat: 1007 / 1006
89
1000 builtin/k-eat: 1006 / 1007
90
1000 builtin/k-eat: 1006 / 1005
91
<<
92
1000 builtin/k-eat: 1042 / 1042
93
1000 builtin/k-eat: 1041 / 1042
94
1000 builtin/k-eat: 1042 / 1041
95
1000 builtin/k-eat: 1041 / 1041
96
1000 builtin/k-eat: 1041 / 1042
97
1000 builtin/k-eat: 1041 / 1040
98
1000 builtin/k-eat: 1041 / 1040
99
1000 builtin/k-eat: 1040 / 1040
100
1000 builtin/k-eat: 1040 / 1041
101
1000 builtin/k-eat: 1042 / 1041
102
1000 builtin/k-eat: 1042 / 1041
103
1000 builtin/k-eat: 1041 / 1042
104
1000 builtin/k-eat: 1041 / 1042
105
1000 builtin/k-eat: 1042 / 1041
106
1000 builtin/k-eat: 1042 / 1041
107
1000 builtin/k-eat: 1041 / 1042
108
1000 builtin/k-eat: 1041 / 1042
109
1000 builtin/k-eat: 1042 / 1041
110
1000 builtin/k-eat: 1041 / 1040
111
1000 builtin/k-eat: 1040 / 1041
112
1000 builtin/k-eat: 1040 / 1041
113
1000 builtin/k-eat: 1041 / 1040
114
1000 builtin/k-eat: 1041 / 1041
115
1000 builtin/k-eat: 1041 / 1042
116
1000 builtin/k-eat: 1042 / 1041
117
1000 builtin/k-eat: 1042 / 1041
118
1000 builtin/k-eat: 1041 / 1041
119
1000 builtin/k-eat: 1041 / 1042
120
1000 builtin/k-eat: 1042 / 1041
121
1000 builtin/k-eat: 1042 / 1041
122
1000 builtin/k-eat: 1041 / 1042
123
1000 builtin/k-eat: 1041 / 1041
124
1000 builtin/k-eat: 1042 / 1040
125
1000 builtin/k-eat: 1040 / 1040
126
1000 builtin/k-eat: 1040 / 1041
127
1000 builtin/k-eat: 1040 / 1041
128
1000 builtin/k-eat: 1042 / 1041
129
1000 builtin/k-eat: 1041 / 1041
130
1000 builtin/k-eat: 1041 / 1042
131
1000 builtin/k-eat: 1042 / 1041
132
1000 builtin/k-eat: 1042 / 1041
133
1000 builtin/k-eat: 1041 / 1041
134
1000 builtin/k-eat: 1041 / 1042
135
1000 builtin/k-eat: 1042 / 1041
136
1000 builtin/k-eat: 1042 / 1041
137
1000 builtin/k-eat: 1041 / 1041
138
1000 builtin/k-eat: 1040 / 1041
139
1000 builtin/k-eat: 1041 / 1040
140
1000 builtin/k-eat: 1040 / 1040
141
1000 builtin/k-eat: 1041 / 1042
142
143
144
*/
145
146
#include <i2a.h>
147
148
#include <
krnl.h
>
149
150
char
a
[10];
151
152
void
test
(
int
msec)
153
{
154
unsigned
long
t1
,
t2
;
155
i2a(
a
, msec);
156
157
Serial.print(
a
);
158
Serial.print(
" builtin/k-eat: "
);
159
t1
= millis();
160
while
(msec > 10) {
161
delayMicroseconds
(10000);
162
msec -= 10;
163
}
164
delayMicroseconds
(msec * 1000);
165
t2
= millis();
166
t2
-=
t1
;
167
ul2a(
a
,
t2
);
168
Serial.print(
a
);
169
170
}
171
172
void
ktest
(
int
msec)
173
{
174
unsigned
long
t1
,
t2
;
175
176
Serial.print(
" / "
);
177
t1
= millis();
178
k_eat_time(msec);
179
t2
= millis();
180
t2
-=
t1
;
181
ul2a(
a
,
t2
);
182
Serial.println(
a
);
183
k_eat_time(100);
// wait på rs232
184
}
185
186
char
s1
[100];
187
void
t1
()
188
{
189
int
i
= 50;
190
while
(
i
--) {
191
test
(1000);
192
ktest
(1000);
193
}
194
while
(1);
195
}
196
197
198
void
setup
() {
199
// put your setup code here, to run once:
200
Serial.begin(9600);
201
for
(
int
i
= 0;
i
< 50;
i
++) {
202
test
(1000);
203
ktest
(1000);
204
}
205
Serial.println(
"<<"
);
206
k_init
(1, 0, 0);
207
k_crt_task
(
t1
, 10,
s1
, 100);
208
k_start
(1);
209
}
210
211
void
loop
() {}
// put your main code here, to run repeatedly:
212
213
i
volatile int i
Definition
k02twotasks.ino:29
s1
unsigned char s1[110]
Definition
k03asleep.ino:25
a
char a[150]
Definition
k08isrsem.ino:105
delayMicroseconds
void delayMicroseconds(unsigned int t)
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
test
void test(int msec)
Definition
k001timertest.ino:152
setup
void setup()
Definition
k001timertest.ino:198
ktest
void ktest(int msec)
Definition
k001timertest.ino:172
t1
void t1()
Definition
k001timertest.ino:187
loop
void loop()
Definition
k001timertest.ino:211
t1
struct k_t * t1
Definition
krnlgen.ino:3
t2
struct k_t * t2
Definition
krnlgen.ino:3
Generated by
1.15.0