altos-avr: Completely replace the spi slave code
[fw/altos] / src-avr / ao.h
index ecb334641b777a0409d6924077ec0d1fb87d2374..fb3612d41a4a6a226b9ae85033236716ab8fed06 100644 (file)
@@ -201,7 +201,7 @@ struct ao_adc {
  * ao_adc.c
  */
 
-#define AO_ADC_RING    16
+#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))
@@ -1343,6 +1343,7 @@ struct ao_fifo {
        (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)
 
@@ -1421,4 +1422,36 @@ ao_btm_init(void);
 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
+
+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_ */