mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-26 09:45:37 +03:00
Avoid reading data from BMP085 when no EOC event occured
This commit is contained in:
parent
9ed84e0e6b
commit
0134e19edf
1 changed files with 20 additions and 4 deletions
|
@ -31,6 +31,7 @@
|
||||||
|
|
||||||
#include "barometer_bmp085.h"
|
#include "barometer_bmp085.h"
|
||||||
|
|
||||||
|
#if defined(BARO) && defined(BARO_EOC_GPIO)
|
||||||
// BMP085, Standard address 0x77
|
// BMP085, Standard address 0x77
|
||||||
static bool convDone = false;
|
static bool convDone = false;
|
||||||
static uint16_t convOverrun = 0;
|
static uint16_t convOverrun = 0;
|
||||||
|
@ -43,6 +44,7 @@ void EXTI15_10_IRQHandler(void)
|
||||||
convDone = true;
|
convDone = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
int16_t ac1;
|
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.al_version = BMP085_GET_BITSLICE(data, BMP085_AL_VERSION); /* get AL Version */
|
||||||
bmp085_get_cal_param(); /* readout bmp085 calibparam structure */
|
bmp085_get_cal_param(); /* readout bmp085 calibparam structure */
|
||||||
bmp085InitDone = true;
|
bmp085InitDone = true;
|
||||||
baro->ut_delay = 6000; // 1.5ms margin according to the spec (4.5ms T convetion time)
|
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 convetion time with OSS=3)
|
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->start_ut = bmp085_start_ut;
|
||||||
baro->get_ut = bmp085_get_ut;
|
baro->get_ut = bmp085_get_ut;
|
||||||
baro->start_up = bmp085_start_up;
|
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)
|
static void bmp085_start_ut(void)
|
||||||
{
|
{
|
||||||
|
#if defined(BARO) && defined(BARO_EOC_GPIO)
|
||||||
convDone = false;
|
convDone = false;
|
||||||
|
#endif
|
||||||
i2cWrite(BMP085_I2C_ADDR, BMP085_CTRL_MEAS_REG, BMP085_T_MEASURE);
|
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];
|
uint8_t data[2];
|
||||||
|
|
||||||
|
#if defined(BARO) && defined(BARO_EOC_GPIO)
|
||||||
// wait in case of cockup
|
// wait in case of cockup
|
||||||
if (!convDone)
|
if (!convDone) {
|
||||||
convOverrun++;
|
convOverrun++;
|
||||||
|
return; // keep old value
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
i2cRead(BMP085_I2C_ADDR, BMP085_ADC_OUT_MSB_REG, 2, data);
|
i2cRead(BMP085_I2C_ADDR, BMP085_ADC_OUT_MSB_REG, 2, data);
|
||||||
bmp085_ut = (data[0] << 8) | data[1];
|
bmp085_ut = (data[0] << 8) | data[1];
|
||||||
|
@ -284,7 +292,11 @@ static void bmp085_start_up(void)
|
||||||
uint8_t ctrl_reg_data;
|
uint8_t ctrl_reg_data;
|
||||||
|
|
||||||
ctrl_reg_data = BMP085_P_MEASURE + (bmp085.oversampling_setting << 6);
|
ctrl_reg_data = BMP085_P_MEASURE + (bmp085.oversampling_setting << 6);
|
||||||
|
|
||||||
|
#if defined(BARO) && defined(BARO_EOC_GPIO)
|
||||||
convDone = false;
|
convDone = false;
|
||||||
|
#endif
|
||||||
|
|
||||||
i2cWrite(BMP085_I2C_ADDR, BMP085_CTRL_MEAS_REG, ctrl_reg_data);
|
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];
|
uint8_t data[3];
|
||||||
|
|
||||||
|
#if defined(BARO) && defined(BARO_EOC_GPIO)
|
||||||
// wait in case of cockup
|
// wait in case of cockup
|
||||||
if (!convDone)
|
if (!convDone) {
|
||||||
convOverrun++;
|
convOverrun++;
|
||||||
|
return; // keep old value
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
i2cRead(BMP085_I2C_ADDR, BMP085_ADC_OUT_MSB_REG, 3, data);
|
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])
|
bmp085_up = (((uint32_t) data[0] << 16) | ((uint32_t) data[1] << 8) | (uint32_t) data[2])
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue