From e892dcb0336b5111bc2820eaa9a266fb804245e2 Mon Sep 17 00:00:00 2001 From: stac Date: Mon, 24 May 2010 16:33:30 +0000 Subject: [PATCH] bmp085: create semaphore prior to configuring irq Since the EXTI and NVIC init routines automatically enable the IRQ when it is configured, it is possible for the EOC interrupt to fire immediately upon configuring the IRQ. Since the handler for the EOC interrupt (EXTI15_10_IRQHandler) does a xSemaphoreGiveFromISR, it is important to have the semaphore initialized prior to enabling the interrupt. Also, added missing include for altitude module. git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@654 ebee16cc-31ac-478f-84a7-5cbb03baadba --- flight/PiOS/Common/pios_bmp085.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/flight/PiOS/Common/pios_bmp085.c b/flight/PiOS/Common/pios_bmp085.c index a092a1ace..f9d8c7999 100644 --- a/flight/PiOS/Common/pios_bmp085.c +++ b/flight/PiOS/Common/pios_bmp085.c @@ -39,7 +39,7 @@ xSemaphoreHandle PIOS_BMP085_EOC; /* Local Variables */ static BMP085CalibDataTypeDef CalibData; -static portBASE_TYPE xHigherPriorityTaskWoken; + /* Straight from the datasheet */ static int32_t X1, X2, X3, B3, B5, B6, P; static uint32_t B4, B7; @@ -58,6 +58,11 @@ void PIOS_BMP085_Init(void) EXTI_InitTypeDef EXTI_InitStructure; NVIC_InitTypeDef NVIC_InitStructure; + /* Semaphore used by ISR to signal End-Of-Conversion */ + vSemaphoreCreateBinary(PIOS_BMP085_EOC); + /* Must start off empty so that first transfer waits for EOC */ + xSemaphoreTake(PIOS_BMP085_EOC, portMAX_DELAY); + /* Enable EOC GPIO clock */ RCC_APB2PeriphClockCmd(PIOS_BMP085_EOC_CLK | RCC_APB2Periph_AFIO, ENABLE); @@ -101,11 +106,6 @@ void PIOS_BMP085_Init(void) CalibData.MB = (Data[16] << 8) | Data[17]; CalibData.MC = (Data[18] << 8) | Data[19]; CalibData.MD = (Data[20] << 8) | Data[21]; - - /* Semaphore used by ISR to signal End-Of-Conversion */ - vSemaphoreCreateBinary(PIOS_BMP085_EOC); - /* Must start off empty so that first transfer waits for EOC */ - xSemaphoreTake(PIOS_BMP085_EOC, portMAX_DELAY); }