From a252ee134a76ac0762322a18524181f53d3a828d Mon Sep 17 00:00:00 2001 From: James Cotton Date: Fri, 20 Jan 2012 14:36:48 -0600 Subject: [PATCH] Fix the l3gd20 initialization in pios_board.c and also change the (ugly) hardcoded exti system to use line3 on F1xx for L3GD20 --- flight/CopterControl/System/inc/pios_config.h | 1 + flight/CopterControl/System/pios_board.c | 2 ++ flight/PiOS/STM32F10x/pios_exti.c | 13 ++++++++----- flight/PiOS/STM32F10x/pios_l3gd20.c | 8 -------- flight/PiOS/pios.h | 4 ++++ 5 files changed, 15 insertions(+), 13 deletions(-) diff --git a/flight/CopterControl/System/inc/pios_config.h b/flight/CopterControl/System/inc/pios_config.h index 004104f70..53f2d86b9 100644 --- a/flight/CopterControl/System/inc/pios_config.h +++ b/flight/CopterControl/System/inc/pios_config.h @@ -75,6 +75,7 @@ #define PIOS_INCLUDE_BL_HELPER #define PIOS_INCLUDE_ADXL345 +#define PIOS_INCLUDE_L3GD20 #define PIOS_INCLUDE_FLASH #define PIOS_INCLUDE_BMP085 diff --git a/flight/CopterControl/System/pios_board.c b/flight/CopterControl/System/pios_board.c index 8fb842666..08b791bce 100644 --- a/flight/CopterControl/System/pios_board.c +++ b/flight/CopterControl/System/pios_board.c @@ -1146,6 +1146,8 @@ static const struct pios_l3gd20_cfg pios_l3gd20_cfg = { }, }, .eoc_exti = { + .pin_source = GPIO_PinSource3, + .port_source = GPIO_PortSourceGPIOA, .init = { .EXTI_Line = EXTI_Line3, // matches above GPIO pin .EXTI_Mode = EXTI_Mode_Interrupt, diff --git a/flight/PiOS/STM32F10x/pios_exti.c b/flight/PiOS/STM32F10x/pios_exti.c index 0b4a9a1ae..2a8501066 100644 --- a/flight/PiOS/STM32F10x/pios_exti.c +++ b/flight/PiOS/STM32F10x/pios_exti.c @@ -79,14 +79,17 @@ void EXTI9_5_IRQHandler(void) } /** -* Handle external line 4 interrupt requests +* Handle external line 3 interrupt requests */ -#if defined(PIOS_INCLUDE_USB) -void EXTI4_IRQHandler(void) +#if defined(PIOS_INCLUDE_L3GD20) +extern void PIOS_L3GD20_IRQHandler(); + +void EXTI3_IRQHandler(void) { - if (EXTI_GetITStatus(PIOS_USB_DETECT_EXTI_LINE) != RESET) { + if (EXTI_GetITStatus(EXTI_Line3) != RESET) { + PIOS_L3GD20_IRQHandler(); /* Clear the EXTI line pending bit */ - EXTI_ClearITPendingBit(PIOS_USB_DETECT_EXTI_LINE); + EXTI_ClearITPendingBit(EXTI_Line3); } } #endif diff --git a/flight/PiOS/STM32F10x/pios_l3gd20.c b/flight/PiOS/STM32F10x/pios_l3gd20.c index 7d9a9f7ac..944517b0b 100644 --- a/flight/PiOS/STM32F10x/pios_l3gd20.c +++ b/flight/PiOS/STM32F10x/pios_l3gd20.c @@ -309,14 +309,6 @@ void PIOS_L3GD20_IRQHandler(void) } -void EXTI4_IRQHandler(void) -{ - if (EXTI_GetITStatus(PIOS_USB_DETECT_EXTI_LINE) != RESET) { - /* Clear the EXTI line pending bit */ - EXTI_ClearITPendingBit(PIOS_USB_DETECT_EXTI_LINE); - } -} - #endif /* L3GD20 */ diff --git a/flight/PiOS/pios.h b/flight/PiOS/pios.h index e7d02dfd2..d76d29fe1 100644 --- a/flight/PiOS/pios.h +++ b/flight/PiOS/pios.h @@ -121,6 +121,10 @@ #include #endif +#if defined(PIOS_INCLUDE_L3GD20) +#include +#endif + #if defined(PIOS_INCLUDE_BMA180) #include #endif