1
0
Fork 0
mirror of https://github.com/betaflight/betaflight.git synced 2025-07-25 17:25:20 +03:00

Baro fixes, cleanups and improvements.

* Add BARO debug mode.
* BMP085 - Fix EOC and XCLR initialisation.
* BMP085 - update previously dead code.
* BMP280 - Move t_fine out of the calibration data, since their usage is mixed.
* BMP280 - Move static_assert closer to definition.
This commit is contained in:
Dominic Clifton 2019-01-06 01:35:46 +01:00
parent 7cd030559d
commit eea9242d7b
7 changed files with 48 additions and 29 deletions

View file

@ -26,6 +26,8 @@
#ifdef USE_BARO
#include "build/debug.h"
#include "common/maths.h"
#include "pg/pg.h"
@ -102,7 +104,7 @@ void pgResetFn_barometerConfig(barometerConfig_t *barometerConfig)
barometerConfig->baro_spi_csn = IO_TAG(BARO_CS_PIN);
barometerConfig->baro_i2c_device = I2C_DEV_TO_CFG(I2CINVALID);
barometerConfig->baro_i2c_address = 0;
#elif defined(DEFAULT_BARO_MS5611) || defined(DEFAULT_BARO_BMP280) || defined(DEFAULT_BARO_BMP085)||defined(DEFAULT_BARO_QMP6988)
#elif defined(DEFAULT_BARO_MS5611) || defined(DEFAULT_BARO_BMP280) || defined(DEFAULT_BARO_BMP085) || defined(DEFAULT_BARO_QMP6988)
// All I2C devices shares a default config with address = 0 (per device default)
barometerConfig->baro_bustype = BUSTYPE_I2C;
barometerConfig->baro_i2c_device = I2C_DEV_TO_CFG(BARO_I2C_INSTANCE);
@ -183,7 +185,7 @@ bool baroDetect(baroDev_t *dev, baroSensor_e baroHardwareToUse)
{
const bmp085Config_t *bmp085Config = NULL;
#if defined(BARO_XCLR_GPIO) && defined(BARO_EOC_GPIO)
#if defined(BARO_XCLR_PIN) && defined(BARO_EOC_PIN)
static const bmp085Config_t defaultBMP085Config = {
.xclrIO = IO_TAG(BARO_XCLR_PIN),
.eocIO = IO_TAG(BARO_EOC_PIN),
@ -324,6 +326,10 @@ uint32_t baroUpdate(void)
{
static barometerState_e state = BAROMETER_NEEDS_SAMPLES;
if (debugMode == DEBUG_BARO) {
debug[0] = state;
}
switch (state) {
default:
case BAROMETER_NEEDS_SAMPLES:
@ -340,6 +346,13 @@ uint32_t baroUpdate(void)
baro.baroPressure = baroPressure;
baro.baroTemperature = baroTemperature;
baroPressureSum = recalculateBarometerTotal(barometerConfig()->baro_sample_count, baroPressureSum, baroPressure);
if (debugMode == DEBUG_BARO) {
debug[1] = baroTemperature;
debug[2] = baroPressure;
debug[3] = baroPressureSum;
}
state = BAROMETER_NEEDS_SAMPLES;
return baro.dev.ut_delay;
break;