diff --git a/flight/INS/Makefile b/flight/INS/Makefile index 7346b32d1..cb03ce921 100644 --- a/flight/INS/Makefile +++ b/flight/INS/Makefile @@ -128,6 +128,7 @@ SRC += $(STMSPDSRCDIR)/stm32f2xx_pwr.c SRC += $(STMSPDSRCDIR)/stm32f2xx_rcc.c SRC += $(STMSPDSRCDIR)/stm32f2xx_rtc.c SRC += $(STMSPDSRCDIR)/stm32f2xx_spi.c +SRC += $(STMSPDSRCDIR)/stm32f2xx_syscfg.c SRC += $(STMSPDSRCDIR)/stm32f2xx_tim.c SRC += $(STMSPDSRCDIR)/stm32f2xx_usart.c SRC += $(STMSPDSRCDIR)/misc.c diff --git a/flight/INS/pios_board.c b/flight/INS/pios_board.c index 45d3e1609..0d36c98f9 100644 --- a/flight/INS/pios_board.c +++ b/flight/INS/pios_board.c @@ -565,8 +565,8 @@ static const struct pios_hmc5883_cfg pios_hmc5883_cfg = { }, }, .eoc_exti = { -// .pin_source = GPIO_PinSource8, -// .port_source = GPIO_PortSourceGPIOB, + .pin_source = EXTI_PinSource8, + .port_source = EXTI_PortSourceGPIOB, .init = { .EXTI_Line = EXTI_Line8, // matches above GPIO pin .EXTI_Mode = EXTI_Mode_Interrupt, @@ -597,8 +597,8 @@ static const struct pios_bma180_cfg pios_bma180_cfg = { }, }, .eoc_exti = { - // .pin_source = GPIO_PinSource4, - // .port_source = GPIO_PortSourceGPIOC, + .pin_source = EXTI_PinSource4, + .port_source = EXTI_PortSourceGPIOC, .init = { .EXTI_Line = EXTI_Line4, // matches above GPIO pin .EXTI_Mode = EXTI_Mode_Interrupt, @@ -629,8 +629,8 @@ static const struct pios_imu3000_cfg pios_imu3000_cfg = { }, }, .eoc_exti = { - // .pin_source = GPIO_PinSource1, - // .port_source = GPIO_PortSourceGPIOB, + .pin_source = EXTI_PinSource1, + .port_source = EXTI_PortSourceGPIOB, .init = { .EXTI_Line = EXTI_Line1, // matches above GPIO pin .EXTI_Mode = EXTI_Mode_Interrupt, @@ -733,20 +733,18 @@ void PIOS_Board_Init(void) { PIOS_DEBUG_Assert(0); } - PIOS_BMP085_Init(&pios_bmp085_cfg); - PIOS_HMC5883_Init(&pios_hmc5883_cfg); - if (PIOS_I2C_Init(&pios_i2c_gyro_adapter_id, &pios_i2c_gyro_adapter_cfg)) { PIOS_DEBUG_Assert(0); } - PIOS_IMU3000_Init(&pios_imu3000_cfg); - /* Set up the SPI interface to the accelerometer*/ if (PIOS_SPI_Init(&pios_spi_accel_id, &pios_spi_accel_cfg)) { PIOS_DEBUG_Assert(0); } PIOS_BMA180_Attach(pios_spi_accel_id); PIOS_BMA180_Init(&pios_bma180_cfg); + PIOS_IMU3000_Init(&pios_imu3000_cfg); + PIOS_BMP085_Init(&pios_bmp085_cfg); + PIOS_HMC5883_Init(&pios_hmc5883_cfg); /* Set up the SPI interface to the OP board */ diff --git a/flight/PiOS/STM32F2xx/pios_bma180.c b/flight/PiOS/STM32F2xx/pios_bma180.c index 67e2db795..ff7e022a7 100644 --- a/flight/PiOS/STM32F2xx/pios_bma180.c +++ b/flight/PiOS/STM32F2xx/pios_bma180.c @@ -53,10 +53,13 @@ static t_fifo_buffer pios_bma180_fifo; */ void PIOS_BMA180_Init(const struct pios_bma180_cfg * cfg) { + fifoBuf_init(&pios_bma180_fifo, (uint8_t *) pios_bma180_buffer, sizeof(pios_bma180_buffer)); + /* Configure EOC pin as input floating */ GPIO_Init(cfg->drdy.gpio, &cfg->drdy.init); /* Configure the End Of Conversion (EOC) interrupt */ + SYSCFG_EXTILineConfig(cfg->eoc_exti.port_source, cfg->eoc_exti.pin_source); EXTI_Init(&cfg->eoc_exti.init); /* Enable and set EOC EXTI Interrupt to the lowest priority */ @@ -64,8 +67,6 @@ void PIOS_BMA180_Init(const struct pios_bma180_cfg * cfg) pios_bma180_data_ready = false; - fifoBuf_init(&pios_bma180_fifo, (uint8_t *) pios_bma180_buffer, sizeof(pios_bma180_buffer)); - PIOS_BMA180_Config(); PIOS_BMA180_SelectBW(BMA_BW_600HZ); PIOS_BMA180_SetRange(BMA_RANGE_8G); @@ -311,6 +312,7 @@ int32_t PIOS_BMA180_Test() } uint32_t pios_bma180_count = 0; + /** * @brief IRQ Handler */ @@ -327,6 +329,20 @@ void PIOS_BMA180_IRQHandler(void) fifoBuf_putData(&pios_bma180_fifo, accels, sizeof(accels)); } +/** + * The physical IRQ handler + * Soon this will be generic in pios_exti and the BMA180 will register + * against it + */ +void EXTI4_IRQHandler(void) +{ + if (EXTI_GetITStatus(EXTI_Line4) != RESET) { + PIOS_BMA180_IRQHandler(); + EXTI_ClearITPendingBit(EXTI_Line4); + } +} + + /** * @} * @} diff --git a/flight/PiOS/pios.h b/flight/PiOS/pios.h index cc1b2518a..fa03b6faf 100644 --- a/flight/PiOS/pios.h +++ b/flight/PiOS/pios.h @@ -50,6 +50,7 @@ /* STM32 Std Perf Lib */ #if defined(STM32F2XX) #include +#include #else #include #endif