*/
#include "ao.h"
+#include "ao_pins.h"
volatile __xdata struct ao_adc ao_adc_ring[AO_ADC_RING];
volatile __data uint8_t ao_adc_head;
ADCCON3 = ADCCON3_EREF_VDD | ADCCON3_EDIV_512 | 0;
}
-void
-ao_adc_sleep(void)
-{
- ao_sleep(&ao_adc_ring);
-}
-
void
ao_adc_get(__xdata struct ao_adc *packet)
{
- uint8_t i = ao_adc_ring_prev(ao_adc_head);
+ uint8_t i = ao_adc_ring_prev(ao_flight_adc);
memcpy(packet, &ao_adc_ring[i], sizeof (struct ao_adc));
}
void
-ao_adc_isr(void) interrupt 1
+ao_adc_isr(void) __interrupt 1
{
uint8_t sequence;
uint8_t __xdata *a;
a[0] = ADCL;
a[1] = ADCH;
if (sequence < 5) {
+#if HAS_EXTERNAL_TEMP == 0
/* start next channel conversion */
/* v0.2 replaces external temp sensor with internal one */
if (sequence == 1)
ADCCON3 = ADCCON3_EREF_1_25 | ADCCON3_EDIV_512 | ADCCON3_ECH_TEMP;
else
+#endif
ADCCON3 = ADCCON3_EREF_VDD | ADCCON3_EDIV_512 | (sequence + 1);
} else {
/* record this conversion series */
ao_adc_ring[ao_adc_head].tick = ao_time();
ao_adc_head = ao_adc_ring_next(ao_adc_head);
- ao_wakeup(ao_adc_ring);
+ ao_wakeup(DATA_TO_XDATA(&ao_adc_head));
}
}
{
ADCCFG = ((1 << 0) | /* acceleration */
(1 << 1) | /* pressure */
-/* (1 << 2) | v0.1 temperature */
+#if HAS_EXTERNAL_TEMP
+ (1 << 2) | /* v0.1 temperature */
+#endif
(1 << 3) | /* battery voltage */
(1 << 4) | /* drogue sense */
(1 << 5)); /* main sense */