altos: Make TeleMega v0.1 work more like TeleMega v1.0
authorKeith Packard <keithp@keithp.com>
Wed, 18 Dec 2013 09:12:11 +0000 (01:12 -0800)
committerKeith Packard <keithp@keithp.com>
Wed, 18 Dec 2013 09:12:11 +0000 (01:12 -0800)
I've still got one working v0.1 board which is useful for testing
stuff, so make it work more like the released TeleMega:

 * Use E for drogue, F for main
 * Use on-chip eeprom for config
 * Fix ADC report printf to match

Signed-off-by: Keith Packard <keithp@keithp.com>
src/telemega-v0.1/Makefile
src/telemega-v0.1/ao_pins.h
src/telemega-v0.1/ao_telemega.c

index 26afa38d0a65ce6972791539b4b61e3fb871ddb5..0145f49c5f45ad063a6f45da19a0614fb93e3554 100644 (file)
@@ -90,6 +90,7 @@ ALTOS_SRC = \
        ao_hmc5883.c \
        ao_adc_stm.c \
        ao_beep_stm.c \
+       ao_eeprom_stm.c \
        ao_storage.c \
        ao_m25.c \
        ao_usb_stm.c \
@@ -109,9 +110,9 @@ ALTOS_SRC = \
        ao_companion.c \
        ao_pyro.c \
        ao_aprs.c \
+       $(MATH_SRC) \
        $(PROFILE) \
        $(SAMPLE_PROFILE) \
-       $(MATH_SRC) \
        $(STACK_GUARD)
 
 PRODUCT=TeleMega-v0.1
index 11934bd2ccd6371198e7dc70b8c10283a48ab8d2..7ba3a1a778c6daf74be40f228a4607ec2bdbb774 100644 (file)
 #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       (1024 * 1024)
 #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_RADIO              1
 #define HAS_GPS                        1
 #define HAS_FLIGHT             1
 #define HAS_ADC                        1
+#define HAS_ADC_TEMP           1
 #define HAS_LOG                        1
 
 /*
 #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_PYRO(p,n)     ((p)->adc.sense[n])
+#define AO_SENSE_DROGUE(p)     ((p)->adc.sense[4])
+#define AO_SENSE_MAIN(p)       ((p)->adc.sense[5])
 #define AO_IGNITER_CLOSED      400
 #define AO_IGNITER_OPEN                60
 
-#define AO_IGNITER_DROGUE_PORT (&stm_gpiod)
-#define AO_IGNITER_DROGUE_PIN  6
+/* Pyro A */
+#define AO_PYRO_PORT_0 (&stm_gpiod)
+#define AO_PYRO_PIN_0  6
 
-#define AO_IGNITER_MAIN_PORT   (&stm_gpiod)
-#define AO_IGNITER_MAIN_PIN    7
+/* Pyro B */
+#define AO_PYRO_PORT_1 (&stm_gpiod)
+#define AO_PYRO_PIN_1  7
 
-#define AO_PYRO_PORT_0 (&stm_gpiob)
-#define AO_PYRO_PIN_0  5
+/* Pyro C */
+#define AO_PYRO_PORT_2 (&stm_gpiob)
+#define AO_PYRO_PIN_2  5
 
-#define AO_PYRO_PORT_1 (&stm_gpioe)
-#define AO_PYRO_PIN_1  4
+/* Pyro D */
+#define AO_PYRO_PORT_3 (&stm_gpioe)
+#define AO_PYRO_PIN_3  4
 
-#define AO_PYRO_PORT_2 (&stm_gpioe)
-#define AO_PYRO_PIN_2  6
+/* Drogue */
+#define AO_IGNITER_DROGUE_PORT (&stm_gpioe)
+#define AO_IGNITER_DROGUE_PIN  6
 
-#define AO_PYRO_PORT_3 (&stm_gpioe)
-#define AO_PYRO_PIN_3  5
+/* Main */
+#define AO_IGNITER_MAIN_PORT   (&stm_gpioe)
+#define AO_IGNITER_MAIN_PIN    5
 
 /* Number of general purpose pyro channels available */
 #define AO_PYRO_NUM    4
 
-#define AO_SENSE_PYRO(a,p)     ((a)->adc.sense[(p) + 2])
-
 #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)
 
@@ -161,11 +170,16 @@ struct ao_adc {
        int16_t                 sense[AO_ADC_NUM_SENSE];
        int16_t                 v_batt;
        int16_t                 v_pbatt;
-       int16_t                 accel_ref;
-       int16_t                 accel;
        int16_t                 temp;
 };
 
+#define AO_ADC_DUMP(p) \
+       printf("tick: %5u A: %5d B: %5d C: %5d D: %5d drogue: %5d main: %5d batt: %5d pbatt: %5d temp: %5d\n", \
+              (p)->tick, \
+              (p)->adc.sense[0], (p)->adc.sense[1], (p)->adc.sense[2], \
+              (p)->adc.sense[3], (p)->adc.sense[4], (p)->adc.sense[5], \
+              (p)->adc.v_batt, (p)->adc.v_pbatt, (p)->adc.temp)
+
 #define AO_ADC_SENSE_A         0
 #define AO_ADC_SENSE_A_PORT    (&stm_gpioa)
 #define AO_ADC_SENSE_A_PIN     0
@@ -182,13 +196,13 @@ struct ao_adc {
 #define AO_ADC_SENSE_D_PORT    (&stm_gpioa)
 #define AO_ADC_SENSE_D_PIN     3
 
-#define AO_ADC_SENSE_E         4
-#define AO_ADC_SENSE_E_PORT    (&stm_gpioa)
-#define AO_ADC_SENSE_E_PIN     4
+#define AO_ADC_SENSE_DROGUE    4
+#define AO_ADC_SENSE_DROGUE_PORT       (&stm_gpioa)
+#define AO_ADC_SENSE_DROGUE_PIN        4
 
-#define AO_ADC_SENSE_F         22
-#define AO_ADC_SENSE_F_PORT    (&stm_gpioe)
-#define AO_ADC_SENSE_F_PIN     7
+#define AO_ADC_SENSE_MAIN      22
+#define AO_ADC_SENSE_MAIN_PORT (&stm_gpioe)
+#define AO_ADC_SENSE_MAIN_PIN  7
 
 #define AO_ADC_V_BATT          8
 #define AO_ADC_V_BATT_PORT     (&stm_gpiob)
@@ -198,22 +212,13 @@ struct ao_adc {
 #define AO_ADC_V_PBATT_PORT    (&stm_gpiob)
 #define AO_ADC_V_PBATT_PIN     1
 
-#define AO_ADC_ACCEL_REF       10
-#define AO_ADC_ACCEL_REF_PORT  (&stm_gpioc)
-#define AO_ADC_ACCEL_REF_PIN   0
-
-#define AO_ADC_ACCEL           11
-#define AO_ADC_ACCEL_PORT      (&stm_gpioc)
-#define AO_ADC_ACCEL_PIN       1
-
 #define AO_ADC_TEMP            16
 
 #define AO_ADC_RCC_AHBENR      ((1 << STM_RCC_AHBENR_GPIOAEN) | \
                                 (1 << STM_RCC_AHBENR_GPIOEEN) | \
-                                (1 << STM_RCC_AHBENR_GPIOBEN) | \
-                                (1 << STM_RCC_AHBENR_GPIOCEN))
+                                (1 << STM_RCC_AHBENR_GPIOBEN))
 
-#define AO_NUM_ADC_PIN         (AO_ADC_NUM_SENSE + 4)
+#define AO_NUM_ADC_PIN         (AO_ADC_NUM_SENSE + 2)
 
 #define AO_ADC_PIN0_PORT       AO_ADC_SENSE_A_PORT
 #define AO_ADC_PIN0_PIN                AO_ADC_SENSE_A_PIN
@@ -223,32 +228,26 @@ struct ao_adc {
 #define AO_ADC_PIN2_PIN                AO_ADC_SENSE_C_PIN
 #define AO_ADC_PIN3_PORT       AO_ADC_SENSE_D_PORT
 #define AO_ADC_PIN3_PIN                AO_ADC_SENSE_D_PIN
-#define AO_ADC_PIN4_PORT       AO_ADC_SENSE_E_PORT
-#define AO_ADC_PIN4_PIN                AO_ADC_SENSE_E_PIN
-#define AO_ADC_PIN5_PORT       AO_ADC_SENSE_F_PORT
-#define AO_ADC_PIN5_PIN                AO_ADC_SENSE_F_PIN
+#define AO_ADC_PIN4_PORT       AO_ADC_SENSE_DROGUE_PORT
+#define AO_ADC_PIN4_PIN                AO_ADC_SENSE_DROGUE_PIN
+#define AO_ADC_PIN5_PORT       AO_ADC_SENSE_MAIN_PORT
+#define AO_ADC_PIN5_PIN                AO_ADC_SENSE_MAIN_PIN
 #define AO_ADC_PIN6_PORT       AO_ADC_V_BATT_PORT
 #define AO_ADC_PIN6_PIN                AO_ADC_V_BATT_PIN
 #define AO_ADC_PIN7_PORT       AO_ADC_V_PBATT_PORT
 #define AO_ADC_PIN7_PIN                AO_ADC_V_PBATT_PIN
-#define AO_ADC_PIN8_PORT       AO_ADC_ACCEL_REF_PORT
-#define AO_ADC_PIN8_PIN                AO_ADC_ACCEL_REF_PIN
-#define AO_ADC_PIN9_PORT       AO_ADC_ACCEL_PORT
-#define AO_ADC_PIN9_PIN                AO_ADC_ACCEL_PIN
 
-#define AO_NUM_ADC             (AO_ADC_NUM_SENSE + 5)
+#define AO_NUM_ADC             (AO_ADC_NUM_SENSE + 3)
 
 #define AO_ADC_SQ1             AO_ADC_SENSE_A
 #define AO_ADC_SQ2             AO_ADC_SENSE_B
 #define AO_ADC_SQ3             AO_ADC_SENSE_C
 #define AO_ADC_SQ4             AO_ADC_SENSE_D
-#define AO_ADC_SQ5             AO_ADC_SENSE_E
-#define AO_ADC_SQ6             AO_ADC_SENSE_F
+#define AO_ADC_SQ5             AO_ADC_SENSE_DROGUE
+#define AO_ADC_SQ6             AO_ADC_SENSE_MAIN
 #define AO_ADC_SQ7             AO_ADC_V_BATT
 #define AO_ADC_SQ8             AO_ADC_V_PBATT
-#define AO_ADC_SQ9             AO_ADC_ACCEL_REF
-#define AO_ADC_SQ10            AO_ADC_ACCEL
-#define AO_ADC_SQ11            AO_ADC_TEMP
+#define AO_ADC_SQ9             AO_ADC_TEMP
 
 /*
  * Pressure sensor settings
@@ -298,7 +297,6 @@ struct ao_adc {
 #define AO_CC1120_MARC_GPIO    3
 #define AO_CC1120_MARC_GPIO_IOCFG      CC1120_IOCFG3
 
-
 #define HAS_BOOT_RADIO         0
 
 /*
index fbdab64a8766dbbc8a43d21a8e417da4d93691d1..7b035269bccd5d0d678a4a8ae23bb1682f77aa96 100644 (file)
@@ -24,6 +24,7 @@
 #include <ao_packet.h>
 #include <ao_companion.h>
 #include <ao_profile.h>
+#include <ao_eeprom.h>
 #if HAS_SAMPLE_PROFILE
 #include <ao_sample_profile.h>
 #endif
@@ -71,6 +72,7 @@ main(void)
        ao_mma655x_init();
 #endif
 
+       ao_eeprom_init();
        ao_storage_init();
        
        ao_flight_init();