summaryrefslogtreecommitdiff
path: root/ao_task.c
diff options
context:
space:
mode:
authorKeith Packard <keithp@keithp.com>2009-04-14 14:21:56 -0700
committerKeith Packard <keithp@keithp.com>2009-04-14 14:21:56 -0700
commitac99982b10fd5772218660137ee21db9b90cd885 (patch)
treeba63d3de2d647a7d159a2f3fe1cc7676125c0702 /ao_task.c
parentfbd8f4aff5058f4d371596b04715b7cb6d38e729 (diff)
Add eeprom driver and command loop
This involved adding dma control and a mutex implementation. Signed-off-by: Keith Packard <keithp@keithp.com>
Diffstat (limited to 'ao_task.c')
-rw-r--r--ao_task.c17
1 files changed, 9 insertions, 8 deletions
diff --git a/ao_task.c b/ao_task.c
index 2e0a8b33..f79d6e1f 100644
--- a/ao_task.c
+++ b/ao_task.c
@@ -17,11 +17,11 @@
#include "ao.h"
-#define AO_NO_TASK 0xff
+#define AO_NO_TASK_INDEX 0xff
__xdata struct ao_task * __xdata ao_tasks[AO_NUM_TASKS];
__data uint8_t ao_num_tasks;
-__data uint8_t ao_cur_task_id;
+__data uint8_t ao_cur_task_index;
__xdata struct ao_task *__data ao_cur_task;
void
@@ -31,6 +31,7 @@ ao_add_task(__xdata struct ao_task * task, void (*start)(void))
if (ao_num_tasks == AO_NUM_TASKS)
ao_panic(AO_PANIC_NO_TASK);
ao_tasks[ao_num_tasks++] = task;
+ task->task_id = ao_num_tasks;
/*
* Construct a stack frame so that it will 'return'
* to the start of the task
@@ -94,7 +95,7 @@ ao_yield(void) _naked
push _bp
_endasm;
- if (ao_cur_task_id != AO_NO_TASK)
+ if (ao_cur_task_index != AO_NO_TASK_INDEX)
{
/* Save the current stack */
stack_len = SP - (AO_STACK_START - 1);
@@ -112,10 +113,10 @@ ao_yield(void) _naked
* this loop will run forever, which is just fine
*/
for (;;) {
- ++ao_cur_task_id;
- if (ao_cur_task_id == ao_num_tasks)
- ao_cur_task_id = 0;
- ao_cur_task = ao_tasks[ao_cur_task_id];
+ ++ao_cur_task_index;
+ if (ao_cur_task_index == ao_num_tasks)
+ ao_cur_task_index = 0;
+ ao_cur_task = ao_tasks[ao_cur_task_index];
if (ao_cur_task->wchan == NULL)
break;
}
@@ -182,7 +183,7 @@ void
ao_start_scheduler(void)
{
- ao_cur_task_id = AO_NO_TASK;
+ ao_cur_task_index = AO_NO_TASK_INDEX;
ao_cur_task = NULL;
ao_yield();
}