aboutsummaryrefslogtreecommitdiff
path: root/sem1/osc/mm8/mm8.ino
blob: f47306d586aeb96e451c825a6b3d1601e8c20d0c (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
42
43
44
45
46
47
// Spg kernel
#include <krnl.h>

#define PRIO 10
#define STACK 100

char stackFast[STACK];
struct k_t *semFast, *fastTask;

void fast() {
	/* Gotta go fast(10 Hz) */
	k_set_sem_timer(semFast, 1000);
	for(;;) {
		k_wait(semFast, 0);
		k_eat_ticks(90);
	}
}

void setup() {
	pinMode(13, OUTPUT);

	PORTB |= 0x20;
	delay(1000);
	PORTB &= 0xDF;
	delay(200);

	k_init(1, 1, 0);
	
	fastTask = k_crt_task(fast, PRIO, stackFast, STACK);
	semFast = k_crt_sem(0, 2);

	k_start(1);
	PORTB |= 0x20;
}

void loop() {}

extern "C" {

	void k_breakout() {
		if( pRun->nr == 0 ) {
			PORTB |= 0x20;
		} else {
			PORTB &= 0xDF;
		}
	}
}