blob: 0f75887d86b134c04851e5f82cd5ce1ebcde3ddc (
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
|
#include "progman.h"
#define EMPTY_PROG_INFO 0x0
struct program_info *prog_0 = PROG_0_INFO,
*prog_1 = PROG_1_INFO;
void progman_init() {
*prog_0 = EMPTY_PROG_INFO;
*prog_1 = EMPTY_PROG_INFO;
// TODO other stuff
}
int8_t prog_req(struct program_info *info) {
uint8_t prog;
if (!prog_0->enabled) {
prog = PROG_0;
*info = *prog_0;
} else if (!prog_1->enabled) {
prog = PROG_1;
*info = *prog_1;
} else {
return PROG_REQ_FULL;
}
return prog;
}
void prog_alloc(int8_t id, struct program_info *info, const struct program_base *base) {
// TODO, implements program allocation
}
void prog_exec(int8_t id, struct program_info *info) {
// TODO, perform a program counter jump
}
void prog_0_qcb(void (*callback)(void)) {
prog_0->quit_cb = callback;
}
void prog_1_qcb(void (*callback)(void)) {
prog_1->quit_cb = callback;
}
void prog_0_quit() {
if (!prog_0->enabled || prog_0->exiting)
return;
if (prog_0->quit_cb)
prog_0->quit_cb();
// TODO free space in RAM
*prog_0 = EMPTY_PROG_INFO;
// TODO jump program counter
}
void prog_1_quit() {
if (!prog_1->enabled || prog_1->exiting)
return;
if (prog_1->quit_cb)
prog_1->quit_cb();
// TODO free space in RAM
*prog_1 = EMPTY_PROG_INFO;
// TODO jump program counter
}
void prog_0_fquit() {
if (!prog_0->enabled)
return;
// TODO free space in RAM
*prog_0 = EMPTY_PROG_INFO;
// TODO jump program counter
}
void prog_1_fquit() {
if (!prog_1->enabled)
return;
// TODO free space in RAM
*prog_1 = EMPTY_PROG_INFO;
// TODO jump program counter
}
|