mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-20 03:23:35 +08:00
I2C/SPI require device type in constructor
This commit is contained in:
@@ -42,7 +42,6 @@ BMP280::BMP280(I2CSPIBusOption bus_option, int bus, bmp280::IBMP280 *interface)
|
||||
_measure_perf(perf_alloc(PC_ELAPSED, MODULE_NAME": measure")),
|
||||
_comms_errors(perf_alloc(PC_COUNT, MODULE_NAME": comms errors"))
|
||||
{
|
||||
_px4_baro.set_device_type(DRV_BARO_DEVTYPE_BMP280);
|
||||
}
|
||||
|
||||
BMP280::~BMP280()
|
||||
|
||||
@@ -71,7 +71,7 @@ bmp280::IBMP280 *bmp280_i2c_interface(uint8_t busnum, uint32_t device, int bus_f
|
||||
}
|
||||
|
||||
BMP280_I2C::BMP280_I2C(uint8_t bus, uint32_t device, int bus_frequency) :
|
||||
I2C("BMP280_I2C", nullptr, bus, device, bus_frequency)
|
||||
I2C(DRV_BARO_DEVTYPE_BMP280, MODULE_NAME, bus, device, bus_frequency)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -87,7 +87,7 @@ bmp280_spi_interface(uint8_t busnum, uint32_t device, int bus_frequency, spi_mod
|
||||
}
|
||||
|
||||
BMP280_SPI::BMP280_SPI(uint8_t bus, uint32_t device, int bus_frequency, spi_mode_e spi_mode) :
|
||||
SPI("BMP280_SPI", nullptr, bus, device, spi_mode, bus_frequency)
|
||||
SPI(DRV_BARO_DEVTYPE_BMP280, MODULE_NAME, bus, device, spi_mode, bus_frequency)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -50,7 +50,6 @@ BMP388::BMP388(I2CSPIBusOption bus_option, int bus, IBMP388 *interface) :
|
||||
_measure_perf(perf_alloc(PC_ELAPSED, MODULE_NAME": measure")),
|
||||
_comms_errors(perf_alloc(PC_COUNT, MODULE_NAME": comms errors"))
|
||||
{
|
||||
_px4_baro.set_device_type(DRV_BARO_DEVTYPE_BMP388);
|
||||
}
|
||||
|
||||
BMP388::~BMP388()
|
||||
|
||||
@@ -68,7 +68,7 @@ IBMP388 *bmp388_i2c_interface(uint8_t busnum, uint32_t device, int bus_frequency
|
||||
}
|
||||
|
||||
BMP388_I2C::BMP388_I2C(uint8_t bus, uint32_t device, int bus_frequency) :
|
||||
I2C("BMP388_I2C", nullptr, bus, device, bus_frequency)
|
||||
I2C(DRV_BARO_DEVTYPE_BMP388, MODULE_NAME, bus, device, bus_frequency)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -84,7 +84,7 @@ IBMP388 *bmp388_spi_interface(uint8_t busnum, uint32_t device, int bus_frequency
|
||||
}
|
||||
|
||||
BMP388_SPI::BMP388_SPI(uint8_t bus, uint32_t device, int bus_frequency, spi_mode_e spi_mode) :
|
||||
SPI("BMP388_SPI", nullptr, bus, device, spi_mode, bus_frequency)
|
||||
SPI(DRV_BARO_DEVTYPE_BMP388, MODULE_NAME, bus, device, spi_mode, bus_frequency)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -54,7 +54,6 @@ DPS310::DPS310(I2CSPIBusOption bus_option, int bus, device::Device *interface) :
|
||||
_sample_perf(perf_alloc(PC_ELAPSED, MODULE_NAME": read")),
|
||||
_comms_errors(perf_alloc(PC_COUNT, MODULE_NAME": comm errors"))
|
||||
{
|
||||
_px4_barometer.set_device_type(DRV_BARO_DEVTYPE_DPS310);
|
||||
}
|
||||
|
||||
DPS310::~DPS310()
|
||||
|
||||
@@ -62,7 +62,7 @@ DPS310_I2C_interface(uint8_t bus, uint32_t address, int bus_frequency)
|
||||
}
|
||||
|
||||
DPS310_I2C::DPS310_I2C(uint8_t bus, uint32_t address, int bus_frequency) :
|
||||
I2C("DPS310_I2C", nullptr, bus, address, bus_frequency)
|
||||
I2C(DRV_BARO_DEVTYPE_DPS310, MODULE_NAME, bus, address, bus_frequency)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -66,7 +66,7 @@ DPS310_SPI_interface(uint8_t bus, uint32_t device, int bus_frequency, spi_mode_e
|
||||
}
|
||||
|
||||
DPS310_SPI::DPS310_SPI(uint8_t bus, uint32_t device, int bus_frequency, spi_mode_e spi_mode) :
|
||||
SPI("DPS310_SPI", nullptr, bus, device, spi_mode, bus_frequency)
|
||||
SPI(DRV_BARO_DEVTYPE_DPS310, MODULE_NAME, bus, device, spi_mode, bus_frequency)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -46,11 +46,9 @@ LPS22HB::LPS22HB(I2CSPIBusOption bus_option, int bus, device::Device *interface)
|
||||
CDev(nullptr),
|
||||
I2CSPIDriver(MODULE_NAME, px4::device_bus_to_wq(interface->get_device_id()), bus_option, bus),
|
||||
_interface(interface),
|
||||
_sample_perf(perf_alloc(PC_ELAPSED, "lps22hb_read")),
|
||||
_comms_errors(perf_alloc(PC_COUNT, "lps22hb_comms_errors"))
|
||||
_sample_perf(perf_alloc(PC_ELAPSED, MODULE_NAME": read")),
|
||||
_comms_errors(perf_alloc(PC_COUNT, MODULE_NAME": comms_errors"))
|
||||
{
|
||||
// set the interface device type
|
||||
_interface->set_device_type(DRV_BARO_DEVTYPE_LPS22HB);
|
||||
}
|
||||
|
||||
LPS22HB::~LPS22HB()
|
||||
|
||||
@@ -64,7 +64,7 @@ LPS22HB_I2C_interface(int bus, int bus_frequency)
|
||||
}
|
||||
|
||||
LPS22HB_I2C::LPS22HB_I2C(int bus, int bus_frequency) :
|
||||
I2C("LPS22HB_I2C", nullptr, bus, LPS22HB_ADDRESS, bus_frequency)
|
||||
I2C(DRV_BARO_DEVTYPE_LPS22HB, MODULE_NAME, bus, LPS22HB_ADDRESS, bus_frequency)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -64,9 +64,8 @@ LPS22HB_SPI_interface(int bus, uint32_t devid, int bus_frequency, spi_mode_e spi
|
||||
}
|
||||
|
||||
LPS22HB_SPI::LPS22HB_SPI(int bus, uint32_t device, int bus_frequency, spi_mode_e spi_mode)
|
||||
: SPI("LPS22HB_SPI", nullptr, bus, device, spi_mode, bus_frequency)
|
||||
: SPI(DRV_BARO_DEVTYPE_LPS22HB, MODULE_NAME, bus, device, spi_mode, bus_frequency)
|
||||
{
|
||||
_device_id.devid_s.devtype = DRV_BARO_DEVTYPE_LPS22HB;
|
||||
}
|
||||
|
||||
int
|
||||
|
||||
@@ -40,8 +40,6 @@ LPS25H::LPS25H(I2CSPIBusOption bus_option, int bus, device::Device *interface) :
|
||||
_sample_perf(perf_alloc(PC_ELAPSED, MODULE_NAME": read")),
|
||||
_comms_errors(perf_alloc(PC_COUNT, MODULE_NAME": comms_errors"))
|
||||
{
|
||||
_interface->set_device_type(DRV_BARO_DEVTYPE_LPS25H);
|
||||
_px4_barometer.set_device_type(DRV_BARO_DEVTYPE_LPS25H);
|
||||
}
|
||||
|
||||
LPS25H::~LPS25H()
|
||||
|
||||
@@ -65,9 +65,8 @@ device::Device *LPS25H_I2C_interface(int bus, int bus_frequency)
|
||||
}
|
||||
|
||||
LPS25H_I2C::LPS25H_I2C(int bus, int bus_frequency) :
|
||||
I2C("LPS25H_I2C", nullptr, bus, LPS25H_ADDRESS, bus_frequency)
|
||||
I2C(DRV_BARO_DEVTYPE_LPS25H, MODULE_NAME, bus, LPS25H_ADDRESS, bus_frequency)
|
||||
{
|
||||
set_device_type(DRV_BARO_DEVTYPE_LPS25H);
|
||||
}
|
||||
|
||||
int LPS25H_I2C::probe()
|
||||
|
||||
@@ -65,9 +65,8 @@ device::Device *LPS25H_SPI_interface(int bus, uint32_t devid, int bus_frequency,
|
||||
}
|
||||
|
||||
LPS25H_SPI::LPS25H_SPI(int bus, uint32_t device, int bus_frequency, spi_mode_e spi_mode) :
|
||||
SPI("LPS25H_SPI", nullptr, bus, device, spi_mode, bus_frequency)
|
||||
SPI(DRV_BARO_DEVTYPE_LPS25H, MODULE_NAME, bus, device, spi_mode, bus_frequency)
|
||||
{
|
||||
set_device_type(DRV_BARO_DEVTYPE_LPS25H);
|
||||
}
|
||||
|
||||
int LPS25H_SPI::init()
|
||||
|
||||
@@ -55,15 +55,13 @@
|
||||
#define MPL3115A2_CTRL_TRIGGER (CTRL_REG1_OST | CTRL_REG1_OS(MPL3115A2_OSR))
|
||||
|
||||
MPL3115A2::MPL3115A2(I2CSPIBusOption bus_option, const int bus, int bus_frequency) :
|
||||
I2C("MPL3115A2", nullptr, bus, MPL3115A2_ADDRESS, bus_frequency),
|
||||
I2C(DRV_BARO_DEVTYPE_MPL3115A2, MODULE_NAME, bus, MPL3115A2_ADDRESS, bus_frequency),
|
||||
I2CSPIDriver(MODULE_NAME, px4::device_bus_to_wq(get_device_id()), bus_option, bus),
|
||||
_px4_barometer(get_device_id()),
|
||||
_sample_perf(perf_alloc(PC_ELAPSED, MODULE_NAME": read")),
|
||||
_measure_perf(perf_alloc(PC_ELAPSED, MODULE_NAME": measure")),
|
||||
_comms_errors(perf_alloc(PC_COUNT, MODULE_NAME": com_err"))
|
||||
{
|
||||
set_device_type(DRV_BARO_DEVTYPE_MPL3115A2);
|
||||
_px4_barometer.set_device_type(DRV_BARO_DEVTYPE_MPL3115A2);
|
||||
}
|
||||
|
||||
MPL3115A2::~MPL3115A2()
|
||||
|
||||
@@ -91,7 +91,7 @@ MS5611_i2c_interface(ms5611::prom_u &prom_buf, uint32_t devid, uint8_t busnum, i
|
||||
}
|
||||
|
||||
MS5611_I2C::MS5611_I2C(uint8_t bus, ms5611::prom_u &prom, int bus_frequency) :
|
||||
I2C("MS5611_I2C", nullptr, bus, 0, bus_frequency),
|
||||
I2C(DRV_BARO_DEVTYPE_MS5611, MODULE_NAME, bus, 0, bus_frequency),
|
||||
_prom(prom)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -103,7 +103,7 @@ MS5611_spi_interface(ms5611::prom_u &prom_buf, uint32_t devid, uint8_t busnum, i
|
||||
}
|
||||
|
||||
MS5611_SPI::MS5611_SPI(uint8_t bus, uint32_t device, ms5611::prom_u &prom_buf, int bus_frequency, spi_mode_e spi_mode) :
|
||||
SPI("MS5611_SPI", nullptr, bus, device, spi_mode, bus_frequency),
|
||||
SPI(DRV_BARO_DEVTYPE_MS5611, MODULE_NAME, bus, device, spi_mode, bus_frequency),
|
||||
_prom(prom_buf)
|
||||
{
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user