projects
/
fw
/
altos
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Add eeprom driver and command loop
[fw/altos]
/
ao_task.c
diff --git
a/ao_task.c
b/ao_task.c
index 2e0a8b33207921e87feee02f0382240429ab0c5e..f79d6e1f184aa530917f59050856a00256b61860 100644
(file)
--- a/
ao_task.c
+++ b/
ao_task.c
@@
-17,11
+17,11
@@
#include "ao.h"
#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;
__xdata struct ao_task * __xdata ao_tasks[AO_NUM_TASKS];
__data uint8_t ao_num_tasks;
-__data uint8_t ao_cur_task_i
d
;
+__data uint8_t ao_cur_task_i
ndex
;
__xdata struct ao_task *__data ao_cur_task;
void
__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;
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
/*
* 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;
push _bp
_endasm;
- if (ao_cur_task_i
d != AO_NO_TASK
)
+ if (ao_cur_task_i
ndex != AO_NO_TASK_INDEX
)
{
/* Save the current stack */
stack_len = SP - (AO_STACK_START - 1);
{
/* 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 (;;) {
* this loop will run forever, which is just fine
*/
for (;;) {
- ++ao_cur_task_i
d
;
- if (ao_cur_task_i
d
== ao_num_tasks)
- ao_cur_task_i
d
= 0;
- ao_cur_task = ao_tasks[ao_cur_task_i
d
];
+ ++ao_cur_task_i
ndex
;
+ if (ao_cur_task_i
ndex
== ao_num_tasks)
+ ao_cur_task_i
ndex
= 0;
+ ao_cur_task = ao_tasks[ao_cur_task_i
ndex
];
if (ao_cur_task->wchan == NULL)
break;
}
if (ao_cur_task->wchan == NULL)
break;
}
@@
-182,7
+183,7
@@
void
ao_start_scheduler(void)
{
ao_start_scheduler(void)
{
- ao_cur_task_i
d = AO_NO_TASK
;
+ ao_cur_task_i
ndex = AO_NO_TASK_INDEX
;
ao_cur_task = NULL;
ao_yield();
}
ao_cur_task = NULL;
ao_yield();
}