-static __xdata uint16_t ao_packet_timer_delay;
-static __xdata uint8_t ao_packet_timer_cancelled;
-
-static __xdata struct ao_task ao_packet_task;
-static __xdata struct ao_task ao_packet_timer_task;
-static __xdata uint8_t ao_packet_enable;
-static __xdata uint8_t ao_packet_master_sleeping;
-
-void
-ao_packet_timer(void) __reentrant
-{
- uint16_t delay;
-
- while (ao_packet_enable) {
-
- /* wait until the timer task is needed
- */
- while (!ao_packet_timer_delay && ao_packet_enable)
- ao_sleep(&ao_packet_timer_delay);
-
- delay = ao_packet_timer_delay;
- ao_packet_timer_delay = 0;
-
- /* pause waiting for either a timeout or
- * a timer cancel
- */
- ao_delay(delay);
-
- /* if not canceled, abort the receive
- */
- if (!ao_packet_timer_cancelled) {
- printf ("packet timeout\n"); flush();
- ao_radio_abort(AO_DMA_TIMEOUT);
- }
- }
- ao_exit();
-}
-
-void
-ao_packet_timer_set(uint16_t delay)
-{
- ao_packet_timer_delay = delay;
- ao_packet_timer_cancelled = 0;
- ao_wakeup(&ao_packet_timer_delay);
-}
-
-void
-ao_packet_timer_cancel(void)
-{
- ao_packet_timer_cancelled = 1;
- ao_packet_timer_delay = 0;
- ao_wake_task(&ao_packet_timer_task);
-}