From 6b8881a7bdb9f89306a700e9a8853b00df29bf5d Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Wed, 3 Oct 2012 07:50:48 -0700 Subject: altos/megametrum: Commit for boards with MS5611 baro sensor Signed-off-by: Keith Packard --- src/megametrum-v0.1/ao_pins.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/megametrum-v0.1/ao_pins.h b/src/megametrum-v0.1/ao_pins.h index af8eebae..f6b49dd0 100644 --- a/src/megametrum-v0.1/ao_pins.h +++ b/src/megametrum-v0.1/ao_pins.h @@ -18,6 +18,8 @@ #ifndef _AO_PINS_H_ #define _AO_PINS_H_ +#define HAS_MS5611 1 + /* 8MHz High speed external crystal */ #define AO_HSE 8000000 -- cgit v1.2.3 From c676ad8048d10ad9da22ea3acf19e4e1872103ff Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Sat, 6 Oct 2012 17:05:59 -0700 Subject: altos/megametrum: Use mma655x for acceleration measurements now Signed-off-by: Keith Packard --- src/megametrum-v0.1/ao_pins.h | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/megametrum-v0.1/ao_pins.h b/src/megametrum-v0.1/ao_pins.h index f6b49dd0..724878b5 100644 --- a/src/megametrum-v0.1/ao_pins.h +++ b/src/megametrum-v0.1/ao_pins.h @@ -107,8 +107,6 @@ #define HAS_GPS 1 #define HAS_FLIGHT 1 #define HAS_ADC 1 -#define HAS_ACCEL 1 -#define HAS_ACCEL_REF 1 #define HAS_LOG 1 /* -- cgit v1.2.3 From 0b28eefe6b32033a0e85731aa38af7e07a8b45f5 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Sat, 6 Oct 2012 17:21:10 -0700 Subject: altos/megametrum: Make MS5607 driver hold SPI bus for whole operation Signed-off-by: Keith Packard --- src/megametrum-v0.1/ao_pins.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/megametrum-v0.1/ao_pins.h b/src/megametrum-v0.1/ao_pins.h index 724878b5..eba72b4f 100644 --- a/src/megametrum-v0.1/ao_pins.h +++ b/src/megametrum-v0.1/ao_pins.h @@ -248,7 +248,7 @@ struct ao_adc { * Pressure sensor settings */ #define HAS_MS5607 1 -#define AO_MS5607_PRIVATE_PINS 1 +#define AO_MS5607_PRIVATE_PINS 0 #define AO_MS5607_CS_PORT (&stm_gpioc) #define AO_MS5607_CS_PIN 4 #define AO_MS5607_CS_MASK (1 << AO_MS5607_CS) -- cgit v1.2.3 From 41add569413bf3ec564195963277c81f2d2da798 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Sat, 6 Oct 2012 17:21:55 -0700 Subject: altos/drivers: Use data ring values for MS5607 presentation Signed-off-by: Keith Packard --- src/drivers/ao_ms5607.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/drivers/ao_ms5607.c b/src/drivers/ao_ms5607.c index 76931b4b..3295baac 100644 --- a/src/drivers/ao_ms5607.c +++ b/src/drivers/ao_ms5607.c @@ -239,14 +239,13 @@ ao_ms5607_info(void) static void ao_ms5607_dump(void) { - struct ao_ms5607_sample sample; + struct ao_data data; struct ao_ms5607_value value; - ao_ms5607_setup(); - ao_ms5607_sample(&sample); - ao_ms5607_convert(&sample, &value); - printf ("Pressure: %8u %8d\n", sample.pres, value.pres); - printf ("Temperature: %8u %8d\n", sample.temp, value.temp); + ao_data_get(&data); + ao_ms5607_convert(&data.ms5607_raw, &value); + printf ("Pressure: %8u %8d\n", data.ms5607_raw.pres, value.pres); + printf ("Temperature: %8u %8d\n", data.ms5607_raw.temp, value.temp); printf ("Altitude: %ld\n", ao_pa_to_altitude(value.pres)); } -- cgit v1.2.3 From 35cb2dc51708ab572a4c72422e5902a313eda58e Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Sat, 6 Oct 2012 17:56:23 -0700 Subject: altos/stm: Clean up SPI pin configuration code Make sure none of the pin configurations are being used at startup time. Split out the pin configuration into separate functions. Signed-off-by: Keith Packard --- src/stm/ao_spi_stm.c | 199 ++++++++++++++++++++++++++++----------------------- 1 file changed, 109 insertions(+), 90 deletions(-) diff --git a/src/stm/ao_spi_stm.c b/src/stm/ao_spi_stm.c index ade86a27..5b823e3e 100644 --- a/src/stm/ao_spi_stm.c +++ b/src/stm/ao_spi_stm.c @@ -24,7 +24,7 @@ struct ao_spi_stm_info { }; static uint8_t ao_spi_mutex[STM_NUM_SPI]; -static uint8_t ao_spi_config[STM_NUM_SPI]; +static uint8_t ao_spi_index[STM_NUM_SPI]; static const struct ao_spi_stm_info ao_spi_stm_info[STM_NUM_SPI] = { { @@ -267,97 +267,100 @@ ao_spi_duplex(void *out, void *in, uint16_t len, uint8_t spi_index) ao_dma_done_transfer(miso_dma_index); } -void -ao_spi_get(uint8_t spi_index, uint32_t speed) +static void +ao_spi_disable_index(uint8_t spi_index) { - struct stm_spi *stm_spi = ao_spi_stm_info[AO_SPI_INDEX(spi_index)].stm_spi; - uint8_t config = AO_SPI_CONFIG(spi_index); - - ao_mutex_get(&ao_spi_mutex[AO_SPI_INDEX(spi_index)]); - if (config != ao_spi_config[AO_SPI_INDEX(spi_index)]) { - - /* Disable current config - */ - switch (AO_SPI_INDEX(spi_index)) { - case STM_SPI_INDEX(1): - switch (ao_spi_config[AO_SPI_INDEX(spi_index)]) { - case AO_SPI_1_CONFIG_PA5_PA6_PA7: - stm_gpio_set(&stm_gpioa, 5, 0); - stm_moder_set(&stm_gpioa, 5, STM_MODER_OUTPUT); - stm_moder_set(&stm_gpioa, 6, STM_MODER_INPUT); - stm_moder_set(&stm_gpioa, 7, STM_MODER_OUTPUT); - break; - case AO_SPI_1_CONFIG_PB3_PB4_PB5: - stm_gpio_set(&stm_gpiob, 3, 0); - stm_moder_set(&stm_gpiob, 3, STM_MODER_OUTPUT); - stm_moder_set(&stm_gpiob, 4, STM_MODER_INPUT); - stm_moder_set(&stm_gpiob, 5, STM_MODER_OUTPUT); - break; - case AO_SPI_1_CONFIG_PE13_PE14_PE15: - stm_gpio_set(&stm_gpioe, 13, 0); - stm_moder_set(&stm_gpioe, 13, STM_MODER_OUTPUT); - stm_moder_set(&stm_gpioe, 14, STM_MODER_INPUT); - stm_moder_set(&stm_gpioe, 15, STM_MODER_OUTPUT); - break; - } + /* Disable current config + */ + switch (AO_SPI_INDEX(spi_index)) { + case STM_SPI_INDEX(1): + switch (spi_index) { + case AO_SPI_1_PA5_PA6_PA7: + stm_gpio_set(&stm_gpioa, 5, 0); + stm_moder_set(&stm_gpioa, 5, STM_MODER_OUTPUT); + stm_moder_set(&stm_gpioa, 6, STM_MODER_INPUT); + stm_moder_set(&stm_gpioa, 7, STM_MODER_OUTPUT); + break; + case AO_SPI_1_PB3_PB4_PB5: + stm_gpio_set(&stm_gpiob, 3, 0); + stm_moder_set(&stm_gpiob, 3, STM_MODER_OUTPUT); + stm_moder_set(&stm_gpiob, 4, STM_MODER_INPUT); + stm_moder_set(&stm_gpiob, 5, STM_MODER_OUTPUT); break; - case STM_SPI_INDEX(2): - switch (ao_spi_config[AO_SPI_INDEX(spi_index)]) { - case AO_SPI_2_CONFIG_PB13_PB14_PB15: - stm_gpio_set(&stm_gpiob, 13, 0); - stm_moder_set(&stm_gpiob, 13, STM_MODER_OUTPUT); - stm_moder_set(&stm_gpiob, 14, STM_MODER_INPUT); - stm_moder_set(&stm_gpiob, 15, STM_MODER_OUTPUT); - break; - case AO_SPI_2_CONFIG_PD1_PD3_PD4: - stm_gpio_set(&stm_gpiod, 1, 0); - stm_moder_set(&stm_gpiod, 1, STM_MODER_OUTPUT); - stm_moder_set(&stm_gpiod, 3, STM_MODER_INPUT); - stm_moder_set(&stm_gpiod, 4, STM_MODER_OUTPUT); - break; - } + case AO_SPI_1_PE13_PE14_PE15: + stm_gpio_set(&stm_gpioe, 13, 0); + stm_moder_set(&stm_gpioe, 13, STM_MODER_OUTPUT); + stm_moder_set(&stm_gpioe, 14, STM_MODER_INPUT); + stm_moder_set(&stm_gpioe, 15, STM_MODER_OUTPUT); break; } + break; + case STM_SPI_INDEX(2): + switch (spi_index) { + case AO_SPI_2_PB13_PB14_PB15: + stm_gpio_set(&stm_gpiob, 13, 0); + stm_moder_set(&stm_gpiob, 13, STM_MODER_OUTPUT); + stm_moder_set(&stm_gpiob, 14, STM_MODER_INPUT); + stm_moder_set(&stm_gpiob, 15, STM_MODER_OUTPUT); + break; + case AO_SPI_2_PD1_PD3_PD4: + stm_gpio_set(&stm_gpiod, 1, 0); + stm_moder_set(&stm_gpiod, 1, STM_MODER_OUTPUT); + stm_moder_set(&stm_gpiod, 3, STM_MODER_INPUT); + stm_moder_set(&stm_gpiod, 4, STM_MODER_OUTPUT); + break; + } + break; + } +} - /* Enable new config - */ - switch (AO_SPI_INDEX(spi_index)) { - case 0: - switch (AO_SPI_CONFIG(spi_index)) { - case AO_SPI_1_CONFIG_PA5_PA6_PA7: - stm_afr_set(&stm_gpioa, 5, STM_AFR_AF5); - stm_afr_set(&stm_gpioa, 6, STM_AFR_AF5); - stm_afr_set(&stm_gpioa, 7, STM_AFR_AF5); - break; - case AO_SPI_1_CONFIG_PB3_PB4_PB5: - stm_afr_set(&stm_gpiob, 3, STM_AFR_AF5); - stm_afr_set(&stm_gpiob, 4, STM_AFR_AF5); - stm_afr_set(&stm_gpiob, 5, STM_AFR_AF5); - break; - case AO_SPI_1_CONFIG_PE13_PE14_PE15: - stm_afr_set(&stm_gpioe, 13, STM_AFR_AF5); - stm_afr_set(&stm_gpioe, 14, STM_AFR_AF5); - stm_afr_set(&stm_gpioe, 15, STM_AFR_AF5); - break; - } +static void +ao_spi_enable_index(uint8_t spi_index) +{ + switch (AO_SPI_INDEX(spi_index)) { + case STM_SPI_INDEX(1): + switch (spi_index) { + case AO_SPI_1_PA5_PA6_PA7: + stm_afr_set(&stm_gpioa, 5, STM_AFR_AF5); + stm_afr_set(&stm_gpioa, 6, STM_AFR_AF5); + stm_afr_set(&stm_gpioa, 7, STM_AFR_AF5); + break; + case AO_SPI_1_PB3_PB4_PB5: + stm_afr_set(&stm_gpiob, 3, STM_AFR_AF5); + stm_afr_set(&stm_gpiob, 4, STM_AFR_AF5); + stm_afr_set(&stm_gpiob, 5, STM_AFR_AF5); + break; + case AO_SPI_1_PE13_PE14_PE15: + stm_afr_set(&stm_gpioe, 13, STM_AFR_AF5); + stm_afr_set(&stm_gpioe, 14, STM_AFR_AF5); + stm_afr_set(&stm_gpioe, 15, STM_AFR_AF5); break; - case 1: - switch (AO_SPI_CONFIG(spi_index)) { - case AO_SPI_2_CONFIG_PB13_PB14_PB15: - stm_afr_set(&stm_gpiob, 13, STM_AFR_AF5); - stm_afr_set(&stm_gpiob, 14, STM_AFR_AF5); - stm_afr_set(&stm_gpiob, 15, STM_AFR_AF5); - break; - case AO_SPI_2_CONFIG_PD1_PD3_PD4: - stm_afr_set(&stm_gpiod, 1, STM_AFR_AF5); - stm_afr_set(&stm_gpiod, 3, STM_AFR_AF5); - stm_afr_set(&stm_gpiod, 4, STM_AFR_AF5); - break; - } + } + break; + case STM_SPI_INDEX(2): + switch (spi_index) { + case AO_SPI_2_PB13_PB14_PB15: + stm_afr_set(&stm_gpiob, 13, STM_AFR_AF5); + stm_afr_set(&stm_gpiob, 14, STM_AFR_AF5); + stm_afr_set(&stm_gpiob, 15, STM_AFR_AF5); + break; + case AO_SPI_2_PD1_PD3_PD4: + stm_afr_set(&stm_gpiod, 1, STM_AFR_AF5); + stm_afr_set(&stm_gpiod, 3, STM_AFR_AF5); + stm_afr_set(&stm_gpiod, 4, STM_AFR_AF5); break; } - ao_spi_config[AO_SPI_INDEX(spi_index)] = AO_SPI_CONFIG(spi_index); + break; } +} + +void +ao_spi_get(uint8_t spi_index, uint32_t speed) +{ + uint8_t id = AO_SPI_INDEX(spi_index); + struct stm_spi *stm_spi = ao_spi_stm_info[id].stm_spi; + + ao_mutex_get(&ao_spi_mutex[id]); stm_spi->cr1 = ((0 << STM_SPI_CR1_BIDIMODE) | /* Three wire mode */ (0 << STM_SPI_CR1_BIDIOE) | (0 << STM_SPI_CR1_CRCEN) | /* CRC disabled */ @@ -372,21 +375,39 @@ ao_spi_get(uint8_t spi_index, uint32_t speed) (1 << STM_SPI_CR1_MSTR) | (0 << STM_SPI_CR1_CPOL) | /* Format 0 */ (0 << STM_SPI_CR1_CPHA)); + if (spi_index != ao_spi_index[id]) { + + /* Disable old config + */ + ao_spi_disable_index(ao_spi_index[id]); + + /* Enable new config + */ + ao_spi_enable_index(spi_index); + + /* Remember current config + */ + ao_spi_index[id] = spi_index; + } } void ao_spi_put(uint8_t spi_index) { - struct stm_spi *stm_spi = ao_spi_stm_info[AO_SPI_INDEX(spi_index)].stm_spi; + uint8_t id = AO_SPI_INDEX(spi_index); + struct stm_spi *stm_spi = ao_spi_stm_info[id].stm_spi; stm_spi->cr1 = 0; - ao_mutex_put(&ao_spi_mutex[AO_SPI_INDEX(spi_index)]); + ao_mutex_put(&ao_spi_mutex[id]); } static void ao_spi_channel_init(uint8_t spi_index) { - struct stm_spi *stm_spi = ao_spi_stm_info[AO_SPI_INDEX(spi_index)].stm_spi; + uint8_t id = AO_SPI_INDEX(spi_index); + struct stm_spi *stm_spi = ao_spi_stm_info[id].stm_spi; + + ao_spi_disable_index(spi_index); stm_spi->cr1 = 0; (void) stm_spi->sr; @@ -412,7 +433,7 @@ ao_spi_init(void) stm_rcc.ahbenr |= (1 << STM_RCC_AHBENR_GPIOEEN); # endif stm_rcc.apb2enr |= (1 << STM_RCC_APB2ENR_SPI1EN); - ao_spi_config[0] = AO_SPI_CONFIG_NONE; + ao_spi_index[0] = AO_SPI_CONFIG_NONE; ao_spi_channel_init(0); #endif @@ -423,10 +444,8 @@ ao_spi_init(void) # if SPI_2_PD1_PD3_PD4 stm_rcc.ahbenr |= (1 << STM_RCC_AHBENR_GPIODEN); # endif - stm_rcc.apb1enr |= (1 << STM_RCC_APB1ENR_SPI2EN); - ao_spi_config[1] = AO_SPI_CONFIG_NONE; - + ao_spi_index[1] = AO_SPI_CONFIG_NONE; ao_spi_channel_init(1); #endif } -- cgit v1.2.3 From 6d47dd1d9104745cf68bef23b066c5033ca30a84 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Sat, 6 Oct 2012 19:39:15 -0700 Subject: altos/stm: Set SPI clock high for disabled SPI busses This should avoid an accidental low->high transition when switching between multiple SPI busses. Signed-off-by: Keith Packard --- src/stm/ao_spi_stm.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/stm/ao_spi_stm.c b/src/stm/ao_spi_stm.c index 5b823e3e..599d7ee0 100644 --- a/src/stm/ao_spi_stm.c +++ b/src/stm/ao_spi_stm.c @@ -276,19 +276,19 @@ ao_spi_disable_index(uint8_t spi_index) case STM_SPI_INDEX(1): switch (spi_index) { case AO_SPI_1_PA5_PA6_PA7: - stm_gpio_set(&stm_gpioa, 5, 0); + stm_gpio_set(&stm_gpioa, 5, 1); stm_moder_set(&stm_gpioa, 5, STM_MODER_OUTPUT); stm_moder_set(&stm_gpioa, 6, STM_MODER_INPUT); stm_moder_set(&stm_gpioa, 7, STM_MODER_OUTPUT); break; case AO_SPI_1_PB3_PB4_PB5: - stm_gpio_set(&stm_gpiob, 3, 0); + stm_gpio_set(&stm_gpiob, 3, 1); stm_moder_set(&stm_gpiob, 3, STM_MODER_OUTPUT); stm_moder_set(&stm_gpiob, 4, STM_MODER_INPUT); stm_moder_set(&stm_gpiob, 5, STM_MODER_OUTPUT); break; case AO_SPI_1_PE13_PE14_PE15: - stm_gpio_set(&stm_gpioe, 13, 0); + stm_gpio_set(&stm_gpioe, 13, 1); stm_moder_set(&stm_gpioe, 13, STM_MODER_OUTPUT); stm_moder_set(&stm_gpioe, 14, STM_MODER_INPUT); stm_moder_set(&stm_gpioe, 15, STM_MODER_OUTPUT); @@ -298,13 +298,13 @@ ao_spi_disable_index(uint8_t spi_index) case STM_SPI_INDEX(2): switch (spi_index) { case AO_SPI_2_PB13_PB14_PB15: - stm_gpio_set(&stm_gpiob, 13, 0); + stm_gpio_set(&stm_gpiob, 13, 1); stm_moder_set(&stm_gpiob, 13, STM_MODER_OUTPUT); stm_moder_set(&stm_gpiob, 14, STM_MODER_INPUT); stm_moder_set(&stm_gpiob, 15, STM_MODER_OUTPUT); break; case AO_SPI_2_PD1_PD3_PD4: - stm_gpio_set(&stm_gpiod, 1, 0); + stm_gpio_set(&stm_gpiod, 1, 1); stm_moder_set(&stm_gpiod, 1, STM_MODER_OUTPUT); stm_moder_set(&stm_gpiod, 3, STM_MODER_INPUT); stm_moder_set(&stm_gpiod, 4, STM_MODER_OUTPUT); -- cgit v1.2.3 From 16bbe9d25856259d2694751c364b668638e4a971 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Sun, 7 Oct 2012 15:40:41 -0700 Subject: altos/megametrum: Try running accel and baro in parallel again Now that the baro sensor appears to be working, try running conversions in parallel to see if that makes the accel cal happy Signed-off-by: Keith Packard --- src/megametrum-v0.1/ao_pins.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/megametrum-v0.1/ao_pins.h b/src/megametrum-v0.1/ao_pins.h index eba72b4f..724878b5 100644 --- a/src/megametrum-v0.1/ao_pins.h +++ b/src/megametrum-v0.1/ao_pins.h @@ -248,7 +248,7 @@ struct ao_adc { * Pressure sensor settings */ #define HAS_MS5607 1 -#define AO_MS5607_PRIVATE_PINS 0 +#define AO_MS5607_PRIVATE_PINS 1 #define AO_MS5607_CS_PORT (&stm_gpioc) #define AO_MS5607_CS_PIN 4 #define AO_MS5607_CS_MASK (1 << AO_MS5607_CS) -- cgit v1.2.3 From 39c5738acdfdf0c87b64de6135fe107971cfa12b Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Mon, 8 Oct 2012 23:04:16 -0700 Subject: altos: Go back to recording sensor data in globals Instead of trying to get things into the ring from a variety of functions, go back to the simpler method of storing them in globals and having the ADC code just pluck out the most recent values. Signed-off-by: Keith Packard --- src/core/ao_data.h | 9 +-------- src/drivers/ao_hmc5883.c | 4 +++- src/drivers/ao_hmc5883.h | 2 ++ src/drivers/ao_mma655x.c | 4 +++- src/drivers/ao_mma655x.h | 1 + src/drivers/ao_mpu6000.c | 4 +++- src/drivers/ao_mpu6000.h | 2 ++ src/drivers/ao_ms5607.c | 4 +++- src/drivers/ao_ms5607.h | 2 ++ src/stm/ao_adc_stm.c | 17 +++++++++++++++++ 10 files changed, 37 insertions(+), 12 deletions(-) diff --git a/src/core/ao_data.h b/src/core/ao_data.h index 2b9ef5ac..30208dfb 100644 --- a/src/core/ao_data.h +++ b/src/core/ao_data.h @@ -85,14 +85,7 @@ extern volatile __data uint8_t ao_data_count; /* * Mark a section of data as ready, check for data complete */ -#define AO_DATA_PRESENT(bit) do { \ - if ((ao_data_present |= (bit)) == AO_DATA_ALL) { \ - ao_data_ring[ao_data_head].tick = ao_tick_count; \ - ao_data_head = ao_data_ring_next(ao_data_head); \ - ao_data_present = 0; \ - ao_wakeup((void *) &ao_data_head); \ - } \ - } while (0); +#define AO_DATA_PRESENT(bit) (ao_data_present |= (bit)) /* * Wait until it is time to write a sensor sample; this is diff --git a/src/drivers/ao_hmc5883.c b/src/drivers/ao_hmc5883.c index ade6c263..059fc2c8 100644 --- a/src/drivers/ao_hmc5883.c +++ b/src/drivers/ao_hmc5883.c @@ -123,12 +123,14 @@ ao_hmc5883_setup(void) return 1; } +struct ao_hmc5883_sample ao_hmc5883_current; + static void ao_hmc5883(void) { ao_hmc5883_setup(); for (;;) { - ao_hmc5883_sample((struct ao_hmc5883_sample *) &ao_data_ring[ao_data_head].hmc5883); + ao_hmc5883_sample(&ao_hmc5883_current); ao_arch_critical( AO_DATA_PRESENT(AO_DATA_HMC5883); AO_DATA_WAIT(); diff --git a/src/drivers/ao_hmc5883.h b/src/drivers/ao_hmc5883.h index 55690978..ff2725eb 100644 --- a/src/drivers/ao_hmc5883.h +++ b/src/drivers/ao_hmc5883.h @@ -79,6 +79,8 @@ struct ao_hmc5883_sample { int16_t x, y, z; }; +extern struct ao_hmc5883_sample ao_hmc5883_current; + void ao_hmc5883_init(void); diff --git a/src/drivers/ao_mma655x.c b/src/drivers/ao_mma655x.c index 005bc684..18c5317c 100644 --- a/src/drivers/ao_mma655x.c +++ b/src/drivers/ao_mma655x.c @@ -250,12 +250,14 @@ __code struct ao_cmds ao_mma655x_cmds[] = { { 0, NULL }, }; +uint16_t ao_mma655x_current; + static void ao_mma655x(void) { ao_mma655x_setup(); for (;;) { - ao_data_ring[ao_data_head].mma655x = ao_mma655x_value(); + ao_mma655x_current = ao_mma655x_value(); ao_arch_critical( AO_DATA_PRESENT(AO_DATA_MMA655X); AO_DATA_WAIT(); diff --git a/src/drivers/ao_mma655x.h b/src/drivers/ao_mma655x.h index 9c0c59dc..2d951e07 100644 --- a/src/drivers/ao_mma655x.h +++ b/src/drivers/ao_mma655x.h @@ -78,6 +78,7 @@ #define AO_MMA655X_COUNT 0x15 #define AO_MMA655X_OFFCORR 0x16 +extern uint16_t ao_mma655x_current; void ao_mma655x_init(void); diff --git a/src/drivers/ao_mpu6000.c b/src/drivers/ao_mpu6000.c index b3e284e0..49596705 100644 --- a/src/drivers/ao_mpu6000.c +++ b/src/drivers/ao_mpu6000.c @@ -240,13 +240,15 @@ ao_mpu6000_setup(void) ao_mpu6000_configured = 1; } +struct ao_mpu6000_sample ao_mpu6000_current; + static void ao_mpu6000(void) { ao_mpu6000_setup(); for (;;) { - ao_mpu6000_sample((struct ao_mpu6000_sample *) &ao_data_ring[ao_data_head].mpu6000); + ao_mpu6000_sample(&ao_mpu6000_current); ao_arch_critical( AO_DATA_PRESENT(AO_DATA_MPU6000); AO_DATA_WAIT(); diff --git a/src/drivers/ao_mpu6000.h b/src/drivers/ao_mpu6000.h index ca76b081..ab36d6f2 100644 --- a/src/drivers/ao_mpu6000.h +++ b/src/drivers/ao_mpu6000.h @@ -155,6 +155,8 @@ struct ao_mpu6000_sample { int16_t gyro_z; }; +extern struct ao_mpu6000_sample ao_mpu6000_current; + void ao_mpu6000_init(void); diff --git a/src/drivers/ao_ms5607.c b/src/drivers/ao_ms5607.c index 3295baac..492199b8 100644 --- a/src/drivers/ao_ms5607.c +++ b/src/drivers/ao_ms5607.c @@ -207,13 +207,15 @@ ao_ms5607_convert(struct ao_ms5607_sample *sample, struct ao_ms5607_value *value value->temp = TEMP; } +struct ao_ms5607_sample ao_ms5607_current; + static void ao_ms5607(void) { ao_ms5607_setup(); for (;;) { - ao_ms5607_sample((struct ao_ms5607_sample *) &ao_data_ring[ao_data_head].ms5607_raw); + ao_ms5607_sample(&ao_ms5607_current); ao_arch_critical( AO_DATA_PRESENT(AO_DATA_MS5607); AO_DATA_WAIT(); diff --git a/src/drivers/ao_ms5607.h b/src/drivers/ao_ms5607.h index e9c364d9..4c29f6a7 100644 --- a/src/drivers/ao_ms5607.h +++ b/src/drivers/ao_ms5607.h @@ -56,6 +56,8 @@ struct ao_ms5607_value { int32_t temp; /* in °C * 100 */ }; +extern struct ao_ms5607_sample ao_ms5607_current; + void ao_ms5607_init(void); diff --git a/src/stm/ao_adc_stm.c b/src/stm/ao_adc_stm.c index 18ca6ea0..48fc4262 100644 --- a/src/stm/ao_adc_stm.c +++ b/src/stm/ao_adc_stm.c @@ -43,6 +43,23 @@ static void ao_adc_done(int index) { AO_DATA_PRESENT(AO_DATA_ADC); ao_dma_done_transfer(STM_DMA_INDEX(STM_DMA_CHANNEL_ADC1)); + if (ao_data_present == AO_DATA_ALL) { +#if HAS_MS5607 + ao_data_ring[ao_data_head].ms5607_raw = ao_ms5607_current; +#endif +#if HAS_MMA655X + ao_data_ring[ao_data_head].mma655x = ao_mma655x_current; +#endif +#if HAS_HMC5883 + ao_data_ring[ao_data_head].hmc5883 = ao_hmc5883_current; +#endif +#if HAS_MPU6000 + ao_data_ring[ao_data_head].mpu6000 = ao_mpu6000_current; +#endif + ao_data_ring[ao_data_head].tick = ao_tick_count; + ao_data_head = ao_data_ring_next(ao_data_head); + ao_wakeup((void *) &ao_data_head); + } ao_adc_ready = 1; } -- cgit v1.2.3 From 0361235c9ef56738ba0e97be88a85afef0ce8268 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Mon, 8 Oct 2012 23:24:19 -0700 Subject: altos: Fix up ms5607 and mma655x commands to work again These just display the most recently fetched values Signed-off-by: Keith Packard --- src/drivers/ao_mma655x.c | 7 +++---- src/drivers/ao_ms5607.c | 8 +++----- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/src/drivers/ao_mma655x.c b/src/drivers/ao_mma655x.c index 18c5317c..28fe1e08 100644 --- a/src/drivers/ao_mma655x.c +++ b/src/drivers/ao_mma655x.c @@ -238,11 +238,12 @@ ao_mma655x_setup(void) } +uint16_t ao_mma655x_current; + static void ao_mma655x_dump(void) { - ao_mma655x_setup(); - printf ("MMA655X value %d\n", ao_mma655x_value()); + printf ("MMA655X value %d\n", ao_mma655x_current); } __code struct ao_cmds ao_mma655x_cmds[] = { @@ -250,8 +251,6 @@ __code struct ao_cmds ao_mma655x_cmds[] = { { 0, NULL }, }; -uint16_t ao_mma655x_current; - static void ao_mma655x(void) { diff --git a/src/drivers/ao_ms5607.c b/src/drivers/ao_ms5607.c index 492199b8..736e115b 100644 --- a/src/drivers/ao_ms5607.c +++ b/src/drivers/ao_ms5607.c @@ -241,13 +241,11 @@ ao_ms5607_info(void) static void ao_ms5607_dump(void) { - struct ao_data data; struct ao_ms5607_value value; - ao_data_get(&data); - ao_ms5607_convert(&data.ms5607_raw, &value); - printf ("Pressure: %8u %8d\n", data.ms5607_raw.pres, value.pres); - printf ("Temperature: %8u %8d\n", data.ms5607_raw.temp, value.temp); + ao_ms5607_convert(&ao_ms5607_current, &value); + printf ("Pressure: %8u %8d\n", ao_ms5607_current.pres, value.pres); + printf ("Temperature: %8u %8d\n", ao_ms5607_current.temp, value.temp); printf ("Altitude: %ld\n", ao_pa_to_altitude(value.pres)); } -- cgit v1.2.3 From ceb42f4c96076b01ac05577c9fe461b66e72d30d Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Thu, 18 Oct 2012 15:34:41 -0700 Subject: altos/megametrum: Switch back to using the MS5607 We're planning to ship the MS5607 Signed-off-by: Keith Packard --- src/megametrum-v0.1/ao_pins.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/megametrum-v0.1/ao_pins.h b/src/megametrum-v0.1/ao_pins.h index 724878b5..e4c8c8fb 100644 --- a/src/megametrum-v0.1/ao_pins.h +++ b/src/megametrum-v0.1/ao_pins.h @@ -18,8 +18,6 @@ #ifndef _AO_PINS_H_ #define _AO_PINS_H_ -#define HAS_MS5611 1 - /* 8MHz High speed external crystal */ #define AO_HSE 8000000 @@ -248,6 +246,7 @@ struct ao_adc { * Pressure sensor settings */ #define HAS_MS5607 1 +#define HAS_MS5611 0 #define AO_MS5607_PRIVATE_PINS 1 #define AO_MS5607_CS_PORT (&stm_gpioc) #define AO_MS5607_CS_PIN 4 -- cgit v1.2.3 From 05173876d5984a54929db486c9ce1e19bde79526 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Thu, 18 Oct 2012 16:02:59 -0700 Subject: Bump version to 1.1.9.1 Prepare for Rocketober/Thrustration Signed-off-by: Keith Packard --- configure.ac | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index cbb4ce66..0c958a24 100644 --- a/configure.ac +++ b/configure.ac @@ -18,7 +18,7 @@ dnl dnl Process this file with autoconf to create configure. AC_PREREQ(2.57) -AC_INIT([altos], 1.1.9.0) +AC_INIT([altos], 1.1.9.1) AC_CONFIG_SRCDIR([src/core/ao.h]) AM_INIT_AUTOMAKE([foreign dist-bzip2]) AM_MAINTAINER_MODE -- cgit v1.2.3 From 23b0c2fe95dbfaa4a8ce603b56b75d12d2c17d8c Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Thu, 18 Oct 2012 16:19:38 -0700 Subject: altosui: Re-add a couple of "unused" values The values in these calls aren't needed, but the side-effects are, so add them back in. Signed-off-by: Keith Packard --- altosui/AltosFlashUI.java | 2 +- altosui/AltosSiteMap.java | 2 +- altosui/AltosUIPreferences.java | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/altosui/AltosFlashUI.java b/altosui/AltosFlashUI.java index f8c24b16..3ccfa76c 100644 --- a/altosui/AltosFlashUI.java +++ b/altosui/AltosFlashUI.java @@ -286,7 +286,7 @@ public class AltosFlashUI if (!select_source_file()) return; build_dialog(); - //flash_task f = new flash_task(this); + flash_task f = new flash_task(this); } static void show(JFrame frame) { diff --git a/altosui/AltosSiteMap.java b/altosui/AltosSiteMap.java index 3ea4d0fd..4e939b88 100644 --- a/altosui/AltosSiteMap.java +++ b/altosui/AltosSiteMap.java @@ -421,7 +421,7 @@ public class AltosSiteMap extends JScrollPane implements AltosFlightDisplay { public AltosSiteMap(int in_radius) { radius = in_radius; - //GrabNDrag scroller = new GrabNDrag(comp); + GrabNDrag scroller = new GrabNDrag(comp); comp.setLayout(layout); diff --git a/altosui/AltosUIPreferences.java b/altosui/AltosUIPreferences.java index a28c07b0..f6ee7e06 100644 --- a/altosui/AltosUIPreferences.java +++ b/altosui/AltosUIPreferences.java @@ -163,7 +163,7 @@ public class AltosUIPreferences extends AltosPreferences { } } public static void set_serial_debug(boolean new_serial_debug) { - AltosLink.set_debug(serial_debug); + AltosLink.set_debug(new_serial_debug); synchronized (backend) { serial_debug = new_serial_debug; backend.putBoolean(serialDebugPreference, serial_debug); -- cgit v1.2.3