altos: Add Mosaic GPS support to TeleMega v3+
[fw/altos] / src / telemega-v6.0 / ao_pins.h
index 5bc224fe950ac97dde27ef82c8407537ea4e0d11..fc4fa12aa645cc58a56c4eb4c48e84aab7f556fa 100644 (file)
 #define AO_APB2_PRESCALER      2
 #define AO_RCC_CFGR_PPRE2_DIV  STM_RCC_CFGR_PPRE2_DIV_2
 
+#define HAS_GPS_MOSAIC         1
+
+#if HAS_GPS_MOSAIC
+
+/* Companion cs_companion0(pin 6) = TX cs_companion1 (pin 5) = RX */
+
+#define HAS_SERIAL_1           1
+#define USE_SERIAL_1_STDIN     0
+#define SERIAL_1_PB6_PB7       1
+#define SERIAL_1_PA9_PA10      0
+
+#define ao_mosaic_getchar      ao_serial1_getchar
+#define ao_mosaic_putchar      ao_serial1_putchar
+#define ao_mosaic_set_speed    ao_serial1_set_speed
+#define ao_mosaic_fifo         (ao_stm_usart1.rx_fifo)
+
+#else
 #define HAS_SERIAL_1           0
 #define USE_SERIAL_1_STDIN     0
 #define SERIAL_1_PB6_PB7       0
 #define SERIAL_1_PA9_PA10      0
+#endif
 
 #define HAS_SERIAL_2           1
 #define USE_SERIAL_2_STDIN     0
@@ -265,6 +283,12 @@ struct ao_adc {
 #define AO_BATTERY_DIV_PLUS    56      /* 5.6k */
 #define AO_BATTERY_DIV_MINUS   100     /* 10k */
 
+/*
+ * Voltage divider on ADC pyro battery sampler
+ */
+#define AO_PYRO_BATTERY_DIV_PLUS       100     /* 100k */
+#define AO_PYRO_BATTERY_DIV_MINUS      27      /* 27k */
+
 /*
  * Voltage divider on ADC igniter samplers
  */
@@ -327,21 +351,28 @@ struct ao_adc {
 
 /*
  *
- * If the board is laying component side up with
- * the antenna (nose) pointing north
+ * Here are the required sensor signs:
+ *
+ * +along      nose up
+ * +across     USB down
+ * +through    TH down
  *
- * +along      north   +roll   left up
- * +across     west    +pitch  nose down
- * +through    up      +yaw    left turn
+ * With the board aligned to have positive accel for the relevant
+ * axis, looking down from above we have:
+ *
+ * +roll       counter clockwise (nose up)
+ * +pitch      counter clockwise (USB down)
+ * +yaw                counter clockwise (TH down)
  */
 
 /*
- * bmi088
- *
- *     pin 1 NE corner of chip
+ * On TMega v6, bmi088 pin 1 (NE corner of chip) is placed towards the
+ * USB and antenna edges of the board. Relative to bmi088 specs, to
+ * get the above values, we need to flip the Y axis, assigning values
+ * as follows:
  *
- *     +along          +Y      +roll   +Y
- *     +across         -X      +pitch  -X
+ *     +along          +X      +roll   +X
+ *     +across         -Y      +pitch  -Y
  *     +through        +Z      +yaw    +Z
  */
 
@@ -353,12 +384,12 @@ struct ao_adc {
 #define AO_BMI088_GYR_CS_PIN   13
 #define HAS_IMU                        1
 
-#define ao_bmi088_along(m)     ((m)->acc.y)
-#define ao_bmi088_across(m)    (-(m)->acc.x)
+#define ao_bmi088_along(m)     ((m)->acc.x)
+#define ao_bmi088_across(m)    (-(m)->acc.y)
 #define ao_bmi088_through(m)   ((m)->acc.z)
 
-#define ao_bmi088_roll(m)      ((m)->gyr.y)
-#define ao_bmi088_pitch(m)     (-(m)->gyr.x)
+#define ao_bmi088_roll(m)      ((m)->gyr.x)
+#define ao_bmi088_pitch(m)     (-(m)->gyr.y)
 #define ao_bmi088_yaw(m)       ((m)->gyr.z)
 
 #define ao_data_along(packet)  ao_bmi088_along(&(packet)->bmi088)