1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2025-01-18 03:52:11 +01:00

Get BMA180 working. Need to move exti stuff into it until pios_exti

implemented properly
This commit is contained in:
James Cotton 2011-08-13 01:10:33 -05:00
parent 5619e33292
commit 6d018c046e
4 changed files with 29 additions and 13 deletions

View File

@ -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

View File

@ -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 */

View File

@ -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);
}
}
/**
* @}
* @}

View File

@ -50,6 +50,7 @@
/* STM32 Std Perf Lib */
#if defined(STM32F2XX)
#include <stm32f2xx.h>
#include <stm32f2xx_syscfg.h>
#else
#include <stm32f10x.h>
#endif