mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-25 17:25:20 +03:00
Add LPS25HB driver
This commit is contained in:
parent
172c1e370b
commit
efc556f91a
7 changed files with 301 additions and 3 deletions
|
@ -35,6 +35,7 @@
|
|||
#include "drivers/barometer/barometer_bmp280.h"
|
||||
#include "drivers/barometer/barometer_fake.h"
|
||||
#include "drivers/barometer/barometer_ms5611.h"
|
||||
#include "drivers/barometer/barometer_lps.h"
|
||||
|
||||
#include "fc/runtime_config.h"
|
||||
|
||||
|
@ -64,7 +65,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))
|
||||
#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_LPS))
|
||||
#if defined(USE_BARO_BMP280) || defined(USE_BARO_SPI_BMP280)
|
||||
#if defined(USE_BARO_SPI_BMP280)
|
||||
#define DEFAULT_BARO_SPI_BMP280
|
||||
|
@ -77,6 +78,8 @@ void pgResetFn_barometerConfig(barometerConfig_t *barometerConfig)
|
|||
#else
|
||||
#define DEFAULT_BARO_MS5611
|
||||
#endif
|
||||
#elif defined(USE_BARO_LPS)
|
||||
#define DEFAULT_BARO_SPI_LPS
|
||||
#elif defined(DEFAULT_BARO_BMP085)
|
||||
#define DEFAULT_BARO_BMP085
|
||||
#endif
|
||||
|
@ -94,6 +97,12 @@ 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_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)
|
||||
// All I2C devices shares a default config with address = 0 (per device default)
|
||||
barometerConfig->baro_bustype = BUSTYPE_I2C;
|
||||
|
@ -186,6 +195,15 @@ bool baroDetect(baroDev_t *dev, baroSensor_e baroHardwareToUse)
|
|||
#endif
|
||||
FALLTHROUGH;
|
||||
|
||||
case BARO_LPS:
|
||||
#if defined(USE_BARO_LPS)
|
||||
if (lpsDetect(dev)) {
|
||||
baroHardware = BARO_LPS;
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
FALLTHROUGH;
|
||||
|
||||
case BARO_BMP280:
|
||||
#if defined(USE_BARO_BMP280) || defined(USE_BARO_SPI_BMP280)
|
||||
if (bmp280Detect(dev)) {
|
||||
|
|
|
@ -25,7 +25,8 @@ typedef enum {
|
|||
BARO_NONE = 1,
|
||||
BARO_BMP085 = 2,
|
||||
BARO_MS5611 = 3,
|
||||
BARO_BMP280 = 4
|
||||
BARO_BMP280 = 4,
|
||||
BARO_LPS = 5
|
||||
} baroSensor_e;
|
||||
|
||||
#define BARO_SAMPLE_COUNT_MAX 48
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue