altos: Disable telefire 'pad' listener when testing radio
authorKeith Packard <keithp@keithp.com>
Fri, 24 Aug 2012 07:27:13 +0000 (00:27 -0700)
committerKeith Packard <keithp@keithp.com>
Fri, 24 Aug 2012 07:27:13 +0000 (00:27 -0700)
Ensures that the radio testing won't block waiting for a firing mode
packet to arrive.

Signed-off-by: Keith Packard <keithp@keithp.com>
src/cc1111/ao_radio.c
src/drivers/ao_pad.c
src/drivers/ao_pad.h

index 2071c47a432cae2c4f8d3c628fea19e8578a9c34..46b2362d8b19e5a5245ca8b680a744ced8625ea7 100644 (file)
@@ -16,6 +16,9 @@
  */
 
 #include "ao.h"
+#if HAS_PAD
+#include <ao_pad.h>
+#endif
 
 /* Values from SmartRF® Studio for:
  *
@@ -484,6 +487,9 @@ ao_radio_test(void)
 #endif
 #if PACKET_HAS_SLAVE
                ao_packet_slave_stop();
+#endif
+#if HAS_PAD
+               ao_pad_disable();
 #endif
                ao_radio_get(0xff);
                RFST = RFST_STX;
@@ -500,6 +506,9 @@ ao_radio_test(void)
                radio_on = 0;
 #if HAS_MONITOR
                ao_monitor_enable();
+#endif
+#if HAS_PAD
+               ao_pad_enable();
 #endif
        }
 }
index 21aa788d0e17a9d7b830e1e2548c73d3aae1fd4e..b6dbcefef0e0e9c5c2b034356e04c2c97ffdbd7b 100644 (file)
@@ -71,6 +71,23 @@ ao_pad_status(void)
 static __pdata uint8_t ao_pad_armed;
 static __pdata uint16_t        ao_pad_arm_time;
 static __pdata uint8_t ao_pad_box;
+static __xdata uint8_t ao_pad_disabled;
+
+void
+ao_pad_disable(void)
+{
+       if (!ao_pad_disabled) {
+               ao_pad_disabled = 1;
+               ao_radio_recv_abort();
+       }
+}
+
+void
+ao_pad_enable(void)
+{
+       ao_pad_disabled = 0;
+       ao_wakeup (&ao_pad_disabled);
+}
 
 static void
 ao_pad(void)
@@ -85,6 +102,8 @@ ao_pad(void)
        ao_pad_box = ao_74hc497_read();
        for (;;) {
                flush();
+               while (ao_pad_disabled)
+                       ao_sleep(&ao_pad_disabled);
                if (ao_radio_cmac_recv(&command, sizeof (command), 0) != AO_RADIO_CMAC_OK)
                        continue;
                
index 9ea016ff93d04bebd6092c9e902d80de8193c0e8..d5ca3a888871e82bc94672951950ea7578347e4e 100644 (file)
@@ -64,4 +64,10 @@ struct ao_pad_query {
 void
 ao_pad_init(void);
 
+void
+ao_pad_disable(void);
+
+void
+ao_pad_enable(void);
+
 #endif /* _AO_PAD_H_ */