diff --git a/src/main/drivers/barometer_bmp085.c b/src/main/drivers/barometer_bmp085.c index a67f34f3fe..ad01bdf547 100644 --- a/src/main/drivers/barometer_bmp085.c +++ b/src/main/drivers/barometer_bmp085.c @@ -31,6 +31,7 @@ #include "barometer_bmp085.h" +#if defined(BARO) && defined(BARO_EOC_GPIO) // BMP085, Standard address 0x77 static bool convDone = false; static uint16_t convOverrun = 0; @@ -43,6 +44,7 @@ void EXTI15_10_IRQHandler(void) convDone = true; } } +#endif typedef struct { int16_t ac1; @@ -193,8 +195,8 @@ bool bmp085Detect(const bmp085Config_t *config, baro_t *baro) bmp085.al_version = BMP085_GET_BITSLICE(data, BMP085_AL_VERSION); /* get AL Version */ bmp085_get_cal_param(); /* readout bmp085 calibparam structure */ bmp085InitDone = true; - baro->ut_delay = 6000; // 1.5ms margin according to the spec (4.5ms T convetion time) - baro->up_delay = 27000; // 6000+21000=27000 1.5ms margin according to the spec (25.5ms P convetion time with OSS=3) + baro->ut_delay = 6000; // 1.5ms margin according to the spec (4.5ms T conversion time) + baro->up_delay = 27000; // 6000+21000=27000 1.5ms margin according to the spec (25.5ms P conversion time with OSS=3) baro->start_ut = bmp085_start_ut; baro->get_ut = bmp085_get_ut; baro->start_up = bmp085_start_up; @@ -263,7 +265,9 @@ static int32_t bmp085_get_pressure(uint32_t up) static void bmp085_start_ut(void) { +#if defined(BARO) && defined(BARO_EOC_GPIO) convDone = false; +#endif i2cWrite(BMP085_I2C_ADDR, BMP085_CTRL_MEAS_REG, BMP085_T_MEASURE); } @@ -271,9 +275,13 @@ static void bmp085_get_ut(void) { uint8_t data[2]; +#if defined(BARO) && defined(BARO_EOC_GPIO) // wait in case of cockup - if (!convDone) + if (!convDone) { convOverrun++; + return; // keep old value + } +#endif i2cRead(BMP085_I2C_ADDR, BMP085_ADC_OUT_MSB_REG, 2, data); bmp085_ut = (data[0] << 8) | data[1]; @@ -284,7 +292,11 @@ static void bmp085_start_up(void) uint8_t ctrl_reg_data; ctrl_reg_data = BMP085_P_MEASURE + (bmp085.oversampling_setting << 6); + +#if defined(BARO) && defined(BARO_EOC_GPIO) convDone = false; +#endif + i2cWrite(BMP085_I2C_ADDR, BMP085_CTRL_MEAS_REG, ctrl_reg_data); } @@ -296,9 +308,13 @@ static void bmp085_get_up(void) { uint8_t data[3]; +#if defined(BARO) && defined(BARO_EOC_GPIO) // wait in case of cockup - if (!convDone) + if (!convDone) { convOverrun++; + return; // keep old value + } +#endif i2cRead(BMP085_I2C_ADDR, BMP085_ADC_OUT_MSB_REG, 3, data); bmp085_up = (((uint32_t) data[0] << 16) | ((uint32_t) data[1] << 8) | (uint32_t) data[2])