#if HAS_ADC
struct ao_adc adc;
#endif
-#if HAS_ACCEL_REF
- uint16_t accel_ref;
-#endif
#if HAS_MS5607
struct ao_ms5607_sample ms5607;
#endif
* ao_data_accel_invert - flip rocket ends for positive acceleration
*/
-#if HAS_MPU6000
+#if HAS_MPU6000 && !HAS_HIGHG_ACCEL
typedef int16_t accel_t;
*/
#if HAS_ACCEL_REF
#define ao_data_accel_sample(packet) \
- ((uint16_t) ((((uint32_t) (packet)->adc.accel << 16) / ((packet)->accel_ref << 1))) >> 1)
+ ((uint16_t) ((((uint32_t) (packet)->adc.accel << 16) / ((packet)->adc.accel_ref << 1))) >> 1)
#else
#define ao_data_accel_sample(packet) ((packet)->adc.accel)
#endif /* HAS_ACCEL_REF */
#define HAS_FLIGHT 1
#define HAS_ADC 1
#define HAS_ACCEL 1
+#define HAS_ACCEL_REF 1
#define HAS_LOG 1
#define AO_DATA_RING 32
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_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_GPIOBEN) | \
+ (1 << STM_RCC_AHBENR_GPIOCEN))
-#define AO_NUM_ADC_PIN (AO_ADC_NUM_SENSE + 2)
+#define AO_NUM_ADC_PIN (AO_ADC_NUM_SENSE + 4)
#define AO_ADC_PIN0_PORT AO_ADC_SENSE_A_PORT
#define AO_ADC_PIN0_PIN AO_ADC_SENSE_A_PIN
#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 + 3)
+#define AO_NUM_ADC (AO_ADC_NUM_SENSE + 5)
#define AO_ADC_SQ1 AO_ADC_SENSE_A
#define AO_ADC_SQ2 AO_ADC_SENSE_B
#define AO_ADC_SQ6 AO_ADC_SENSE_F
#define AO_ADC_SQ7 AO_ADC_V_BATT
#define AO_ADC_SQ8 AO_ADC_V_PBATT
-#define AO_ADC_SQ9 AO_ADC_TEMP
+#define AO_ADC_SQ9 AO_ADC_ACCEL_REF
+#define AO_ADC_SQ10 AO_ADC_ACCEL
+#define AO_ADC_SQ11 AO_ADC_TEMP
/*
* Pressure sensor settings
#define AO_MPU6000_INT_PIN 13
#define AO_MPU6000_I2C_INDEX STM_I2C_INDEX(1)
+#define HAS_HIGHG_ACCEL 1
+
#endif /* _AO_PINS_H_ */
stm_adc.sr = 0;
ao_dma_set_transfer(STM_DMA_INDEX(STM_DMA_CHANNEL_ADC1),
&stm_adc.dr,
- (void *) (&ao_data_ring[ao_data_head].tick + 1),
+ (void *) (&ao_data_ring[ao_data_head].adc),
AO_NUM_ADC,
(0 << STM_DMA_CCR_MEM2MEM) |
(STM_DMA_CCR_PL_HIGH << STM_DMA_CCR_PL) |
#ifdef AO_ADC_PIN9_PORT
stm_moder_set(&AO_ADC_PIN9_PORT, AO_ADC_PIN9_PIN, STM_MODER_ANALOG);
#endif
+#ifdef AO_ADC_PIN10_PORT
+ stm_moder_set(&AO_ADC_PIN10_PORT, AO_ADC_PIN10_PIN, STM_MODER_ANALOG);
+#endif
+#ifdef AO_ADC_PIN11_PORT
+ stm_moder_set(&AO_ADC_PIN11_PORT, AO_ADC_PIN11_PIN, STM_MODER_ANALOG);
+#endif
+#ifdef AO_ADC_PIN12_PORT
+ stm_moder_set(&AO_ADC_PIN12_PORT, AO_ADC_PIN12_PIN, STM_MODER_ANALOG);
+#endif
stm_rcc.apb2enr |= (1 << STM_RCC_APB2ENR_ADC1EN);
#if AO_NUM_ADC > 8
stm_adc.sqr4 |= (AO_ADC_SQ9 << 10);
#endif
-
+#if AO_NUM_ADC > 9
+ stm_adc.sqr4 |= (AO_ADC_SQ10 << 15);
+#endif
+#if AO_NUM_ADC > 10
+ stm_adc.sqr4 |= (AO_ADC_SQ11 << 20);
+#endif
+#if AO_NUM_ADC > 11
+ stm_adc.sqr4 |= (AO_ADC_SQ12 << 25);
+#endif
+#if AO_NUM_ADC > 12
+#error "need to finish stm_adc.sqr settings"
+#endif
+
/* Turn ADC on */
stm_adc.cr2 = AO_ADC_CR2_VAL;