diff options
author | Keith Packard <keithp@keithp.com> | 2012-08-28 18:03:52 -0700 |
---|---|---|
committer | Keith Packard <keithp@keithp.com> | 2012-08-28 23:00:22 -0700 |
commit | 31b42b99edbb976534ac432c07e218f13d1f5f9b (patch) | |
tree | 738feb9a042a1dad0c04e36b610a0e1099050c40 /src/core/ao_task.c | |
parent | ac5d053e6d766d243b7a425ae19779810c350125 (diff) |
altos: Fix ao_delay function and move from per-chip code to ao_task.c
ao_delay hasn't been chip-specific for a long time, and it had a bug
in not calling ao_clear_alarm.
Signed-off-by: Keith Packard <keithp@keithp.com>
Diffstat (limited to 'src/core/ao_task.c')
-rw-r--r-- | src/core/ao_task.c | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/src/core/ao_task.c b/src/core/ao_task.c index 4593bd79..65654731 100644 --- a/src/core/ao_task.c +++ b/src/core/ao_task.c @@ -125,6 +125,7 @@ ao_sleep(__xdata void *wchan) ao_yield(); if (ao_cur_task->wchan) { ao_cur_task->wchan = NULL; + ao_cur_task->alarm = 0; return 1; } return 0; @@ -157,6 +158,16 @@ ao_clear_alarm(void) 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) { |