Clean up telemetry now that all packets are the same
authorKeith Packard <keithp@keithp.com>
Tue, 21 Apr 2009 09:07:24 +0000 (02:07 -0700)
committerKeith Packard <keithp@keithp.com>
Tue, 21 Apr 2009 09:07:24 +0000 (02:07 -0700)
ao.h
ao_radio.c
ao_telemetry.c

diff --git a/ao.h b/ao.h
index c2e83277ca6e6c3e2320a3ccfd6b5f40de2ad41f..02810d05baefa61683254fdbb53149e128428603 100644 (file)
--- a/ao.h
+++ b/ao.h
@@ -695,9 +695,6 @@ struct ao_telemetry {
        struct ao_gps_data      gps;
 };
 
-void
-ao_telemetry_send(__xdata struct ao_telemetry *telemetry) __reentrant;
-
 void
 ao_telemetry_init(void);
 
index 5ff6f9bf41ee935f864bbaa44b5fb263e47c010a..13362d3e32ca3f09e68ff1f8f0c0691336fe2acb 100644 (file)
@@ -217,7 +217,7 @@ ao_radio_send(__xdata struct ao_telemetry *telemetry) __reentrant
                            DMA_CFG1_PRIORITY_HIGH);
        ao_dma_start(ao_radio_dma);
        RFST = RFST_STX;
-       while (!ao_radio_dma_done)
+       __critical while (!ao_radio_dma_done)
                ao_sleep(&ao_radio_dma_done);
        ao_mutex_put(&ao_radio_mutex);
 }
@@ -239,7 +239,7 @@ ao_radio_recv(__xdata struct ao_radio_recv *radio) __reentrant
                            DMA_CFG1_PRIORITY_HIGH);
        ao_dma_start(ao_radio_dma);
        RFST = RFST_SRX;
-       while (!ao_radio_dma_done)
+       __critical while (!ao_radio_dma_done)
                ao_sleep(&ao_radio_dma_done);
        ao_mutex_put(&ao_radio_mutex);
 }
index b46f03c76e737c31f0325b8d3b953737ed417928..90cf2e4ef254aec2a61a055910953255c46831fb 100644 (file)
 
 uint8_t        ao_serial_number = 2;
 
-void
-ao_telemetry_send(__xdata struct ao_telemetry *telemetry) __reentrant
-{
-       if (ao_flight_state != ao_flight_idle && ao_flight_state != ao_flight_startup) {
-               telemetry->addr = ao_serial_number;
-               telemetry->flight_state = ao_flight_state;
-               ao_radio_send(telemetry);
-       }
-}
-
 void
 ao_telemetry(void)
 {
@@ -41,11 +31,13 @@ ao_telemetry(void)
                ao_sleep(DATA_TO_XDATA(&ao_flight_state));
 
        for (;;) {
+               telemetry.addr = ao_serial_number;
+               telemetry.flight_state = ao_flight_state;
                ao_adc_get(&telemetry.adc);
                ao_mutex_get(&ao_gps_mutex);
                memcpy(&telemetry.gps, &ao_gps_data, sizeof (struct ao_gps_data));
                ao_mutex_put(&ao_gps_mutex);
-               ao_telemetry_send(&telemetry);
+               ao_radio_send(&telemetry);
                ao_delay(AO_MS_TO_TICKS(1000));
        }
 }