mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-22 06:23:34 +08:00
I2C/SPI require device type in constructor
This commit is contained in:
@@ -48,7 +48,7 @@
|
||||
extern "C" __EXPORT int ak09916_main(int argc, char *argv[]);
|
||||
|
||||
AK09916::AK09916(I2CSPIBusOption bus_option, const int bus, int bus_frequency, enum Rotation rotation) :
|
||||
I2C("AK09916", nullptr, bus, AK09916_I2C_ADDR, bus_frequency),
|
||||
I2C(DRV_MAG_DEVTYPE_AK09916, MODULE_NAME, bus, AK09916_I2C_ADDR, bus_frequency),
|
||||
I2CSPIDriver(MODULE_NAME, px4::device_bus_to_wq(get_device_id()), bus_option, bus),
|
||||
_px4_mag(get_device_id(), external() ? ORB_PRIO_VERY_HIGH : ORB_PRIO_DEFAULT, rotation),
|
||||
_mag_reads(perf_alloc(PC_COUNT, MODULE_NAME": mag_reads")),
|
||||
@@ -56,10 +56,7 @@ AK09916::AK09916(I2CSPIBusOption bus_option, const int bus, int bus_frequency, e
|
||||
_mag_overruns(perf_alloc(PC_COUNT, MODULE_NAME": mag_overruns")),
|
||||
_mag_overflows(perf_alloc(PC_COUNT, MODULE_NAME": mag_overflows"))
|
||||
{
|
||||
set_device_type(DRV_MAG_DEVTYPE_AK09916);
|
||||
_px4_mag.set_device_type(DRV_MAG_DEVTYPE_AK09916);
|
||||
_px4_mag.set_external(external());
|
||||
|
||||
_px4_mag.set_scale(AK09916_MAG_RANGE_GA);
|
||||
}
|
||||
|
||||
|
||||
@@ -41,7 +41,7 @@
|
||||
#include <px4_platform_common/module.h>
|
||||
|
||||
BMM150::BMM150(I2CSPIBusOption bus_option, const int bus, int bus_frequency, enum Rotation rotation) :
|
||||
I2C("BMM150", nullptr, bus, BMM150_SLAVE_ADDRESS, bus_frequency),
|
||||
I2C(DRV_MAG_DEVTYPE_BMM150, MODULE_NAME, bus, BMM150_SLAVE_ADDRESS, bus_frequency),
|
||||
I2CSPIDriver(MODULE_NAME, px4::device_bus_to_wq(get_device_id()), bus_option, bus),
|
||||
_px4_mag(get_device_id(), external() ? ORB_PRIO_VERY_HIGH : ORB_PRIO_DEFAULT, rotation),
|
||||
_call_interval(0),
|
||||
@@ -67,9 +67,6 @@ BMM150::BMM150(I2CSPIBusOption bus_option, const int bus, int bus_frequency, enu
|
||||
_duplicates(perf_alloc(PC_COUNT, MODULE_NAME": duplicates")),
|
||||
_got_duplicate(false)
|
||||
{
|
||||
set_device_type(DRV_MAG_DEVTYPE_BMM150);
|
||||
|
||||
_px4_mag.set_device_type(DRV_MAG_DEVTYPE_BMM150);
|
||||
_px4_mag.set_external(external());
|
||||
|
||||
// default range scale from from uT to gauss
|
||||
|
||||
@@ -48,8 +48,6 @@ HMC5883::HMC5883(device::Device *interface, enum Rotation rotation, I2CSPIBusOpt
|
||||
_temperature_counter(0),
|
||||
_temperature_error_count(0)
|
||||
{
|
||||
_interface->set_device_type(DRV_MAG_DEVTYPE_HMC5883);
|
||||
_px4_mag.set_device_type(DRV_MAG_DEVTYPE_HMC5883);
|
||||
_px4_mag.set_external(_interface->external());
|
||||
}
|
||||
|
||||
|
||||
@@ -68,9 +68,8 @@ HMC5883_I2C_interface(int bus, int bus_frequency)
|
||||
}
|
||||
|
||||
HMC5883_I2C::HMC5883_I2C(int bus, int bus_frequency) :
|
||||
I2C("HMC5883_I2C", nullptr, bus, HMC5883L_ADDRESS, bus_frequency)
|
||||
I2C(DRV_MAG_DEVTYPE_HMC5883, MODULE_NAME, bus, HMC5883L_ADDRESS, bus_frequency)
|
||||
{
|
||||
_device_id.devid_s.devtype = DRV_MAG_DEVTYPE_HMC5883;
|
||||
}
|
||||
|
||||
int HMC5883_I2C::probe()
|
||||
|
||||
@@ -72,9 +72,8 @@ HMC5883_SPI_interface(int bus, uint32_t devid, int bus_frequency, spi_mode_e spi
|
||||
}
|
||||
|
||||
HMC5883_SPI::HMC5883_SPI(int bus, uint32_t device, int bus_frequency, spi_mode_e spi_mode) :
|
||||
SPI("HMC5883_SPI", nullptr, bus, device, spi_mode, bus_frequency)
|
||||
SPI(DRV_MAG_DEVTYPE_HMC5883, MODULE_NAME, bus, device, spi_mode, bus_frequency)
|
||||
{
|
||||
_device_id.devid_s.devtype = DRV_MAG_DEVTYPE_HMC5883;
|
||||
}
|
||||
|
||||
int HMC5883_SPI::init()
|
||||
|
||||
@@ -41,13 +41,10 @@ static constexpr int16_t combine(uint8_t msb, uint8_t lsb)
|
||||
}
|
||||
|
||||
IST8308::IST8308(I2CSPIBusOption bus_option, int bus, enum Rotation rotation, int bus_frequency) :
|
||||
I2C(MODULE_NAME, nullptr, bus, I2C_ADDRESS_DEFAULT, bus_frequency),
|
||||
I2C(DRV_MAG_DEVTYPE_IST8308, MODULE_NAME, bus, I2C_ADDRESS_DEFAULT, bus_frequency),
|
||||
I2CSPIDriver(MODULE_NAME, px4::device_bus_to_wq(get_device_id()), bus_option, bus),
|
||||
_px4_mag(get_device_id(), external() ? ORB_PRIO_VERY_HIGH : ORB_PRIO_DEFAULT, rotation)
|
||||
{
|
||||
set_device_type(DRV_MAG_DEVTYPE_IST8308);
|
||||
|
||||
_px4_mag.set_device_type(DRV_MAG_DEVTYPE_IST8308);
|
||||
_px4_mag.set_external(external());
|
||||
}
|
||||
|
||||
|
||||
@@ -269,7 +269,7 @@ private:
|
||||
};
|
||||
|
||||
IST8310::IST8310(I2CSPIBusOption bus_option, int bus_number, int address, enum Rotation rotation, int bus_frequency) :
|
||||
I2C("IST8310", nullptr, bus_number, address, bus_frequency),
|
||||
I2C(DRV_MAG_DEVTYPE_IST8310, MODULE_NAME, bus_number, address, bus_frequency),
|
||||
I2CSPIDriver(MODULE_NAME, px4::device_bus_to_wq(get_device_id()), bus_option, bus_number, address),
|
||||
_px4_mag(get_device_id(), external() ? ORB_PRIO_VERY_HIGH : ORB_PRIO_DEFAULT, rotation),
|
||||
_sample_perf(perf_alloc(PC_ELAPSED, MODULE_NAME": read")),
|
||||
@@ -277,9 +277,6 @@ IST8310::IST8310(I2CSPIBusOption bus_option, int bus_number, int address, enum R
|
||||
_range_errors(perf_alloc(PC_COUNT, MODULE_NAME": rng_err")),
|
||||
_conf_errors(perf_alloc(PC_COUNT, MODULE_NAME": conf_err"))
|
||||
{
|
||||
set_device_type(DRV_MAG_DEVTYPE_IST8310);
|
||||
|
||||
_px4_mag.set_device_type(DRV_MAG_DEVTYPE_IST8310);
|
||||
_px4_mag.set_external(external());
|
||||
|
||||
// default range scale from counts to gauss
|
||||
|
||||
@@ -65,9 +65,6 @@ LIS3MDL::LIS3MDL(device::Device *interface, enum Rotation rotation, I2CSPIBusOpt
|
||||
_temperature_counter(0),
|
||||
_temperature_error_count(0)
|
||||
{
|
||||
_interface->set_device_type(DRV_MAG_DEVTYPE_IST8310);
|
||||
|
||||
_px4_mag.set_device_type(DRV_MAG_DEVTYPE_IST8310);
|
||||
_px4_mag.set_external(_interface->external());
|
||||
}
|
||||
|
||||
|
||||
@@ -81,9 +81,8 @@ LIS3MDL_I2C_interface(int bus, int bus_frequency)
|
||||
}
|
||||
|
||||
LIS3MDL_I2C::LIS3MDL_I2C(int bus, int bus_frequency) :
|
||||
I2C("LIS3MDL_I2C", nullptr, bus, LIS3MDLL_ADDRESS, bus_frequency)
|
||||
I2C(DRV_MAG_DEVTYPE_LIS3MDL, MODULE_NAME, bus, LIS3MDLL_ADDRESS, bus_frequency)
|
||||
{
|
||||
_device_id.devid_s.devtype = DRV_MAG_DEVTYPE_LIS3MDL;
|
||||
}
|
||||
|
||||
int LIS3MDL_I2C::probe()
|
||||
|
||||
@@ -81,9 +81,8 @@ LIS3MDL_SPI_interface(int bus, uint32_t devid, int bus_frequency, spi_mode_e spi
|
||||
}
|
||||
|
||||
LIS3MDL_SPI::LIS3MDL_SPI(int bus, uint32_t devid, int bus_frequency, spi_mode_e spi_mode) :
|
||||
SPI("LIS3MDL_SPI", nullptr, bus, devid, spi_mode, bus_frequency)
|
||||
SPI(DRV_MAG_DEVTYPE_LIS3MDL, MODULE_NAME, bus, devid, spi_mode, bus_frequency)
|
||||
{
|
||||
_device_id.devid_s.devtype = DRV_MAG_DEVTYPE_LIS3MDL;
|
||||
}
|
||||
|
||||
int
|
||||
|
||||
@@ -63,16 +63,13 @@ static constexpr uint8_t LSM303AGR_WHO_AM_I_M = 0x40;
|
||||
|
||||
LSM303AGR::LSM303AGR(I2CSPIBusOption bus_option, int bus, int device, enum Rotation rotation, int bus_frequency,
|
||||
spi_mode_e spi_mode) :
|
||||
SPI("LSM303AGR", nullptr, bus, device, spi_mode, bus_frequency),
|
||||
SPI(DRV_MAG_DEVTYPE_LSM303AGR, MODULE_NAME, bus, device, spi_mode, bus_frequency),
|
||||
I2CSPIDriver(MODULE_NAME, px4::device_bus_to_wq(get_device_id()), bus_option, bus),
|
||||
_px4_mag(get_device_id(), external() ? ORB_PRIO_VERY_HIGH : ORB_PRIO_DEFAULT, rotation),
|
||||
_mag_sample_perf(perf_alloc(PC_ELAPSED, MODULE_NAME": mag_read")),
|
||||
_bad_registers(perf_alloc(PC_COUNT, MODULE_NAME": bad_reg")),
|
||||
_bad_values(perf_alloc(PC_COUNT, MODULE_NAME": bad_val"))
|
||||
{
|
||||
set_device_type(DRV_MAG_DEVTYPE_LSM303AGR);
|
||||
|
||||
_px4_mag.set_device_type(DRV_MAG_DEVTYPE_LSM303AGR);
|
||||
_px4_mag.set_external(external());
|
||||
|
||||
_px4_mag.set_scale(1.5f / 1000.f); // 1.5 milligauss/LSB
|
||||
|
||||
@@ -42,13 +42,10 @@ static constexpr int16_t combine(uint8_t lsb, uint8_t msb) { return (msb << 8u)
|
||||
|
||||
LSM9DS1_MAG::LSM9DS1_MAG(I2CSPIBusOption bus_option, int bus, uint32_t device, enum Rotation rotation,
|
||||
int bus_frequency, spi_mode_e spi_mode) :
|
||||
SPI(MODULE_NAME, nullptr, bus, device, spi_mode, bus_frequency),
|
||||
SPI(DRV_MAG_DEVTYPE_ST_LSM9DS1_M, MODULE_NAME, bus, device, spi_mode, bus_frequency),
|
||||
I2CSPIDriver(MODULE_NAME, px4::device_bus_to_wq(get_device_id()), bus_option, bus),
|
||||
_px4_mag(get_device_id(), external() ? ORB_PRIO_VERY_HIGH : ORB_PRIO_DEFAULT, rotation)
|
||||
{
|
||||
set_device_type(DRV_MAG_DEVTYPE_ST_LSM9DS1_M);
|
||||
|
||||
_px4_mag.set_device_type(DRV_MAG_DEVTYPE_ST_LSM9DS1_M);
|
||||
_px4_mag.set_external(external());
|
||||
}
|
||||
|
||||
|
||||
@@ -47,9 +47,6 @@ QMC5883::QMC5883(device::Device *interface, enum Rotation rotation, I2CSPIBusOpt
|
||||
_temperature_counter(0),
|
||||
_temperature_error_count(0)
|
||||
{
|
||||
_interface->set_device_type(DRV_MAG_DEVTYPE_QMC5883);
|
||||
|
||||
_px4_mag.set_device_type(DRV_MAG_DEVTYPE_QMC5883);
|
||||
_px4_mag.set_external(_interface->external());
|
||||
}
|
||||
|
||||
|
||||
@@ -66,9 +66,8 @@ QMC5883_I2C_interface(int bus, int bus_frequency, int i2c_address)
|
||||
}
|
||||
|
||||
QMC5883_I2C::QMC5883_I2C(int bus, int bus_frequency, int i2c_address) :
|
||||
I2C("QMC5883_I2C", nullptr, bus, i2c_address, bus_frequency)
|
||||
I2C(DRV_MAG_DEVTYPE_QMC5883, MODULE_NAME, bus, i2c_address, bus_frequency)
|
||||
{
|
||||
_device_id.devid_s.devtype = DRV_MAG_DEVTYPE_QMC5883;
|
||||
}
|
||||
|
||||
int QMC5883_I2C::probe()
|
||||
|
||||
@@ -54,9 +54,6 @@ RM3100::RM3100(device::Device *interface, enum Rotation rotation, I2CSPIBusOptio
|
||||
_measure_interval(0),
|
||||
_check_state_cnt(0)
|
||||
{
|
||||
_interface->set_device_type(DRV_MAG_DEVTYPE_RM3100);
|
||||
|
||||
_px4_mag.set_device_type(DRV_MAG_DEVTYPE_RM3100);
|
||||
_px4_mag.set_external(_interface->external());
|
||||
|
||||
_px4_mag.set_scale(1.f / (RM3100_SENSITIVITY * UTESLA_TO_GAUSS));
|
||||
|
||||
@@ -80,9 +80,8 @@ RM3100_I2C_interface(int bus, int bus_frequency)
|
||||
}
|
||||
|
||||
RM3100_I2C::RM3100_I2C(int bus, int bus_frequency) :
|
||||
I2C("RM300_I2C", nullptr, bus, RM3100_ADDRESS, bus_frequency)
|
||||
I2C(DRV_MAG_DEVTYPE_RM3100, MODULE_NAME, bus, RM3100_ADDRESS, bus_frequency)
|
||||
{
|
||||
_device_id.devid_s.devtype = DRV_MAG_DEVTYPE_RM3100;
|
||||
}
|
||||
|
||||
int RM3100_I2C::probe()
|
||||
|
||||
@@ -80,9 +80,8 @@ RM3100_SPI_interface(int bus, uint32_t devid, int bus_frequency, spi_mode_e spi_
|
||||
}
|
||||
|
||||
RM3100_SPI::RM3100_SPI(int bus, uint32_t devid, int bus_frequency, spi_mode_e spi_mode) :
|
||||
SPI("RM3100_SPI", nullptr, bus, devid, spi_mode, bus_frequency)
|
||||
SPI(DRV_MAG_DEVTYPE_RM3100, MODULE_NAME, bus, devid, spi_mode, bus_frequency)
|
||||
{
|
||||
_device_id.devid_s.devtype = DRV_MAG_DEVTYPE_RM3100;
|
||||
}
|
||||
|
||||
int RM3100_SPI::init()
|
||||
|
||||
Reference in New Issue
Block a user