From fee46389b70a624ab5b1128a8b4c3083c7747bcb Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Fri, 4 Sep 2009 11:46:55 -0700 Subject: [PATCH] Make RDF beacon only run on pad and after landing. 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 --- src/ao.h | 2 +- src/ao_flight.c | 5 ++--- src/ao_radio.c | 18 +++++++++++++++--- src/ao_telemetry.c | 9 ++++++--- 4 files changed, 24 insertions(+), 10 deletions(-) diff --git a/src/ao.h b/src/ao.h index 37f21508..4116be65 100644 --- 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_rdf(void); +ao_radio_rdf(int ms); void ao_radio_rdf_abort(void); diff --git a/src/ao_flight.c b/src/ao_flight.c index 2b062c13..ec89e7c2 100644 --- a/src/ao_flight.c +++ b/src/ao_flight.c @@ -360,9 +360,6 @@ ao_flight(void) /* 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 @@ -445,6 +442,8 @@ ao_flight(void) /* 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)); } diff --git a/src/ao_radio.c b/src/ao_radio.c index e4d42c6c..76fa3e5d 100644 --- a/src/ao_radio.c +++ b/src/ao_radio.c @@ -223,7 +223,6 @@ static __code uint8_t rdf_setup[] = { (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| @@ -324,19 +323,32 @@ __xdata ao_radio_rdf_running; __xdata ao_radio_rdf_value = 0x55; void -ao_radio_rdf(void) +ao_radio_rdf(int ms) { 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]; + /* + * 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, - RDF_PACKET_LEN, + pkt_len, DMA_CFG0_WORDSIZE_8 | DMA_CFG0_TMODE_SINGLE | DMA_CFG0_TRIGGER_RADIO, diff --git a/src/ao_telemetry.c b/src/ao_telemetry.c index 7eefee3c..d52e589c 100644 --- a/src/ao_telemetry.c +++ b/src/ao_telemetry.c @@ -21,7 +21,8 @@ __xdata uint16_t ao_telemetry_interval = 0; __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) @@ -51,8 +52,8 @@ ao_telemetry(void) 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); } } @@ -71,6 +72,8 @@ ao_rdf_set(uint8_t rdf) ao_rdf = rdf; if (rdf == 0) ao_radio_rdf_abort(); + else + ao_rdf_time = ao_time(); } __xdata struct ao_task ao_telemetry_task; -- 2.30.2