summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKeith Packard <keithp@keithp.com>2009-10-31 01:19:41 -0700
committerKeith Packard <keithp@keithp.com>2009-10-31 01:19:41 -0700
commit442b1ef18c8320d4e5329dc92bb5268a36058fc5 (patch)
tree1511189c334bf254526ed7dee7964a701bbf2065
parent4f7ed9ff484778381db647c27d2a34d0cadec41e (diff)
Use ao_alarm for ao_delay so it can be easily interrupted
-rw-r--r--src/ao_timer.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/ao_timer.c b/src/ao_timer.c
index 78c6e063..d7603435 100644
--- a/src/ao_timer.c
+++ b/src/ao_timer.c
@@ -24,13 +24,13 @@ uint16_t ao_time(void) __critical
return ao_tick_count;
}
+static __xdata uint8_t ao_forever;
+
void
ao_delay(uint16_t ticks)
{
- uint16_t until = ao_time() + ticks;
-
- while ((int16_t) (until - ao_time()) > 0)
- ao_sleep(DATA_TO_XDATA(&ao_tick_count));
+ ao_alarm(ticks);
+ ao_sleep(&ao_forever);
}
#define T1_CLOCK_DIVISOR 8 /* 24e6/8 = 3e6 */