aboutsummaryrefslogtreecommitdiff
path: root/sem4/embedded/emb_m4/emb_m4.ino
blob: 7e5ff4881d853a9c485835627cc02c65fc43e1ce (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#include <krnl.h>
#define STACK 100

char stk1[STACK];
char stk2[STACK];
struct k_t *tsk1, *tsk2;

void f1() {
	for(int i = 0;;i++) {
		Serial.println(i);
        k_sleep(400);
	}
}
void f2() {
	bool state = false;
	for(;;) {
		digitalWrite(13, state);
		state = !state;
		k_sleep(100);
	}
}

void setup()
{
	pinMode(13, OUTPUT);
	Serial.begin(115200);
	Serial.println("Starting");

	k_init(2, 0, 0);

	tsk1 = k_crt_task(f1, 10, stk1, STACK);
	tsk2 = k_crt_task(f2, 10, stk2, STACK);

	k_start(1);
}

void loop()
{
	
}