From 5d29fe79d30f430ae326d9dc57ccfaed6fe61328 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karel=20Ko=C4=8D=C3=AD?= Date: Tue, 8 Mar 2016 16:10:33 +0100 Subject: Another full update of current work --- src/tasks.c | 64 ++++++++++++++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 55 insertions(+), 9 deletions(-) (limited to 'src/tasks.c') diff --git a/src/tasks.c b/src/tasks.c index 1d94eaa..abc2add 100644 --- a/src/tasks.c +++ b/src/tasks.c @@ -1,16 +1,62 @@ -#include "../tasks.h" - +#include #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) { +} + +void init_mutex(Mutex * mtx, uint8_t flags) { +}; +void take_mutex(Mutex * mtx) { +}; +int8_t take_mutex_t(Mutex * mtx, uint16_t timeout) { +}; +void give_mutex(Mutex * mtx) { +}; + #else /* CONFIG_IOE_TASKS */ -int8_t taskDelayTillT(int8_t *condition, uint8_t timeout_10us) { - while(*condition == 0) { - if (timeout_10us == 0) - return 1; - timeout_10us--; - _delay_us(10); - } +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; } -- cgit v1.2.3