mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2025-02-20 10:54:14 +01:00
bmp085: only use eoc and drdy gpios when available
When the bmp085 chip is on an external board, we don't have access to the eoc and drdy gpio lines. Only use them when available.
This commit is contained in:
parent
a0089f072a
commit
4cb0c41338
@ -144,13 +144,21 @@ static void altitudeTask(void *parameters)
|
||||
#endif
|
||||
// Update the temperature data
|
||||
PIOS_BMP085_StartADC(TemperatureConv);
|
||||
#ifdef PIOS_BMP085_HAS_GPIOS
|
||||
xSemaphoreTake(PIOS_BMP085_EOC, portMAX_DELAY);
|
||||
#else
|
||||
vTaskDelay(5 / portTICK_RATE_MS);
|
||||
#endif
|
||||
PIOS_BMP085_ReadADC();
|
||||
alt_ds_temp += PIOS_BMP085_GetTemperature();
|
||||
|
||||
// Update the pressure data
|
||||
PIOS_BMP085_StartADC(PressureConv);
|
||||
#ifdef PIOS_BMP085_HAS_GPIOS
|
||||
xSemaphoreTake(PIOS_BMP085_EOC, portMAX_DELAY);
|
||||
#else
|
||||
vTaskDelay(26 / portTICK_RATE_MS);
|
||||
#endif
|
||||
PIOS_BMP085_ReadADC();
|
||||
alt_ds_pres += PIOS_BMP085_GetPressure();
|
||||
|
||||
|
@ -106,6 +106,7 @@ extern uint32_t pios_i2c_gyro_adapter_id;
|
||||
//------------------------
|
||||
// PIOS_BMP085
|
||||
//------------------------
|
||||
#define PIOS_BMP085_HAS_GPIOS
|
||||
#define PIOS_BMP085_EOC_GPIO_PORT GPIOC
|
||||
#define PIOS_BMP085_EOC_GPIO_PIN GPIO_Pin_2
|
||||
#define PIOS_BMP085_EOC_PORT_SOURCE GPIO_PortSourceGPIOC
|
||||
|
@ -120,6 +120,7 @@ extern uint32_t pios_i2c_main_adapter_id;
|
||||
//------------------------
|
||||
// PIOS_BMP085
|
||||
//------------------------
|
||||
#define PIOS_BMP085_HAS_GPIOS
|
||||
#define PIOS_BMP085_EOC_GPIO_PORT GPIOC
|
||||
#define PIOS_BMP085_EOC_GPIO_PIN GPIO_Pin_15
|
||||
#define PIOS_BMP085_EOC_PORT_SOURCE GPIO_PortSourceGPIOC
|
||||
|
@ -38,12 +38,17 @@
|
||||
|
||||
/* Glocal Variables */
|
||||
ConversionTypeTypeDef CurrentRead;
|
||||
|
||||
#ifdef PIOS_BMP085_HAS_GPIOS
|
||||
|
||||
#if defined(PIOS_INCLUDE_FREERTOS)
|
||||
xSemaphoreHandle PIOS_BMP085_EOC;
|
||||
#else
|
||||
int32_t PIOS_BMP085_EOC;
|
||||
#endif
|
||||
|
||||
#endif /* PIOS_BMP085_HAS_GPIOS */
|
||||
|
||||
/* Local Variables */
|
||||
static BMP085CalibDataTypeDef CalibData;
|
||||
|
||||
@ -60,6 +65,9 @@ static volatile uint16_t Temperature;
|
||||
*/
|
||||
void PIOS_BMP085_Init(void)
|
||||
{
|
||||
|
||||
#ifdef PIOS_BMP085_HAS_GPIOS
|
||||
|
||||
GPIO_InitTypeDef GPIO_InitStructure;
|
||||
EXTI_InitTypeDef EXTI_InitStructure;
|
||||
NVIC_InitTypeDef NVIC_InitStructure;
|
||||
@ -101,6 +109,8 @@ void PIOS_BMP085_Init(void)
|
||||
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;
|
||||
GPIO_Init(PIOS_BMP085_XCLR_GPIO_PORT, &GPIO_InitStructure);
|
||||
|
||||
#endif /* PIOS_BMP085_HAS_GPIOS */
|
||||
|
||||
/* Read all 22 bytes of calibration data in one transfer, this is a very optimized way of doing things */
|
||||
uint8_t Data[BMP085_CALIB_LEN];
|
||||
while (!PIOS_BMP085_Read(BMP085_CALIB_ADDR, Data, BMP085_CALIB_LEN))
|
||||
|
@ -44,7 +44,7 @@ void EXTI15_10_IRQHandler(void)
|
||||
portBASE_TYPE xHigherPriorityTaskWoken = pdFALSE;
|
||||
#endif
|
||||
|
||||
#if defined(PIOS_INCLUDE_BMP085)
|
||||
#if defined(PIOS_INCLUDE_BMP085) && defined(PIOS_BMP085_HAS_GPIOS)
|
||||
if (EXTI_GetITStatus(PIOS_BMP085_EOC_EXTI_LINE) != RESET) {
|
||||
/* Read the ADC Value */
|
||||
#if defined(PIOS_INCLUDE_FREERTOS)
|
||||
|
Loading…
x
Reference in New Issue
Block a user