diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/cc1111/ao_adc.c | 2 | ||||
| -rw-r--r-- | src/cc1111/ao_arch.h | 1 | ||||
| -rw-r--r-- | src/core/ao_data.h | 7 | ||||
| -rw-r--r-- | src/megametrum-v0.1/ao_pins.h | 28 | ||||
| -rw-r--r-- | src/stm/ao_adc_stm.c | 25 | 
5 files changed, 51 insertions, 12 deletions
| diff --git a/src/cc1111/ao_adc.c b/src/cc1111/ao_adc.c index 95643956..ce827e25 100644 --- a/src/cc1111/ao_adc.c +++ b/src/cc1111/ao_adc.c @@ -56,7 +56,7 @@ ao_adc_isr(void) __interrupt 1  	/* TeleMetrum readings */  #if HAS_ACCEL_REF  	if (sequence == 2) { -		a = (uint8_t __xdata *) (&ao_data_ring[ao_data_head].accel_ref); +		a = (uint8_t __xdata *) (&ao_data_ring[ao_data_head].adc.accel_ref);  		sequence = 0;  	} else  #endif diff --git a/src/cc1111/ao_arch.h b/src/cc1111/ao_arch.h index 704ae4f9..44116b81 100644 --- a/src/cc1111/ao_arch.h +++ b/src/cc1111/ao_arch.h @@ -205,6 +205,7 @@ struct ao_adc {  	int16_t		v_batt;		/* battery voltage */  	int16_t		sense_d;	/* drogue continuity sense */  	int16_t		sense_m;	/* main continuity sense */ +	int16_t		accel_ref;	/* acceleration reference */  };  #define AO_DATA_RING	32 diff --git a/src/core/ao_data.h b/src/core/ao_data.h index bb26c4c0..83f8df59 100644 --- a/src/core/ao_data.h +++ b/src/core/ao_data.h @@ -31,9 +31,6 @@ struct ao_data {  #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 @@ -82,7 +79,7 @@ typedef int16_t alt_t;   * ao_data_accel_invert	- flip rocket ends for positive acceleration   */ -#if HAS_MPU6000 +#if HAS_MPU6000 && !HAS_HIGHG_ACCEL  typedef int16_t accel_t; @@ -181,7 +178,7 @@ 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 */ diff --git a/src/megametrum-v0.1/ao_pins.h b/src/megametrum-v0.1/ao_pins.h index ff0edaa9..75b22045 100644 --- a/src/megametrum-v0.1/ao_pins.h +++ b/src/megametrum-v0.1/ao_pins.h @@ -98,6 +98,7 @@  #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 @@ -107,6 +108,8 @@ 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;  }; @@ -142,13 +145,22 @@ 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_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 @@ -166,8 +178,12 @@ struct ao_adc {  #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 @@ -177,7 +193,9 @@ struct ao_adc {  #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 @@ -230,4 +248,6 @@ struct ao_adc {  #define AO_MPU6000_INT_PIN	13  #define AO_MPU6000_I2C_INDEX	STM_I2C_INDEX(1) +#define HAS_HIGHG_ACCEL		1 +  #endif /* _AO_PINS_H_ */ diff --git a/src/stm/ao_adc_stm.c b/src/stm/ao_adc_stm.c index ea9e25e4..24a1fdd0 100644 --- a/src/stm/ao_adc_stm.c +++ b/src/stm/ao_adc_stm.c @@ -82,7 +82,7 @@ ao_adc_poll(void)  	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) | @@ -180,6 +180,15 @@ ao_adc_init(void)  #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); @@ -240,7 +249,19 @@ ao_adc_init(void)  #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; | 
