Make RDF beacon only run on pad and after landing.
authorKeith Packard <keithp@keithp.com>
Fri, 4 Sep 2009 18:46:55 +0000 (11:46 -0700)
committerKeith Packard <keithp@keithp.com>
Fri, 4 Sep 2009 18:46:55 +0000 (11:46 -0700)
It's pretty much impossible to RDF the rocket during flight, and it
interferes with the telemetry data stream. Leave it enabled on the pad
so that radios can be tested, and then re-enable it once the rocket
has landed.

This patch also turns the rdf 'on' time into a parameter so it can be
changed, and then sets that parameter to 500ms, once every 5 seconds.

Signed-off-by: Keith Packard <keithp@keithp.com>
src/ao.h
src/ao_flight.c
src/ao_radio.c
src/ao_telemetry.c

index 37f21508dd0877f1f6f4ae2427f13e1b0a22e273..4116be65ae13f22aef242957363d4b2ffa42147b 100644 (file)
--- a/src/ao.h
+++ b/src/ao.h
@@ -800,7 +800,7 @@ void
 ao_radio_recv(__xdata struct ao_radio_recv *recv) __reentrant;
 
 void
 ao_radio_recv(__xdata struct ao_radio_recv *recv) __reentrant;
 
 void
-ao_radio_rdf(void);
+ao_radio_rdf(int ms);
 
 void
 ao_radio_rdf_abort(void);
 
 void
 ao_radio_rdf_abort(void);
index 2b062c13fbec8a0a545530015f077a5ad8b8307c..ec89e7c2f7e97bdbbb850ead7f1015b1e45e83f1 100644 (file)
@@ -360,9 +360,6 @@ ao_flight(void)
                                /* slow down the ADC sample rate */
                                ao_timer_set_adc_interval(10);
 
                                /* slow down the ADC sample rate */
                                ao_timer_set_adc_interval(10);
 
-                               /* Enable RDF beacon */
-                               ao_rdf_set(1);
-
                                /*
                                 * Start recording min/max accel and pres for a while
                                 * to figure out when the rocket has landed
                                /*
                                 * Start recording min/max accel and pres for a while
                                 * to figure out when the rocket has landed
@@ -445,6 +442,8 @@ ao_flight(void)
 
                                /* turn off the ADC capture */
                                ao_timer_set_adc_interval(0);
 
                                /* turn off the ADC capture */
                                ao_timer_set_adc_interval(0);
+                               /* Enable RDF beacon */
+                               ao_rdf_set(1);
 
                                ao_wakeup(DATA_TO_XDATA(&ao_flight_state));
                        }
 
                                ao_wakeup(DATA_TO_XDATA(&ao_flight_state));
                        }
index e4d42c6c32734b2f1542c9ae411c872a0bc3f6ef..76fa3e5dc497eb5f6913ca15e3fce8354cd8b2ff 100644 (file)
@@ -223,7 +223,6 @@ static __code uint8_t rdf_setup[] = {
                                 (RDF_DEVIATION_M << RF_DEVIATN_DEVIATION_M_SHIFT)),
 
        /* packet length */
                                 (RDF_DEVIATION_M << RF_DEVIATN_DEVIATION_M_SHIFT)),
 
        /* packet length */
-       RF_PKTLEN_OFF,          RDF_PACKET_LEN,
        RF_PKTCTRL1_OFF,        ((1 << PKTCTRL1_PQT_SHIFT)|
                                 PKTCTRL1_ADR_CHK_NONE),
        RF_PKTCTRL0_OFF,        (RF_PKTCTRL0_PKT_FORMAT_NORMAL|
        RF_PKTCTRL1_OFF,        ((1 << PKTCTRL1_PQT_SHIFT)|
                                 PKTCTRL1_ADR_CHK_NONE),
        RF_PKTCTRL0_OFF,        (RF_PKTCTRL0_PKT_FORMAT_NORMAL|
@@ -324,19 +323,32 @@ __xdata ao_radio_rdf_running;
 __xdata ao_radio_rdf_value = 0x55;
 
 void
 __xdata ao_radio_rdf_value = 0x55;
 
 void
-ao_radio_rdf(void)
+ao_radio_rdf(int ms)
 {
        uint8_t i;
 {
        uint8_t i;
+       uint8_t pkt_len;
        ao_mutex_get(&ao_radio_mutex);
        ao_radio_idle();
        ao_radio_rdf_running = 1;
        for (i = 0; i < sizeof (rdf_setup); i += 2)
                RF[rdf_setup[i]] = rdf_setup[i+1];
 
        ao_mutex_get(&ao_radio_mutex);
        ao_radio_idle();
        ao_radio_rdf_running = 1;
        for (i = 0; i < sizeof (rdf_setup); i += 2)
                RF[rdf_setup[i]] = rdf_setup[i+1];
 
+       /*
+        * Compute the packet length as follows:
+        *
+        * 2000 bps (for a 1kHz tone)
+        * so, for 'ms' milliseconds, we need
+        * 2 * ms bits, or ms / 4 bytes
+        */
+       if (ms > (255 * 4))
+               ms = 255 * 4;
+       pkt_len = ms >> 2;
+       RF[RF_PKTLEN_OFF] = pkt_len;
+
        ao_dma_set_transfer(ao_radio_dma,
                            &ao_radio_rdf_value,
                            &RFDXADDR,
        ao_dma_set_transfer(ao_radio_dma,
                            &ao_radio_rdf_value,
                            &RFDXADDR,
-                           RDF_PACKET_LEN,
+                           pkt_len,
                            DMA_CFG0_WORDSIZE_8 |
                            DMA_CFG0_TMODE_SINGLE |
                            DMA_CFG0_TRIGGER_RADIO,
                            DMA_CFG0_WORDSIZE_8 |
                            DMA_CFG0_TMODE_SINGLE |
                            DMA_CFG0_TRIGGER_RADIO,
index 7eefee3c2ea7554a494bdf0c0c29f77c032e7b23..d52e589c78a3ea245df37ef36a30bfa7d43973d2 100644 (file)
@@ -21,7 +21,8 @@ __xdata uint16_t ao_telemetry_interval = 0;
 __xdata uint8_t ao_rdf = 0;
 __xdata uint16_t ao_rdf_time;
 
 __xdata uint8_t ao_rdf = 0;
 __xdata uint16_t ao_rdf_time;
 
-#define AO_RDF_INTERVAL        AO_SEC_TO_TICKS(3)
+#define AO_RDF_INTERVAL_TICKS  AO_SEC_TO_TICKS(5)
+#define AO_RDF_LENGTH_MS       500
 
 void
 ao_telemetry(void)
 
 void
 ao_telemetry(void)
@@ -51,8 +52,8 @@ ao_telemetry(void)
                if (ao_rdf &&
                    (int16_t) (ao_time() - ao_rdf_time) >= 0)
                {
                if (ao_rdf &&
                    (int16_t) (ao_time() - ao_rdf_time) >= 0)
                {
-                       ao_rdf_time = ao_time() + AO_RDF_INTERVAL;
-                       ao_radio_rdf();
+                       ao_rdf_time = ao_time() + AO_RDF_INTERVAL_TICKS;
+                       ao_radio_rdf(AO_RDF_LENGTH_MS);
                        ao_delay(ao_telemetry_interval);
                }
        }
                        ao_delay(ao_telemetry_interval);
                }
        }
@@ -71,6 +72,8 @@ ao_rdf_set(uint8_t rdf)
        ao_rdf = rdf;
        if (rdf == 0)
                ao_radio_rdf_abort();
        ao_rdf = rdf;
        if (rdf == 0)
                ao_radio_rdf_abort();
+       else
+               ao_rdf_time = ao_time();
 }
 
 __xdata struct ao_task ao_telemetry_task;
 }
 
 __xdata struct ao_task ao_telemetry_task;