telescience: steal last adc channel for icp3 most recent value
authorRobert Garbee <robert@gag.com>
Thu, 19 Jul 2012 17:40:20 +0000 (11:40 -0600)
committerRobert Garbee <robert@gag.com>
Thu, 19 Jul 2012 17:40:20 +0000 (11:40 -0600)
src/avr/ao_adc_avr.c
src/avr/ao_pwmin.h

index 3a262977512b606552211cee8b6122fcdea3a8e7..4896b01579cec10168a73347acfc2e3ae19e2905 100644 (file)
@@ -16,6 +16,7 @@
  */
 
 #include "ao.h"
+#include "ao_pwmin.h"
 
 volatile __xdata struct ao_data        ao_data_ring[AO_DATA_RING];
 volatile __data uint8_t                ao_data_head;
@@ -93,9 +94,11 @@ ISR(ADC_vect)
        value = ADCL;
        value |= (ADCH << 8);
        ao_data_ring[ao_data_head].adc.adc[ao_adc_channel] = value;
-       if (++ao_adc_channel < NUM_ADC)
+       if (++ao_adc_channel < NUM_ADC - 1)
                ao_adc_start();
        else {
+               /* steal last adc channel for pwm input */
+               ao_data_ring[ao_data_head].adc.adc[ao_adc_channel] = ao_icp3_count;
                ADCSRA = ADCSRA_INIT;
                ao_data_ring[ao_data_head].tick = ao_time();
                ao_data_head = ao_data_ring_next(ao_data_head);
index bbab4ddc1c44fa042ea26c1bd6c609d81e45d51b..14741201af4e60244b94b1211bc3fb118b0f012b 100644 (file)
@@ -16,3 +16,4 @@
  */
 
 void ao_pwmin_init(void);
+extern volatile __data uint16_t ao_icp3_count;