AP_Baro: BMP390

This commit is contained in:
alexklimaj 2022-10-03 16:02:00 -06:00 committed by Randy Mackay
parent a5b13043bf
commit ca54c9f5e8
3 changed files with 16 additions and 4 deletions

View File

@ -121,6 +121,7 @@ baro_types = {
0x11 : "DEVTYPE_BARO_MS5607", 0x11 : "DEVTYPE_BARO_MS5607",
0x12 : "DEVTYPE_BARO_MS5837", 0x12 : "DEVTYPE_BARO_MS5837",
0x13 : "DEVTYPE_BARO_MS5637", 0x13 : "DEVTYPE_BARO_MS5637",
0x14 : "DEVTYPE_BARO_BMP390",
} }
airspeed_types = { airspeed_types = {

View File

@ -26,8 +26,10 @@ extern const AP_HAL::HAL &hal;
#define BMP388_MODE BMP388_MODE_NORMAL #define BMP388_MODE BMP388_MODE_NORMAL
#define BMP388_ID 0x50 #define BMP388_ID 0x50
#define BMP390_ID 0x60
#define BMP388_REG_ID 0x00 #define BMP388_REG_ID 0x00
#define BMP388_REV_ID_ADDR 0x01
#define BMP388_REG_ERR 0x02 #define BMP388_REG_ERR 0x02
#define BMP388_REG_STATUS 0x03 #define BMP388_REG_STATUS 0x03
#define BMP388_REG_PRESS 0x04 // 24 bit #define BMP388_REG_PRESS 0x04 // 24 bit
@ -89,9 +91,18 @@ bool AP_Baro_BMP388::init()
dev->write_register(BMP388_REG_PWR_CTRL, 0x33, true); dev->write_register(BMP388_REG_PWR_CTRL, 0x33, true);
uint8_t whoami; uint8_t whoami;
if (!read_registers(BMP388_REG_ID, &whoami, 1) || if (!read_registers(BMP388_REG_ID, &whoami, 1)) {
whoami != BMP388_ID) { return false;
// not a BMP388 }
switch (whoami) {
case BMP388_ID:
dev->set_device_type(DEVTYPE_BARO_BMP388);
break;
case BMP390_ID:
dev->set_device_type(DEVTYPE_BARO_BMP390);
break;
default:
return false; return false;
} }
@ -108,7 +119,6 @@ bool AP_Baro_BMP388::init()
instance = _frontend.register_sensor(); instance = _frontend.register_sensor();
dev->set_device_type(DEVTYPE_BARO_BMP388);
set_bus_id(instance, dev->get_bus_id()); set_bus_id(instance, dev->get_bus_id());
// request 50Hz update // request 50Hz update

View File

@ -61,6 +61,7 @@ public:
DEVTYPE_BARO_MS5607 = 0x11, DEVTYPE_BARO_MS5607 = 0x11,
DEVTYPE_BARO_MS5837 = 0x12, DEVTYPE_BARO_MS5837 = 0x12,
DEVTYPE_BARO_MS5637 = 0x13, DEVTYPE_BARO_MS5637 = 0x13,
DEVTYPE_BARO_BMP390 = 0x14,
}; };
protected: protected: