altos: Make telemetrum-v1.1 compile with new ao_data structure
[fw/altos] / src / stm / ao_adc_stm.c
index 576dbf5d6c76b78c946575aa94f0c29f8d3d55ee..ea9e25e48a9f94d0438c7d4ca03e908be1c89c99 100644 (file)
@@ -50,15 +50,22 @@ static uint8_t                      ao_adc_ready;
  */
 static void ao_adc_done(int index)
 {
+       uint8_t step = 1;
        ao_data_ring[ao_data_head].tick = ao_time();
 #if HAS_MPU6000
+       if (!ao_mpu6000_valid)
+               step = 0;
        ao_data_ring[ao_data_head].mpu6000 = ao_mpu6000_current;
 #endif
 #if HAS_MS5607
+       if (!ao_ms5607_valid)
+               step = 0;
        ao_data_ring[ao_data_head].ms5607 = ao_ms5607_current;
 #endif 
-       ao_data_head = ao_data_ring_next(ao_data_head);
-       ao_wakeup((void *) &ao_data_head);
+       if (step) {
+               ao_data_head = ao_data_ring_next(ao_data_head);
+               ao_wakeup((void *) &ao_data_head);
+       }
        ao_dma_done_transfer(STM_DMA_INDEX(STM_DMA_CHANNEL_ADC1));
        ao_adc_ready = 1;
 }
@@ -97,14 +104,22 @@ ao_adc_poll(void)
 void
 ao_adc_get(__xdata struct ao_adc *packet)
 {
+#if HAS_FLIGHT
+       uint8_t i = ao_data_ring_prev(ao_sample_data);
+#else
        uint8_t i = ao_data_ring_prev(ao_data_head);
+#endif
        memcpy(packet, (void *) &ao_data_ring[i].adc, sizeof (struct ao_adc));
 }
 
 void
 ao_data_get(__xdata struct ao_data *packet)
 {
+#if HAS_FLIGHT
+       uint8_t i = ao_data_ring_prev(ao_sample_data);
+#else
        uint8_t i = ao_data_ring_prev(ao_data_head);
+#endif
        memcpy(packet, (void *) &ao_data_ring[i], sizeof (struct ao_data));
 }