src-avr: Log ADC data to eeprom
[fw/altos] / src-avr / ao.h
index ed27a156e171f577331343818b61abc5e65123b6..6d025c99d78acd6ba70bb265b41041e95e747030 100644 (file)
 struct ao_task {
        __xdata void *wchan;            /* current wait channel (NULL if running) */
        uint16_t alarm;                 /* abort ao_sleep time */
+#ifdef AVR
+       uint8_t *sp;                    /* saved stack pointer */
+#else
        uint8_t stack_count;            /* amount of saved stack */
+#endif
        uint8_t task_id;                /* unique id */
        __code char *name;              /* task name */
        uint8_t stack[AO_STACK_SIZE];   /* saved stack */
@@ -61,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
  */
@@ -161,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
@@ -185,7 +201,8 @@ struct ao_adc {
  * ao_adc.c
  */
 
-#define AO_ADC_RING    32
+#define AO_ADC_RING    16
+
 #define ao_adc_ring_next(n)    (((n) + 1) & (AO_ADC_RING - 1))
 #define ao_adc_ring_prev(n)    (((n) - 1) & (AO_ADC_RING - 1))
 
@@ -326,8 +343,12 @@ extern __code __at (0x00a0) struct ao_romconfig ao_romconfig;
 #endif
 
 #if HAS_USB
+#ifdef AVR
+extern const uint8_t ao_usb_descriptors [];
+#else
 extern __code __at (0x00aa) uint8_t ao_usb_descriptors [];
 #endif
+#endif
 
 /*
  * ao_usb.c