aboutsummaryrefslogtreecommitdiff
path: root/src/tasks.c
blob: 27f8fb4279a856d07d5c3a25fbc4c9b496f8c6a1 (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
#include <tasks.h>
#ifdef CONFIG_IOE_TASKS

void tasks_run(void) {
}

void task_init(Task * t, void (*func) (void)) {
}
void task_start(Task * t) {
}

void task_delay(uint16_t us) {
}
void task_delay_ms(uint16_t ms) {
}
void task_delay_till(volatile int8_t * boolean, uint16_t timeout) {
}

int8_t task_stack_init(TaskStack * ts, uint8_t stack_size, uint8_t flags) {
    ts->stack = malloc(stack_size * sizeof(uint8_t));
    ts->flags = flags;
    ts->running = NULL;
    ts->pending = NULL;
}

void task_stack_free(TaskStack * ts) {
    free(ts->stack);
}

void task_stack_reg(TaskStack * ts, Task * t) {
}

void task_stack_unreg(TaskStack * ts, Task * t) {
}

#else /* CONFIG_IOE_TASKS */

int8_t task_delay_till(volatile int8_t * boolean, uint16_t timeout) {
    if (timeout == 0)
        while (!*boolean)
            _delay_us(100);
    else
        // TODO this implementation should be improved to check boolean as often
        // as possible
        while (*boolean == 0) {
            if (timeout == 0)
                return 1;
            timeout--;
            _delay_ms(1);
        }
    return 0;
}

#endif /* CONFIG_IOE_TASKS */