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 */
#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
*/
/*
* 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
* ao_adc.c
*/
-#define AO_ADC_RING 32
+#define AO_ADC_RING 8
+
#define ao_adc_ring_next(n) (((n) + 1) & (AO_ADC_RING - 1))
#define ao_adc_ring_prev(n) (((n) - 1) & (AO_ADC_RING - 1))
void
ao_led_init(uint8_t enable);
+/*
+ * ao_lcd.c
+ */
+
+void
+ao_lcd_init(void);
+
/*
* ao_romconfig.c
*/
extern __xdata uint8_t ao_log_running;
extern __xdata enum flight_state ao_log_state;
+#define AO_LOG_TELESCIENCE_START ((uint8_t) 's')
+#define AO_LOG_TELESCIENCE_DATA ((uint8_t) 'd')
+
+struct ao_log_telescience {
+ uint8_t type;
+ uint8_t csum;
+ uint16_t tick;
+ uint16_t tm_tick;
+ uint8_t tm_state;
+ uint8_t unused;
+ uint16_t adc[NUM_ADC];
+};
+
+extern struct ao_log_telescience ao_log_store;
+
/* required functions from the underlying log system */
+#define AO_LOG_FORMAT_UNKNOWN 0 /* unknown; altosui will have to guess */
+#define AO_LOG_FORMAT_FULL 1 /* 8 byte typed log records */
+#define AO_LOG_FORMAT_TINY 2 /* two byte state/baro records */
+#define AO_LOG_FORMAT_TELEMETRY 3 /* 32 byte ao_telemetry records */
+#define AO_LOG_FORMAT_TELESCIENCE 4 /* 32 byte typed telescience records */
+#define AO_LOG_FORMAT_NONE 127 /* No log at all */
+
+extern __code uint8_t ao_log_format;
+
/* Return the flight number from the given log slot, 0 if none */
uint16_t
ao_log_flight(uint8_t slot);
+/* Flash has been erased, go find the start of storage */
+void
+ao_log_restart(void);
+
/* Flush the log */
void
ao_log_flush(void);
(f).remove = ((f).remove + 1) & (AO_FIFO_SIZE-1); \
} while(0)
+#define ao_fifo_reset(f) ((f).insert = (f).remove = 0)
#define ao_fifo_full(f) ((((f).insert + 1) & (AO_FIFO_SIZE-1)) == (f).remove)
#define ao_fifo_empty(f) ((f).insert == (f).remove)
void
ao_debug_init(void);
+/* ao_spi_slave.c */
+
+int
+ao_spi_slave_read(uint8_t *data, int len);
+
+int
+ao_spi_slave_write(uint8_t *data, int len);
+
+void
+ao_spi_slave_debug(void);
+
+void
+ao_spi_slave_init(void);
+
+/* ao_companion.c */
+
+#define AO_COMPANION_SETUP 1
+#define AO_COMPANION_FETCH 2
+#define AO_COMPANION_STATE 3
+
+struct ao_companion_command {
+ uint8_t command;
+ uint8_t flight_state;
+ uint16_t tick;
+};
+
+struct ao_companion_setup {
+ uint16_t board_id;
+ uint16_t board_id_inverse;
+ uint8_t update_period;
+ uint8_t channels;
+};
+
#endif /* _AO_H_ */