diff --git a/flight/PiOS/Common/pios_bma180.c b/flight/PiOS/Common/pios_bma180.c index f085d5448..7d5c53ef2 100644 --- a/flight/PiOS/Common/pios_bma180.c +++ b/flight/PiOS/Common/pios_bma180.c @@ -30,6 +30,9 @@ */ #include "pios.h" + +#if defined(PIOS_INCLUDE_BMA180) + #include "fifo_buffer.h" static uint32_t PIOS_SPI_ACCEL; @@ -40,7 +43,6 @@ static int32_t PIOS_BMA180_SelectBW(enum bma180_bandwidth bw); static int32_t PIOS_BMA180_SetRange(enum bma180_range range); static int32_t PIOS_BMA180_Config(); static int32_t PIOS_BMA180_EnableIrq(); -static void PIOS_BMA180_IRQHandler(void); #define PIOS_BMA180_MAX_DOWNSAMPLE 10 static int16_t pios_bma180_buffer[PIOS_BMA180_MAX_DOWNSAMPLE * sizeof(struct pios_bma180_data)]; @@ -60,15 +62,7 @@ int32_t 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 */ - NVIC_Init(&cfg->eoc_irq.init); + PIOS_EXTI_Init(cfg->exti_cfg); if(PIOS_BMA180_Config() < 0) return -1; @@ -364,7 +358,7 @@ int32_t PIOS_BMA180_Test() /** * @brief IRQ Handler. Read data from the BMA180 FIFO and push onto a local fifo. */ -static void PIOS_BMA180_IRQHandler(void) +void PIOS_BMA180_IRQHandler(void) { const static uint8_t pios_bma180_req_buf[7] = {BMA_X_LSB_ADDR | 0x80,0,0,0,0,0}; uint8_t pios_bma180_dmabuf[8]; @@ -401,24 +395,7 @@ static void PIOS_BMA180_IRQHandler(void) } - -/** - * The physical IRQ handler - * Soon this will be generic in pios_exti and the BMA180 will register - * against it - */ - -int32_t bma180_irq = 0; -void EXTI4_IRQHandler(void) -{ - if (EXTI_GetITStatus(dev_cfg->eoc_exti.init.EXTI_Line) != RESET) { - bma180_irq++; - PIOS_BMA180_IRQHandler(); - EXTI_ClearITPendingBit(dev_cfg->eoc_exti.init.EXTI_Line); - } -} - - +#endif /* PIOS_INCLUDE_BMA180 */ /** * @} * @} diff --git a/flight/PiOS/Common/pios_hmc5883.c b/flight/PiOS/Common/pios_hmc5883.c index 6922dfe9e..8891709fc 100644 --- a/flight/PiOS/Common/pios_hmc5883.c +++ b/flight/PiOS/Common/pios_hmc5883.c @@ -54,15 +54,7 @@ void PIOS_HMC5883_Init(const struct pios_hmc5883_cfg * cfg) { dev_cfg = cfg; // store config before enabling interrupt - /* 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 */ - NVIC_Init(&cfg->eoc_irq.init); + PIOS_EXTI_Init(cfg->exti_cfg); int32_t val = PIOS_HMC5883_Config(cfg); @@ -404,37 +396,6 @@ void PIOS_HMC5883_IRQHandler(void) pios_hmc5883_data_ready = true; } -/** - * The physical IRQ handler - * Soon this will be generic in pios_exti and the BMA180 will register - * against it. Right now this is crap! - */ -#if defined(PIOS_INCLUDE_MPU6000) -extern void PIOS_MPU6000_IRQHandler(); -#elif defined(PIOS_INCLUDE_L3GD20) -extern void PIOS_L3GD20_IRQHandler(); -#endif -void EXTI9_5_IRQHandler(void) -{ - if (EXTI_GetITStatus(dev_cfg->eoc_exti.init.EXTI_Line) != RESET) { - PIOS_HMC5883_IRQHandler(); - EXTI_ClearITPendingBit(dev_cfg->eoc_exti.init.EXTI_Line); - } -#if defined(PIOS_INCLUDE_MPU6000) - if (EXTI_GetITStatus(EXTI_Line8) != RESET) { - PIOS_MPU6000_IRQHandler(); - EXTI_ClearITPendingBit(EXTI_Line8); - } -#elif defined(PIOS_INCLUDE_L3GD20) - if (EXTI_GetITStatus(EXTI_Line8) != RESET) { - PIOS_L3GD20_IRQHandler(); - EXTI_ClearITPendingBit(EXTI_Line8); - } -#endif - -} - - #endif /* PIOS_INCLUDE_HMC5883 */ /** diff --git a/flight/PiOS/Common/pios_l3gd20.c b/flight/PiOS/Common/pios_l3gd20.c index 3913eeaa8..daf3607cf 100644 --- a/flight/PiOS/Common/pios_l3gd20.c +++ b/flight/PiOS/Common/pios_l3gd20.c @@ -68,15 +68,8 @@ void PIOS_L3GD20_Init(const struct pios_l3gd20_cfg * new_cfg) PIOS_L3GD20_Config(cfg); PIOS_SPI_SetPrescalar(pios_spi_gyro, SPI_BaudRatePrescaler_16); - /* 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 */ - NVIC_Init(&cfg->eoc_irq.init); + /* Set up EXTI */ + PIOS_EXTI_Init(new_cfg->exti_cfg); // An initial read is needed to get it running struct pios_l3gd20_data data; diff --git a/flight/PiOS/Common/pios_mpu6000.c b/flight/PiOS/Common/pios_mpu6000.c index 34b4da64b..f8d56c874 100644 --- a/flight/PiOS/Common/pios_mpu6000.c +++ b/flight/PiOS/Common/pios_mpu6000.c @@ -68,12 +68,8 @@ void PIOS_MPU6000_Init(const struct pios_mpu6000_cfg * new_cfg) PIOS_MPU6000_Config(cfg); PIOS_SPI_SetPrescalar(pios_spi_gyro, SPI_BaudRatePrescaler_8); - /* 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); + /* Set up EXTI line */ + PIOS_EXTI_Init(&new_cfg->cfg); /* Enable and set EOC EXTI Interrupt to the lowest priority */ NVIC_Init(&cfg->eoc_irq.init); diff --git a/flight/PiOS/Common/pios_adxl345.c b/flight/PiOS/STM32F10x/pios_adxl345.c similarity index 100% rename from flight/PiOS/Common/pios_adxl345.c rename to flight/PiOS/STM32F10x/pios_adxl345.c diff --git a/flight/PiOS/inc/pios_bma180.h b/flight/PiOS/inc/pios_bma180.h index 6a860dfd2..f00ab03d6 100644 --- a/flight/PiOS/inc/pios_bma180.h +++ b/flight/PiOS/inc/pios_bma180.h @@ -91,9 +91,7 @@ struct pios_bma180_data { struct pios_bma180_cfg { - struct stm32_gpio drdy; - struct stm32_exti eoc_exti; - struct stm32_irq eoc_irq; + const struct pios_exti_cfg * exti_cfg; /* Pointer to the EXTI configuration */ }; /* Public Functions */ @@ -103,6 +101,7 @@ extern float PIOS_BMA180_GetScale(); extern int32_t PIOS_BMA180_ReadFifo(struct pios_bma180_data * buffer); extern int32_t PIOS_BMA180_ReadAccels(struct pios_bma180_data * data); extern int32_t PIOS_BMA180_Test(); +extern void PIOS_BMA180_IRQHandler(); #endif /* PIOS_BMA180_H */ diff --git a/flight/PiOS/inc/pios_bmp085.h b/flight/PiOS/inc/pios_bmp085.h index ecb51a982..73acf871f 100644 --- a/flight/PiOS/inc/pios_bmp085.h +++ b/flight/PiOS/inc/pios_bmp085.h @@ -73,10 +73,7 @@ extern int32_t PIOS_BMP085_EOC; struct pios_bmp085_cfg { - struct stm32_gpio drdy; - struct stm32_gpio xclr; - struct stm32_exti eoc_exti; - struct stm32_irq eoc_irq; + static const struct pios_exti_cfg * exti_cfg; /* Pointer to the EXTI configuration */ uint32_t oversampling; }; diff --git a/flight/PiOS/inc/pios_hmc5883.h b/flight/PiOS/inc/pios_hmc5883.h index 91442cf33..037dca788 100644 --- a/flight/PiOS/inc/pios_hmc5883.h +++ b/flight/PiOS/inc/pios_hmc5883.h @@ -93,10 +93,7 @@ struct pios_hmc5883_cfg { - struct stm32_gpio drdy; - struct stm32_exti eoc_exti; - struct stm32_irq eoc_irq; - + const struct pios_exti_cfg * exti_cfg; /* Pointer to the EXTI configuration */ uint8_t M_ODR; /* OUTPUT DATA RATE --> here below the relative define (See datasheet page 11 for more details) */ uint8_t Meas_Conf; /* Measurement Configuration,: Normal, positive bias, or negative bias --> here below the relative define */ uint8_t Gain; /* Gain Configuration, select the full scale --> here below the relative define (See datasheet page 11 for more details) */ @@ -110,7 +107,7 @@ extern bool PIOS_HMC5883_NewDataAvailable(void); extern int32_t PIOS_HMC5883_ReadMag(int16_t out[3]); extern uint8_t PIOS_HMC5883_ReadID(uint8_t out[4]); extern int32_t PIOS_HMC5883_Test(void); - +extern void PIOS_HMC5883_IRQHandler(); #endif /* PIOS_HMC5883_H */ /** diff --git a/flight/PiOS/inc/pios_l3gd20.h b/flight/PiOS/inc/pios_l3gd20.h index 090c325e7..ebc3cc91a 100644 --- a/flight/PiOS/inc/pios_l3gd20.h +++ b/flight/PiOS/inc/pios_l3gd20.h @@ -127,9 +127,8 @@ struct pios_l3gd20_data { }; struct pios_l3gd20_cfg { - struct stm32_gpio drdy; - struct stm32_exti eoc_exti; - struct stm32_irq eoc_irq; + const struct pios_exti_cfg * exti_cfg; /* Pointer to the EXTI configuration */ + enum pios_l3gd20_range gyro_range; }; @@ -141,6 +140,7 @@ extern int32_t PIOS_L3GD20_ReadGyros(struct pios_l3gd20_data * buffer); extern int32_t PIOS_L3GD20_ReadID(); extern uint8_t PIOS_L3GD20_Test(); extern float PIOS_L3GD20_GetScale(); +extern void PIOS_L3GD20_IRQHandler(); #endif /* PIOS_L3GD20_H */ diff --git a/flight/PiOS/inc/pios_mpu6000.h b/flight/PiOS/inc/pios_mpu6000.h index b92ded9d3..12627fd9e 100644 --- a/flight/PiOS/inc/pios_mpu6000.h +++ b/flight/PiOS/inc/pios_mpu6000.h @@ -128,9 +128,7 @@ struct pios_mpu6000_data { }; struct pios_mpu6000_cfg { - struct stm32_gpio drdy; - struct stm32_exti eoc_exti; - struct stm32_irq eoc_irq; + const struct pios_exti_cfg * exti_cfg; /* Pointer to the EXTI configuration */ uint8_t Fifo_store; /* FIFO storage of different readings (See datasheet page 31 for more details) */ uint8_t Smpl_rate_div; /* Sample rate divider to use (See datasheet page 32 for more details) */ @@ -151,6 +149,7 @@ extern int32_t PIOS_MPU6000_ReadID(); extern uint8_t PIOS_MPU6000_Test(); extern float PIOS_MPU6000_GetScale(); extern float PIOS_MPU6000_GetAccelScale(); +extern void PIOS_MPU6000_IRQHandler(void); #endif /* PIOS_MPU6000_H */ diff --git a/flight/PiOS/pios.h b/flight/PiOS/pios.h index 88ed15f09..27a53d4da 100644 --- a/flight/PiOS/pios.h +++ b/flight/PiOS/pios.h @@ -93,9 +93,7 @@ #include #include #include -#if defined(PIOS_INCLUDE_EXTI) #include -#endif #include /* PIOS Hardware Includes (Common) */ @@ -134,12 +132,12 @@ #if defined(PIOS_INCLUDE_IAP) #include #endif - #if defined(PIOS_INCLUDE_ADXL345) #include #endif - +#if defined(PIOS_INCLUDE_BMA180) #include +#endif #if defined(PIOS_INCLUDE_FLASH) #include diff --git a/flight/Project/OpenPilotOSX/OpenPilotOSX.xcodeproj/project.pbxproj b/flight/Project/OpenPilotOSX/OpenPilotOSX.xcodeproj/project.pbxproj index 51b8a1a0a..50eb6782a 100644 --- a/flight/Project/OpenPilotOSX/OpenPilotOSX.xcodeproj/project.pbxproj +++ b/flight/Project/OpenPilotOSX/OpenPilotOSX.xcodeproj/project.pbxproj @@ -59,9 +59,7 @@ 651913381256C5240039C0A3 /* ahrs_spi_comm.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = ahrs_spi_comm.c; sourceTree = ""; }; 6519133A1256C52B0039C0A3 /* ahrs_comm_objects.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ahrs_comm_objects.h; sourceTree = ""; }; 6519133B1256C52B0039C0A3 /* ahrs_spi_comm.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ahrs_spi_comm.h; sourceTree = ""; }; - 651CF9E5120B5D8300EEFD70 /* pios_usb_hid_desc.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = pios_usb_hid_desc.c; sourceTree = ""; }; 651CF9E6120B5D8300EEFD70 /* pios_usb_hid_istr.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = pios_usb_hid_istr.c; sourceTree = ""; }; - 651CF9E7120B5D8300EEFD70 /* pios_usb_hid_prop.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = pios_usb_hid_prop.c; sourceTree = ""; }; 651CF9E8120B5D8300EEFD70 /* pios_usb_hid_pwr.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = pios_usb_hid_pwr.c; sourceTree = ""; }; 651CF9EF120B700D00EEFD70 /* pios_usb_hid_desc.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = pios_usb_hid_desc.h; sourceTree = ""; }; 651CF9F0120B700D00EEFD70 /* pios_usb_hid_istr.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = pios_usb_hid_istr.h; sourceTree = ""; }; @@ -123,10 +121,8 @@ 65904E54146128A500FD9482 /* op_config.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = op_config.h; sourceTree = ""; }; 65904E55146128A500FD9482 /* openpilot.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = openpilot.h; sourceTree = ""; }; 65904E56146128A500FD9482 /* pios_config.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = pios_config.h; sourceTree = ""; }; - 65904E57146128A500FD9482 /* taskmonitor.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = taskmonitor.h; sourceTree = ""; }; 65904E58146128A500FD9482 /* pios_board.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = pios_board.c; sourceTree = ""; }; 65904E59146128A500FD9482 /* revolution.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = revolution.c; sourceTree = ""; }; - 65904E5A146128A500FD9482 /* taskmonitor.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = taskmonitor.c; sourceTree = ""; }; 65904E5B146128A500FD9482 /* test.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = test.c; sourceTree = ""; }; 65904E5C146128A500FD9482 /* UAVObjects.inc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.pascal; path = UAVObjects.inc; sourceTree = ""; }; 65904E5F14613B6100FD9482 /* pios_i2c_config.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = pios_i2c_config.h; sourceTree = ""; }; @@ -3834,7 +3830,6 @@ 65904E50146128A500FD9482 /* inc */, 65904E58146128A500FD9482 /* pios_board.c */, 65904E59146128A500FD9482 /* revolution.c */, - 65904E5A146128A500FD9482 /* taskmonitor.c */, ); path = System; sourceTree = ""; @@ -3848,7 +3843,6 @@ 65904E54146128A500FD9482 /* op_config.h */, 65904E55146128A500FD9482 /* openpilot.h */, 65904E56146128A500FD9482 /* pios_config.h */, - 65904E57146128A500FD9482 /* taskmonitor.h */, ); path = inc; sourceTree = ""; @@ -8526,9 +8520,7 @@ 65643CB91413456D00A32F59 /* pios_tim.c */, 65E8F0EA11EFF25C00BBF654 /* pios_usart.c */, 65E8F0ED11EFF25C00BBF654 /* pios_usb_hid.c */, - 651CF9E5120B5D8300EEFD70 /* pios_usb_hid_desc.c */, 651CF9E6120B5D8300EEFD70 /* pios_usb_hid_istr.c */, - 651CF9E7120B5D8300EEFD70 /* pios_usb_hid_prop.c */, 651CF9E8120B5D8300EEFD70 /* pios_usb_hid_pwr.c */, 65003B31121249CA00C183DD /* pios_wdg.c */, 65E8F0EE11EFF25C00BBF654 /* startup_stm32f10x_HD.S */, diff --git a/flight/Revolution/System/inc/pios_config.h b/flight/Revolution/System/inc/pios_config.h index 8e2fa1dd4..4f63fc7e1 100644 --- a/flight/Revolution/System/inc/pios_config.h +++ b/flight/Revolution/System/inc/pios_config.h @@ -51,7 +51,7 @@ #define PIOS_INCLUDE_USART //#define PIOS_INCLUDE_USB_HID //#define PIOS_INCLUDE_GPIO -//#define PIOS_INCLUDE_EXTI +#define PIOS_INCLUDE_EXTI #define PIOS_INCLUDE_RTC #define PIOS_INCLUDE_WDG diff --git a/flight/Revolution/System/pios_board.c b/flight/Revolution/System/pios_board.c index 6b5e85a5f..d49b92296 100644 --- a/flight/Revolution/System/pios_board.c +++ b/flight/Revolution/System/pios_board.c @@ -1394,9 +1394,12 @@ uint32_t pios_com_telem_rf_id; /** * Sensor configurations */ +#if defined(PIOS_INCLUDE_HMC5883) #include "pios_hmc5883.h" -static const struct pios_hmc5883_cfg pios_hmc5883_cfg = { - .drdy = { +static const struct pios_exti_cfg pios_exti_hmc5883_cfg __exti_config = { + .vector = PIOS_HMC5883_IRQHandler, + .line = EXTI_Line5, + .pin = { .gpio = GPIOB, .init = { .GPIO_Pin = GPIO_Pin_5, @@ -1406,17 +1409,7 @@ static const struct pios_hmc5883_cfg pios_hmc5883_cfg = { .GPIO_PuPd = GPIO_PuPd_NOPULL, }, }, - .eoc_exti = { - .pin_source = EXTI_PinSource5, - .port_source = EXTI_PortSourceGPIOB, - .init = { - .EXTI_Line = EXTI_Line5, // matches above GPIO pin - .EXTI_Mode = EXTI_Mode_Interrupt, - .EXTI_Trigger = EXTI_Trigger_Rising, - .EXTI_LineCmd = ENABLE, - }, - }, - .eoc_irq = { + .irq = { .init = { .NVIC_IRQChannel = EXTI9_5_IRQn, .NVIC_IRQChannelPreemptionPriority = PIOS_IRQ_PRIO_LOW, @@ -1424,21 +1417,45 @@ static const struct pios_hmc5883_cfg pios_hmc5883_cfg = { .NVIC_IRQChannelCmd = ENABLE, }, }, + .exti = { + .init = { + .EXTI_Line = EXTI_Line5, // matches above GPIO pin + .EXTI_Mode = EXTI_Mode_Interrupt, + .EXTI_Trigger = EXTI_Trigger_Rising, + .EXTI_LineCmd = ENABLE, + }, + }, +}; + +static const struct pios_hmc5883_cfg pios_hmc5883_cfg = { + .exti_cfg = &pios_exti_hmc5883_cfg, .M_ODR = PIOS_HMC5883_ODR_75, .Meas_Conf = PIOS_HMC5883_MEASCONF_NORMAL, .Gain = PIOS_HMC5883_GAIN_1_9, .Mode = PIOS_HMC5883_MODE_CONTINUOUS, }; +#endif /* PIOS_INCLUDE_HMC5883 */ +/** + * Configuration for the MS5611 chip + */ +#if defined(PIOS_INCLUDE_MS5611) #include "pios_ms5611.h" static const struct pios_ms5611_cfg pios_ms5611_cfg = { .oversampling = 1, }; +#endif /* PIOS_INCLUDE_MS5611 */ +/** + * Configuration for the BMA180 chip + */ +#if defined(PIOS_INCLUDE_BMA180) #include "pios_bma180.h" -static const struct pios_bma180_cfg pios_bma180_cfg = { - .drdy = { +static const struct pios_exti_cfg pios_exti_bma180_cfg __exti_config = { + .vector = PIOS_BMA180_IRQHandler, + .line = EXTI_Line4, + .pin = { .gpio = GPIOC, .init = { .GPIO_Pin = GPIO_Pin_4, @@ -1448,17 +1465,7 @@ static const struct pios_bma180_cfg pios_bma180_cfg = { .GPIO_PuPd = GPIO_PuPd_NOPULL, }, }, - .eoc_exti = { - .pin_source = EXTI_PinSource4, - .port_source = EXTI_PortSourceGPIOC, - .init = { - .EXTI_Line = EXTI_Line4, // matches above GPIO pin - .EXTI_Mode = EXTI_Mode_Interrupt, - .EXTI_Trigger = EXTI_Trigger_Rising, - .EXTI_LineCmd = ENABLE, - }, - }, - .eoc_irq = { + .irq = { .init = { .NVIC_IRQChannel = EXTI4_IRQn, .NVIC_IRQChannelPreemptionPriority = PIOS_IRQ_PRIO_LOW, @@ -1466,11 +1473,29 @@ static const struct pios_bma180_cfg pios_bma180_cfg = { .NVIC_IRQChannelCmd = ENABLE, }, }, + .exti = { + .init = { + .EXTI_Line = EXTI_Line4, // matches above GPIO pin + .EXTI_Mode = EXTI_Mode_Interrupt, + .EXTI_Trigger = EXTI_Trigger_Rising, + .EXTI_LineCmd = ENABLE, + }, + }, }; +static const struct pios_bma180_cfg pios_bma180_cfg = { + .exti_cfg = &pios_exti_bma180_cfg, +}; +#endif /* PIOS_INCLUDE_BMA180 */ +/** + * Configuration for the MPU6000 chip + */ +#if defined(PIOS_INCLUDE_MPU6000) #include "pios_mpu6000.h" -static const struct pios_mpu6000_cfg pios_mpu6000_cfg = { - .drdy = { +static const struct pios_exti_cfg pios_exti_mpu6000_cfg __exti_config = { + .vector = PIOS_MPU6000_IRQHandler, + .line = EXTI_Line8, + .pin = { .gpio = GPIOD, .init = { .GPIO_Pin = GPIO_Pin_8, @@ -1480,17 +1505,7 @@ static const struct pios_mpu6000_cfg pios_mpu6000_cfg = { .GPIO_PuPd = GPIO_PuPd_NOPULL, }, }, - .eoc_exti = { - .pin_source = EXTI_PinSource8, - .port_source = EXTI_PortSourceGPIOD, - .init = { - .EXTI_Line = EXTI_Line8, // matches above GPIO pin - .EXTI_Mode = EXTI_Mode_Interrupt, - .EXTI_Trigger = EXTI_Trigger_Rising, - .EXTI_LineCmd = ENABLE, - }, - }, - .eoc_irq = { + .irq = { .init = { .NVIC_IRQChannel = EXTI9_5_IRQn, .NVIC_IRQChannelPreemptionPriority = PIOS_IRQ_PRIO_HIGH, @@ -1498,6 +1513,18 @@ static const struct pios_mpu6000_cfg pios_mpu6000_cfg = { .NVIC_IRQChannelCmd = ENABLE, }, }, + .exti = { + .init = { + .EXTI_Line = EXTI_Line8, // matches above GPIO pin + .EXTI_Mode = EXTI_Mode_Interrupt, + .EXTI_Trigger = EXTI_Trigger_Rising, + .EXTI_LineCmd = ENABLE, + }, + }, +}; + +static const struct pios_mpu6000_cfg pios_mpu6000_cfg = { + .exti_cfg = &pios_exti_mpu6000_cfg, .Fifo_store = PIOS_MPU6000_FIFO_TEMP_OUT | PIOS_MPU6000_FIFO_GYRO_X_OUT | PIOS_MPU6000_FIFO_GYRO_Y_OUT | PIOS_MPU6000_FIFO_GYRO_Z_OUT, // Clock at 8 khz, downsampled by 8 for 1khz .Smpl_rate_div = 7, @@ -1508,10 +1535,16 @@ static const struct pios_mpu6000_cfg pios_mpu6000_cfg = { .gyro_range = PIOS_MPU6000_SCALE_500_DEG, .filter = PIOS_MPU6000_LOWPASS_256_HZ }; - +#endif /* PIOS_INCLUDE_MPU6000 */ +/** + * Configuration for L3GD20 chip + */ +#if defined(PIOS_INCLUDE_L3GD20) #include "pios_l3gd20.h" -static const struct pios_l3gd20_cfg pios_l3gd20_cfg = { - .drdy = { +static const struct pios_exti_cfg pios_exti_l3gd20_cfg __exti_config = { + .vector = PIOS_L3GD20_IRQHandler, + .line = EXTI_Line8, + .pin = { .gpio = GPIOD, .init = { .GPIO_Pin = GPIO_Pin_8, @@ -1521,17 +1554,7 @@ static const struct pios_l3gd20_cfg pios_l3gd20_cfg = { .GPIO_PuPd = GPIO_PuPd_NOPULL, }, }, - .eoc_exti = { - .pin_source = EXTI_PinSource8, - .port_source = EXTI_PortSourceGPIOD, - .init = { - .EXTI_Line = EXTI_Line8, // matches above GPIO pin - .EXTI_Mode = EXTI_Mode_Interrupt, - .EXTI_Trigger = EXTI_Trigger_Rising, - .EXTI_LineCmd = ENABLE, - }, - }, - .eoc_irq = { + .irq = { .init = { .NVIC_IRQChannel = EXTI9_5_IRQn, .NVIC_IRQChannelPreemptionPriority = PIOS_IRQ_PRIO_HIGH, @@ -1539,8 +1562,21 @@ static const struct pios_l3gd20_cfg pios_l3gd20_cfg = { .NVIC_IRQChannelCmd = ENABLE, }, }, + .exti = { + .init = { + .EXTI_Line = EXTI_Line8, // matches above GPIO pin + .EXTI_Mode = EXTI_Mode_Interrupt, + .EXTI_Trigger = EXTI_Trigger_Rising, + .EXTI_LineCmd = ENABLE, + }, + }, +}; + +static const struct pios_l3gd20_cfg pios_l3gd20_cfg = { + .exti_cfg = &pios_exti_l3gd20_cfg, .gyro_range = PIOS_L3GD20_SCALE_500_DEG, }; +#endif /* PIOS_INCLUDE_L3GD20 */ /** * PIOS_Board_Init()