projects
/
fw
/
altos
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
altos: When missing MMA655x, create fake Z accel value
[fw/altos]
/
src
/
core
/
ao_task.c
diff --git
a/src/core/ao_task.c
b/src/core/ao_task.c
index 4011a36e06297f7423c85aabed8d6f2f2a0561d9..65654731aeaeaccc9f45477e156ffa1419d13c0b 100644
(file)
--- a/
src/core/ao_task.c
+++ b/
src/core/ao_task.c
@@
-82,39
+82,36
@@
ao_yield(void) ao_arch_naked_define
ao_arch_isr_stack();
ao_arch_isr_stack();
-#if CHECK_STACK
+#if
AO_
CHECK_STACK
in_yield = 1;
#endif
/* Find a task to run. If there isn't any runnable task,
* this loop will run forever, which is just fine
*/
{
in_yield = 1;
#endif
/* Find a task to run. If there isn't any runnable task,
* this loop will run forever, which is just fine
*/
{
- __pdata uint8_t ao_
nex
t_task_index = ao_cur_task_index;
+ __pdata uint8_t ao_
las
t_task_index = ao_cur_task_index;
for (;;) {
for (;;) {
- ++ao_next_task_index;
- if (ao_next_task_index == ao_num_tasks)
- ao_next_task_index = 0;
+ ++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];
- ao_cur_task = ao_tasks[ao_next_task_index];
- if (ao_cur_task->wchan == NULL) {
- ao_cur_task_index = ao_next_task_index;
+ /* Check for ready task */
+ if (ao_cur_task->wchan == NULL)
break;
break;
- }
/* Check if the alarm is set for a time which has passed */
if (ao_cur_task->alarm &&
/* Check if the alarm is set for a time which has passed */
if (ao_cur_task->alarm &&
- (int16_t) (ao_time() - ao_cur_task->alarm) >= 0) {
- ao_cur_task_index = ao_next_task_index;
+ (int16_t) (ao_time() - ao_cur_task->alarm) >= 0)
break;
break;
- }
/* Enter lower power mode when there isn't anything to do */
/* Enter lower power mode when there isn't anything to do */
- if (ao_
next_task_index == ao_cur_task_index) {
+ if (ao_
cur_task_index == ao_last_task_index)
ao_arch_cpu_idle();
ao_arch_cpu_idle();
- }
}
}
}
}
-#if CHECK_STACK
+#if
AO_
CHECK_STACK
cli();
in_yield = 0;
#endif
cli();
in_yield = 0;
#endif
@@
-128,6
+125,7
@@
ao_sleep(__xdata void *wchan)
ao_yield();
if (ao_cur_task->wchan) {
ao_cur_task->wchan = NULL;
ao_yield();
if (ao_cur_task->wchan) {
ao_cur_task->wchan = NULL;
+ ao_cur_task->alarm = 0;
return 1;
}
return 0;
return 1;
}
return 0;
@@
-160,6
+158,16
@@
ao_clear_alarm(void)
ao_cur_task->alarm = 0;
}
ao_cur_task->alarm = 0;
}
+static __xdata uint8_t ao_forever;
+
+void
+ao_delay(uint16_t ticks)
+{
+ ao_alarm(ticks);
+ ao_sleep(&ao_forever);
+ ao_clear_alarm();
+}
+
void
ao_exit(void)
{
void
ao_exit(void)
{
@@
-177,7
+185,7
@@
ao_exit(void)
void
ao_task_info(void)
{
void
ao_task_info(void)
{
- uint8_t i;
+ uint8_t
i;
__xdata struct ao_task *task;
for (i = 0; i < ao_num_tasks; i++) {
__xdata struct ao_task *task;
for (i = 0; i < ao_num_tasks; i++) {