summaryrefslogtreecommitdiff
path: root/src-avr/ao.h
diff options
context:
space:
mode:
authorKeith Packard <keithp@keithp.com>2011-05-20 23:47:55 -0700
committerKeith Packard <keithp@keithp.com>2011-05-21 02:07:43 -0700
commit557522e447448023d7869c0fa15ed8337db7e1b8 (patch)
treec45649e979e4852fef7e65ac5bcc52c01157e688 /src-avr/ao.h
parentf7e552a0f4b1382a076b0f3ffc50ef068bfa141f (diff)
src-avr: Add ADC routines to telescience
Note that SLEEP mode must be disabled or extra ADC interrupts occur, which messes up saving ADC values to the right channel. Signed-off-by: Keith Packard <keithp@keithp.com>
Diffstat (limited to 'src-avr/ao.h')
-rw-r--r--src-avr/ao.h13
1 files changed, 13 insertions, 0 deletions
diff --git a/src-avr/ao.h b/src-avr/ao.h
index 90298a3e..0d278525 100644
--- a/src-avr/ao.h
+++ b/src-avr/ao.h
@@ -65,6 +65,10 @@ extern __xdata struct ao_task *__data ao_cur_task;
#define AO_NUM_TASKS 16 /* maximum number of tasks */
#define AO_NO_TASK 0 /* no task id */
+#ifdef AVR
+extern uint8_t ao_cpu_sleep_disable;
+#endif
+
/*
ao_task.c
*/
@@ -165,14 +169,22 @@ ao_clock_init(void);
/*
* One set of samples read from the A/D converter or telemetry
*/
+#ifdef AVR
+#define NUM_ADC 12
+#endif
+
struct ao_adc {
uint16_t tick; /* tick when the sample was read */
+#ifdef AVR
+ uint16_t adc[NUM_ADC]; /* samples */
+#else
int16_t accel; /* accelerometer */
int16_t pres; /* pressure sensor */
int16_t temp; /* temperature sensor */
int16_t v_batt; /* battery voltage */
int16_t sense_d; /* drogue continuity sense */
int16_t sense_m; /* main continuity sense */
+#endif
};
#if HAS_ADC
@@ -190,6 +202,7 @@ struct ao_adc {
*/
#define AO_ADC_RING 32
+
#define ao_adc_ring_next(n) (((n) + 1) & (AO_ADC_RING - 1))
#define ao_adc_ring_prev(n) (((n) - 1) & (AO_ADC_RING - 1))