forked from Archive/PX4-Autopilot
mpu6000: remove unnecessary CDev
This commit is contained in:
parent
76bdeca263
commit
a69e6b92c9
|
@ -39,8 +39,7 @@
|
|||
*/
|
||||
constexpr uint8_t MPU6000::_checked_registers[MPU6000_NUM_CHECKED_REGISTERS];
|
||||
|
||||
MPU6000::MPU6000(device::Device *interface, const char *path, enum Rotation rotation, int device_type) :
|
||||
CDev(path),
|
||||
MPU6000::MPU6000(device::Device *interface, enum Rotation rotation, int device_type) :
|
||||
ScheduledWorkItem(MODULE_NAME, px4::device_bus_to_wq(interface->get_device_id())),
|
||||
_interface(interface),
|
||||
_device_type(device_type),
|
||||
|
@ -97,16 +96,7 @@ MPU6000::init()
|
|||
|
||||
/* if probe failed, bail now */
|
||||
if (ret != OK) {
|
||||
PX4_DEBUG("CDev init failed");
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* do init */
|
||||
ret = CDev::init();
|
||||
|
||||
/* if init failed, bail now */
|
||||
if (ret != OK) {
|
||||
PX4_DEBUG("CDev init failed");
|
||||
PX4_DEBUG("probe init failed");
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
|
|
@ -98,25 +98,6 @@ enum MPU_DEVICE_TYPE {
|
|||
#define DIR_READ 0x80
|
||||
#define DIR_WRITE 0x00
|
||||
|
||||
#define MPU_DEVICE_PATH "/dev/mpu6000"
|
||||
#define MPU_DEVICE_PATH1 "/dev/mpu6000_1"
|
||||
#define MPU_DEVICE_PATH_EXT "/dev/mpu6000_ext"
|
||||
#define MPU_DEVICE_PATH_EXT1 "/dev/mpu6000_ext1"
|
||||
#define MPU_DEVICE_PATH_EXT2 "/dev/mpu6000_ext2"
|
||||
|
||||
|
||||
#define ICM20602_DEVICE_PATH "/dev/icm20602"
|
||||
#define ICM20602_DEVICE_PATH1 "/dev/icm20602_1"
|
||||
#define ICM20602_DEVICE_PATH_EXT "/dev/icm20602_ext"
|
||||
#define ICM20602_DEVICE_PATH_EXT1 "/dev/icm20602_ext1"
|
||||
|
||||
#define ICM20608_DEVICE_PATH "/dev/icm20608"
|
||||
#define ICM20608_DEVICE_PATH1 "/dev/icm20608_1"
|
||||
#define ICM20608_DEVICE_PATH_EXT "/dev/icm20608_ext"
|
||||
#define ICM20608_DEVICE_PATH_EXT1 "/dev/icm20608_ext1"
|
||||
|
||||
#define ICM20689_DEVICE_PATH "/dev/icm20689"
|
||||
|
||||
// MPU 6000 registers
|
||||
#define MPUREG_WHOAMI 0x75
|
||||
#define MPUREG_SMPLRT_DIV 0x19
|
||||
|
@ -301,10 +282,10 @@ enum MPU6000_BUS {
|
|||
MPU6000_BUS_SPI_EXTERNAL2
|
||||
};
|
||||
|
||||
class MPU6000 : public cdev::CDev, public px4::ScheduledWorkItem
|
||||
class MPU6000 : public px4::ScheduledWorkItem
|
||||
{
|
||||
public:
|
||||
MPU6000(device::Device *interface, const char *path, enum Rotation rotation, int device_type);
|
||||
MPU6000(device::Device *interface, enum Rotation rotation, int device_type);
|
||||
|
||||
virtual ~MPU6000();
|
||||
|
||||
|
|
|
@ -46,7 +46,6 @@ namespace mpu6000
|
|||
struct mpu6000_bus_option {
|
||||
enum MPU6000_BUS busid;
|
||||
MPU_DEVICE_TYPE device_type;
|
||||
const char *devpath;
|
||||
MPU6000_constructor interface_constructor;
|
||||
uint8_t busnum;
|
||||
bool external;
|
||||
|
@ -54,42 +53,42 @@ struct mpu6000_bus_option {
|
|||
} bus_options[] = {
|
||||
#if defined (USE_I2C)
|
||||
# if defined(PX4_I2C_BUS_ONBOARD)
|
||||
{ MPU6000_BUS_I2C_INTERNAL, MPU_DEVICE_TYPE_MPU6000, MPU_DEVICE_PATH, &MPU6000_I2C_interface, PX4_I2C_BUS_ONBOARD, false, NULL },
|
||||
{ MPU6000_BUS_I2C_INTERNAL, MPU_DEVICE_TYPE_MPU6000, &MPU6000_I2C_interface, PX4_I2C_BUS_ONBOARD, false, NULL },
|
||||
# endif
|
||||
# if defined(PX4_I2C_BUS_EXPANSION)
|
||||
{ MPU6000_BUS_I2C_EXTERNAL, MPU_DEVICE_TYPE_MPU6000, MPU_DEVICE_PATH_EXT, &MPU6000_I2C_interface, PX4_I2C_BUS_EXPANSION, true, NULL },
|
||||
{ MPU6000_BUS_I2C_EXTERNAL, MPU_DEVICE_TYPE_MPU6000, &MPU6000_I2C_interface, PX4_I2C_BUS_EXPANSION, true, NULL },
|
||||
# endif
|
||||
# if defined(PX4_I2C_BUS_EXPANSION1)
|
||||
{ MPU6000_BUS_I2C_EXTERNAL, MPU_DEVICE_TYPE_MPU6000, MPU_DEVICE_PATH_EXT1, &MPU6000_I2C_interface, PX4_I2C_BUS_EXPANSION1, true, NULL },
|
||||
{ MPU6000_BUS_I2C_EXTERNAL, MPU_DEVICE_TYPE_MPU6000, &MPU6000_I2C_interface, PX4_I2C_BUS_EXPANSION1, true, NULL },
|
||||
# endif
|
||||
# if defined(PX4_I2C_BUS_EXPANSION2)
|
||||
{ MPU6000_BUS_I2C_EXTERNAL, MPU_DEVICE_TYPE_MPU6000, MPU_DEVICE_PATH_EXT2, &MPU6000_I2C_interface, PX4_I2C_BUS_EXPANSION2, true, NULL },
|
||||
{ MPU6000_BUS_I2C_EXTERNAL, MPU_DEVICE_TYPE_MPU6000, &MPU6000_I2C_interface, PX4_I2C_BUS_EXPANSION2, true, NULL },
|
||||
# endif
|
||||
#endif
|
||||
#ifdef PX4_SPIDEV_MPU
|
||||
{ MPU6000_BUS_SPI_INTERNAL1, MPU_DEVICE_TYPE_MPU6000, MPU_DEVICE_PATH, &MPU6000_SPI_interface, PX4_SPI_BUS_SENSORS, false, NULL },
|
||||
{ MPU6000_BUS_SPI_INTERNAL1, MPU_DEVICE_TYPE_MPU6000, &MPU6000_SPI_interface, PX4_SPI_BUS_SENSORS, false, NULL },
|
||||
#endif
|
||||
#if defined(PX4_SPI_BUS_EXT)
|
||||
{ MPU6000_BUS_SPI_EXTERNAL1, MPU_DEVICE_TYPE_MPU6000, MPU_DEVICE_PATH_EXT, &MPU6000_SPI_interface, PX4_SPI_BUS_EXT, true, NULL },
|
||||
{ MPU6000_BUS_SPI_EXTERNAL1, MPU_DEVICE_TYPE_MPU6000, &MPU6000_SPI_interface, PX4_SPI_BUS_EXT, true, NULL },
|
||||
#endif
|
||||
#if defined(PX4_SPIDEV_ICM_20602) && defined(PX4_SPI_BUS_SENSORS)
|
||||
{ MPU6000_BUS_SPI_INTERNAL1, MPU_DEVICE_TYPE_ICM20602, ICM20602_DEVICE_PATH, &MPU6000_SPI_interface, PX4_SPI_BUS_SENSORS, false, NULL },
|
||||
{ MPU6000_BUS_SPI_INTERNAL1, MPU_DEVICE_TYPE_ICM20602, &MPU6000_SPI_interface, PX4_SPI_BUS_SENSORS, false, NULL },
|
||||
#endif
|
||||
#if defined(PX4_SPIDEV_ICM_20602) && defined(PX4_SPI_BUS_SENSORS1)
|
||||
{ MPU6000_BUS_SPI_INTERNAL1, MPU_DEVICE_TYPE_ICM20602, ICM20602_DEVICE_PATH, &MPU6000_SPI_interface, PX4_SPI_BUS_SENSORS1, false, NULL },
|
||||
{ MPU6000_BUS_SPI_INTERNAL1, MPU_DEVICE_TYPE_ICM20602, &MPU6000_SPI_interface, PX4_SPI_BUS_SENSORS1, false, NULL },
|
||||
#endif
|
||||
#if defined(PX4_SPIDEV_ICM_20602) && defined(PX4_SPI_BUS_1)
|
||||
{ MPU6000_BUS_SPI_INTERNAL1, MPU_DEVICE_TYPE_ICM20602, ICM20602_DEVICE_PATH, &MPU6000_SPI_interface, PX4_SPI_BUS_1, false, NULL },
|
||||
{ MPU6000_BUS_SPI_INTERNAL1, MPU_DEVICE_TYPE_ICM20602, &MPU6000_SPI_interface, PX4_SPI_BUS_1, false, NULL },
|
||||
#endif
|
||||
#ifdef PX4_SPIDEV_ICM_20608
|
||||
{ MPU6000_BUS_SPI_INTERNAL1, MPU_DEVICE_TYPE_ICM20608, ICM20608_DEVICE_PATH, &MPU6000_SPI_interface, PX4_SPI_BUS_SENSORS, false, NULL },
|
||||
{ MPU6000_BUS_SPI_INTERNAL1, MPU_DEVICE_TYPE_ICM20608, &MPU6000_SPI_interface, PX4_SPI_BUS_SENSORS, false, NULL },
|
||||
#endif
|
||||
#ifdef PX4_SPIDEV_ICM_20689
|
||||
{ MPU6000_BUS_SPI_INTERNAL2, MPU_DEVICE_TYPE_ICM20689, ICM20689_DEVICE_PATH, &MPU6000_SPI_interface, PX4_SPI_BUS_SENSORS, false, NULL },
|
||||
{ MPU6000_BUS_SPI_INTERNAL2, MPU_DEVICE_TYPE_ICM20689, &MPU6000_SPI_interface, PX4_SPI_BUS_SENSORS, false, NULL },
|
||||
#endif
|
||||
#if defined(PX4_SPI_BUS_EXTERNAL)
|
||||
{ MPU6000_BUS_SPI_EXTERNAL1, MPU_DEVICE_TYPE_MPU6000, MPU_DEVICE_PATH_EXT, &MPU6000_SPI_interface, PX4_SPI_BUS_EXTERNAL, true, NULL },
|
||||
{ MPU6000_BUS_SPI_EXTERNAL2, MPU_DEVICE_TYPE_MPU6000, MPU_DEVICE_PATH_EXT1, &MPU6000_SPI_interface, PX4_SPI_BUS_EXTERNAL, true, NULL },
|
||||
{ MPU6000_BUS_SPI_EXTERNAL1, MPU_DEVICE_TYPE_MPU6000, &MPU6000_SPI_interface, PX4_SPI_BUS_EXTERNAL, true, NULL },
|
||||
{ MPU6000_BUS_SPI_EXTERNAL2, MPU_DEVICE_TYPE_MPU6000, &MPU6000_SPI_interface, PX4_SPI_BUS_EXTERNAL, true, NULL },
|
||||
#endif
|
||||
};
|
||||
|
||||
|
@ -148,7 +147,7 @@ start_bus(struct mpu6000_bus_option &bus, enum Rotation rotation, int device_typ
|
|||
return false;
|
||||
}
|
||||
|
||||
bus.dev = new MPU6000(interface, bus.devpath, rotation, device_type);
|
||||
bus.dev = new MPU6000(interface, rotation, device_type);
|
||||
|
||||
if (bus.dev == nullptr) {
|
||||
delete interface;
|
||||
|
|
Loading…
Reference in New Issue