mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-25 17:25:20 +03:00
Add barometer sensor QMP6988
This commit is contained in:
parent
46291a8374
commit
495cfb4d07
6 changed files with 391 additions and 6 deletions
|
@ -33,6 +33,7 @@
|
|||
#include "drivers/barometer/barometer.h"
|
||||
#include "drivers/barometer/barometer_bmp085.h"
|
||||
#include "drivers/barometer/barometer_bmp280.h"
|
||||
#include "drivers/barometer/barometer_qmp6988.h"
|
||||
#include "drivers/barometer/barometer_fake.h"
|
||||
#include "drivers/barometer/barometer_ms5611.h"
|
||||
#include "drivers/barometer/barometer_lps.h"
|
||||
|
@ -65,7 +66,7 @@ void pgResetFn_barometerConfig(barometerConfig_t *barometerConfig)
|
|||
// a. Precedence is in the order of popularity; BMP280, MS5611 then BMP085, then
|
||||
// b. If SPI variant is specified, it is likely onboard, so take it.
|
||||
|
||||
#if !(defined(DEFAULT_BARO_SPI_BMP280) || defined(DEFAULT_BARO_BMP280) || defined(DEFAULT_BARO_SPI_MS5611) || defined(DEFAULT_BARO_MS5611) || defined(DEFAULT_BARO_BMP085) || defined(DEFAULT_BARO_SPI_LPS))
|
||||
#if !(defined(DEFAULT_BARO_SPI_BMP280) || defined(DEFAULT_BARO_BMP280) || defined(DEFAULT_BARO_SPI_MS5611) || defined(DEFAULT_BARO_MS5611) || defined(DEFAULT_BARO_BMP085) || defined(DEFAULT_BARO_SPI_LPS) || defined(DEFAULT_BARO_SPI_QMP6988) || defined(DEFAULT_BARO_QMP6988))
|
||||
#if defined(USE_BARO_BMP280) || defined(USE_BARO_SPI_BMP280)
|
||||
#if defined(USE_BARO_SPI_BMP280)
|
||||
#define DEFAULT_BARO_SPI_BMP280
|
||||
|
@ -78,6 +79,12 @@ void pgResetFn_barometerConfig(barometerConfig_t *barometerConfig)
|
|||
#else
|
||||
#define DEFAULT_BARO_MS5611
|
||||
#endif
|
||||
#elif defined(USE_BARO_QMP6988) || defined(USE_BARO_SPI_QMP6988)
|
||||
#if defined(USE_BARO_SPI_QMP6988)
|
||||
#define DEFAULT_BARO_SPI_QMP6988
|
||||
#else
|
||||
#define DEFAULT_BARO_QMP6988
|
||||
#endif
|
||||
#elif defined(USE_BARO_SPI_LPS)
|
||||
#define DEFAULT_BARO_SPI_LPS
|
||||
#elif defined(DEFAULT_BARO_BMP085)
|
||||
|
@ -97,13 +104,19 @@ void pgResetFn_barometerConfig(barometerConfig_t *barometerConfig)
|
|||
barometerConfig->baro_spi_csn = IO_TAG(MS5611_CS_PIN);
|
||||
barometerConfig->baro_i2c_device = I2C_DEV_TO_CFG(I2CINVALID);
|
||||
barometerConfig->baro_i2c_address = 0;
|
||||
#elif defined(DEFAULT_BARO_SPI_QMP6988)
|
||||
barometerConfig->baro_bustype = BUSTYPE_SPI;
|
||||
barometerConfig->baro_spi_device = SPI_DEV_TO_CFG(spiDeviceByInstance(QMP6988_SPI_INSTANCE));
|
||||
barometerConfig->baro_spi_csn = IO_TAG(QMP6988_CS_PIN);
|
||||
barometerConfig->baro_i2c_device = I2C_DEV_TO_CFG(I2CINVALID);
|
||||
barometerConfig->baro_i2c_address = 0;
|
||||
#elif defined(DEFAULT_BARO_SPI_LPS)
|
||||
barometerConfig->baro_bustype = BUSTYPE_SPI;
|
||||
barometerConfig->baro_spi_device = SPI_DEV_TO_CFG(spiDeviceByInstance(LPS_SPI_INSTANCE));
|
||||
barometerConfig->baro_spi_csn = IO_TAG(LPS_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)
|
||||
#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);
|
||||
|
@ -136,7 +149,7 @@ bool baroDetect(baroDev_t *dev, baroSensor_e baroHardwareToUse)
|
|||
|
||||
baroSensor_e baroHardware = baroHardwareToUse;
|
||||
|
||||
#if !defined(USE_BARO_BMP085) && !defined(USE_BARO_MS5611) && !defined(USE_BARO_SPI_MS5611) && !defined(USE_BARO_BMP280) && !defined(USE_BARO_SPI_BMP280)
|
||||
#if !defined(USE_BARO_BMP085) && !defined(USE_BARO_MS5611) && !defined(USE_BARO_SPI_MS5611) && !defined(USE_BARO_BMP280) && !defined(USE_BARO_SPI_BMP280)&& !defined(USE_BARO_QMP6988) && !defined(USE_BARO_SPI_QMP6988)
|
||||
UNUSED(dev);
|
||||
#endif
|
||||
|
||||
|
@ -212,7 +225,15 @@ bool baroDetect(baroDev_t *dev, baroSensor_e baroHardwareToUse)
|
|||
}
|
||||
#endif
|
||||
FALLTHROUGH;
|
||||
|
||||
|
||||
case BARO_QMP6988:
|
||||
#if defined(USE_BARO_QMP6988) || defined(USE_BARO_SPI_QMP6988)
|
||||
if (qmp6988Detect(dev)) {
|
||||
baroHardware = BARO_QMP6988;
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
FALLTHROUGH;
|
||||
case BARO_NONE:
|
||||
baroHardware = BARO_NONE;
|
||||
break;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue