altos/stm: Make beeper driver support all possible tim234 configs
[fw/altos] / src / telemetrum-v2.0 / ao_pins.h
index 36cfc7e00c5fe48605d376ac222b79553a90fce8..e8c97ff4270461a4c3a7299202b47663250828a0 100644 (file)
@@ -3,7 +3,8 @@
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; version 2 of the License.
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
  *
  * This program is distributed in the hope that it will be useful, but
  * WITHOUT ANY WARRANTY; without even the implied warranty of
 #define SERIAL_3_PC10_PC11     0
 #define SERIAL_3_PD8_PD9       0
 
-#define ao_gps_getchar         ao_serial3_getchar
-#define ao_gps_putchar         ao_serial3_putchar
-#define ao_gps_set_speed       ao_serial3_set_speed
-#define ao_gps_fifo            (ao_stm_usart3.rx_fifo)
+#define AO_CONFIG_DEFAULT_FLIGHT_LOG_MAX       (512 * 1024)
+#define AO_CONFIG_MAX_SIZE                     1024
+#define LOG_ERASE_MARK                         0x55
+#define LOG_MAX_ERASE                          128
+#define AO_LOG_FORMAT                          AO_LOG_FORMAT_TELEMETRUM
 
 #define HAS_EEPROM             1
 #define USE_INTERNAL_FLASH     0
+#define USE_EEPROM_CONFIG      1
+#define USE_STORAGE_CONFIG     0
 #define HAS_USB                        1
 #define HAS_BEEP               1
+#define HAS_BATTERY_REPORT     1
 #define BEEPER_CHANNEL         4
+#define BEEPER_TIMER           3
+#define BEEPER_PORT            (&stm_gpiob)
+#define BEEPER_PIN             1
 #define HAS_RADIO              1
 #define HAS_TELEMETRY          1
 #define HAS_APRS               1
+#define HAS_COMPANION          1
 
 #define HAS_SPI_1              1
 #define SPI_1_PA5_PA6_PA7      1       /* Barometer */
 #define HAS_IGNITE             1
 #define HAS_IGNITE_REPORT      1
 
-#define AO_SENSE_DROGUE(p)     ((p)->adc.sense[0])
-#define AO_SENSE_MAIN(p)       ((p)->adc.sense[1])
+#define AO_SENSE_DROGUE(p)     ((p)->adc.sense_a)
+#define AO_SENSE_MAIN(p)       ((p)->adc.sense_m)
 #define AO_IGNITER_CLOSED      400
 #define AO_IGNITER_OPEN                60
 
 #define AO_IGNITER_MAIN_PORT   (&stm_gpioa)
 #define AO_IGNITER_MAIN_PIN    9
 
-#define AO_IGNITER_SET_DROGUE(v)       stm_gpio_set(AO_IGNITER_DROGUE_PORT, AO_IGNITER_DROGUE_PIN, v)
-#define AO_IGNITER_SET_MAIN(v)         stm_gpio_set(AO_IGNITER_MAIN_PORT, AO_IGNITER_MAIN_PIN, v)
-
 /*
  * ADC
  */
 #define AO_ADC_NUM_SENSE       2
 
 struct ao_adc {
-       int16_t                 sense[AO_ADC_NUM_SENSE];
+       int16_t                 sense_a;
+       int16_t                 sense_m;
        int16_t                 v_batt;
        int16_t                 temp;
 };
 
 #define AO_ADC_DUMP(p) \
-       printf("tick: %5u drogue: %5d main: %5d batt: %5d pbatt: %5d temp: %5d\n", \
+       printf("tick: %5u drogue: %5d main: %5d batt: %5d\n", \
               (p)->tick, \
-              (p)->adc.sense[0], (p)->adc.sense[1], \
-              (p)->adc.v_batt, (p)->adc.temp)
+              (p)->adc.sense_a, (p)->adc.sense_m, \
+              (p)->adc.v_batt);
 
 #define AO_ADC_SENSE_DROGUE    0
 #define AO_ADC_SENSE_DROGUE_PORT       (&stm_gpioa)
@@ -190,6 +197,34 @@ struct ao_adc {
 #define AO_ADC_SQ3             AO_ADC_V_BATT
 #define AO_ADC_SQ4             AO_ADC_TEMP
 
+/*
+ * Voltage divider on ADC battery sampler
+ */
+#define AO_BATTERY_DIV_PLUS    56      /* 5.6k */
+#define AO_BATTERY_DIV_MINUS   100     /* 10k */
+
+/*
+ * Voltage divider on ADC igniter samplers
+ */
+#define AO_IGNITE_DIV_PLUS     100     /* 100k */
+#define AO_IGNITE_DIV_MINUS    27      /* 27k */
+
+/*
+ * ADC reference in decivolts
+ */
+#define AO_ADC_REFERENCE_DV    33
+
+/*
+ * GPS
+ */
+
+#define AO_SERIAL_SPEED_UBLOX  AO_SERIAL_SPEED_9600
+
+#define ao_gps_getchar         ao_serial3_getchar
+#define ao_gps_putchar         ao_serial3_putchar
+#define ao_gps_set_speed       ao_serial3_set_speed
+#define ao_gps_fifo            (ao_stm_usart3.rx_fifo)
+
 /*
  * Pressure sensor settings
  */
@@ -247,9 +282,10 @@ struct ao_adc {
  */
 
 #define HAS_MMA655X            1
-#define AO_MMA655X_SPI_INDEX   AO_SPI_1_PE13_PE14_PE15
-#define AO_MMA655X_CS_PORT     (&stm_gpiod)
-#define AO_MMA655X_CS_PIN      4
+#define AO_MMA655X_SPI_INDEX   AO_SPI_1_PB3_PB4_PB5
+#define AO_MMA655X_CS_PORT     (&stm_gpiob)
+#define AO_MMA655X_CS_PIN      9
+#define AO_MMA655X_INVERT      1
 
 #define NUM_CMDS               16