mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-29 08:33:34 +08:00
drivers: use updated I2C SPI driver interface
This commit is contained in:
@@ -53,12 +53,11 @@ static constexpr uint8_t _checked_registers[] = {
|
||||
ADDR_CTRL_REG7
|
||||
};
|
||||
|
||||
LSM303D::LSM303D(I2CSPIBusOption bus_option, int bus, uint32_t device, enum Rotation rotation, int bus_frequency,
|
||||
spi_mode_e spi_mode) :
|
||||
SPI(DRV_IMU_DEVTYPE_LSM303D, MODULE_NAME, bus, device, spi_mode, bus_frequency),
|
||||
I2CSPIDriver(MODULE_NAME, px4::device_bus_to_wq(get_device_id()), bus_option, bus),
|
||||
_px4_accel(get_device_id(), rotation),
|
||||
_px4_mag(get_device_id(), rotation),
|
||||
LSM303D::LSM303D(const I2CSPIDriverConfig &config) :
|
||||
SPI(config),
|
||||
I2CSPIDriver(config),
|
||||
_px4_accel(get_device_id(), config.rotation),
|
||||
_px4_mag(get_device_id(), config.rotation),
|
||||
_accel_sample_perf(perf_alloc(PC_ELAPSED, "lsm303d: acc_read")),
|
||||
_mag_sample_perf(perf_alloc(PC_ELAPSED, "lsm303d: mag_read")),
|
||||
_bad_registers(perf_alloc(PC_COUNT, "lsm303d: bad_reg")),
|
||||
|
||||
@@ -141,12 +141,9 @@
|
||||
class LSM303D : public device::SPI, public I2CSPIDriver<LSM303D>
|
||||
{
|
||||
public:
|
||||
LSM303D(I2CSPIBusOption bus_option, int bus, uint32_t device, enum Rotation rotation, int bus_frequency,
|
||||
spi_mode_e spi_mode);
|
||||
LSM303D(const I2CSPIDriverConfig &config);
|
||||
~LSM303D() override;
|
||||
|
||||
static I2CSPIDriverBase *instantiate(const BusCLIArguments &cli, const BusInstanceIterator &iterator,
|
||||
int runtime_instance);
|
||||
static void print_usage();
|
||||
|
||||
void RunImpl();
|
||||
|
||||
@@ -52,25 +52,6 @@ LSM303D::print_usage()
|
||||
PRINT_MODULE_USAGE_DEFAULT_COMMANDS();
|
||||
}
|
||||
|
||||
I2CSPIDriverBase *LSM303D::instantiate(const BusCLIArguments &cli, const BusInstanceIterator &iterator,
|
||||
int runtime_instance)
|
||||
{
|
||||
LSM303D *instance = new LSM303D(iterator.configuredBusOption(), iterator.bus(), iterator.devid(), cli.rotation,
|
||||
cli.bus_frequency, cli.spi_mode);
|
||||
|
||||
if (!instance) {
|
||||
PX4_ERR("alloc failed");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (OK != instance->init()) {
|
||||
delete instance;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return instance;
|
||||
}
|
||||
|
||||
extern "C" int lsm303d_main(int argc, char *argv[])
|
||||
{
|
||||
int ch;
|
||||
|
||||
Reference in New Issue
Block a user