altos: Fix ao_delay function and move from per-chip code to ao_task.c
authorKeith Packard <keithp@keithp.com>
Wed, 29 Aug 2012 01:03:52 +0000 (18:03 -0700)
committerKeith Packard <keithp@keithp.com>
Wed, 29 Aug 2012 06:00:22 +0000 (23:00 -0700)
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>
src/avr/ao_timer.c
src/cc1111/ao_timer.c
src/core/ao_task.c
src/stm/ao_timer.c

index cd81b163bc37bf657971095de81f8f83a774d053..d2ea2be7da5ce142ceb46ad0d3ebaa40c1689add 100644 (file)
@@ -28,15 +28,6 @@ uint16_t ao_time(void)
        return v;
 }
 
-static __xdata uint8_t ao_forever;
-
-void
-ao_delay(uint16_t ticks)
-{
-       ao_alarm(ticks);
-       ao_sleep(&ao_forever);
-}
-
 #define T1_CLOCK_DIVISOR       8       /* 24e6/8 = 3e6 */
 #define T1_SAMPLE_TIME         30000   /* 3e6/30000 = 100 */
 
index 602f98c8276720c047751d95baff9c4fd14fbecc..a64b5aba90a0fb5e104a3005dbf2cdda464056ad 100644 (file)
@@ -24,16 +24,6 @@ uint16_t ao_time(void) __critical
        return ao_tick_count;
 }
 
-static __xdata uint8_t ao_forever;
-
-void
-ao_delay(uint16_t ticks)
-{
-       ao_alarm(ticks);
-       ao_sleep(&ao_forever);
-       ao_clear_alarm();
-}
-
 #define T1_CLOCK_DIVISOR       8       /* 24e6/8 = 3e6 */
 #define T1_SAMPLE_TIME         30000   /* 3e6/30000 = 100 */
 
index 4593bd790c4717586d258489749212d5cf4a5aae..65654731aeaeaccc9f45477e156ffa1419d13c0b 100644 (file)
@@ -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)
 {
index 78228e65b72d10ad43df98e47694fc92c4b374bf..f561e6b56851303d1af929c849acd0658e23dff8 100644 (file)
@@ -28,15 +28,6 @@ uint16_t ao_time(void)
        return v;
 }
 
-static __xdata uint8_t ao_forever;
-
-void
-ao_delay(uint16_t ticks)
-{
-       ao_alarm(ticks);
-       ao_sleep(&ao_forever);
-}
-
 #if AO_DATA_ALL
 volatile __data uint8_t        ao_data_interval = 1;
 volatile __data uint8_t        ao_data_count;