mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-23 16:23:34 +08:00
rm3100: move to PX4Magnetometer and cleanup
This commit is contained in:
@@ -48,8 +48,6 @@
|
||||
#include <sys/types.h>
|
||||
#include <unistd.h>
|
||||
|
||||
|
||||
|
||||
#include <drivers/device/i2c.h>
|
||||
#include <drivers/drv_mag.h>
|
||||
#include <drivers/drv_device.h>
|
||||
@@ -63,16 +61,13 @@ class RM3100_I2C : public device::I2C
|
||||
{
|
||||
public:
|
||||
RM3100_I2C(int bus, int bus_frequency);
|
||||
virtual ~RM3100_I2C() = default;
|
||||
~RM3100_I2C() override = default;
|
||||
|
||||
virtual int init();
|
||||
virtual int ioctl(unsigned operation, unsigned &arg);
|
||||
virtual int read(unsigned address, void *data, unsigned count);
|
||||
virtual int write(unsigned address, void *data, unsigned count);
|
||||
int read(unsigned address, void *data, unsigned count) override;
|
||||
int write(unsigned address, void *data, unsigned count) override;
|
||||
|
||||
protected:
|
||||
virtual int probe();
|
||||
|
||||
int probe() override;
|
||||
};
|
||||
|
||||
device::Device *
|
||||
@@ -90,31 +85,7 @@ RM3100_I2C::RM3100_I2C(int bus, int bus_frequency) :
|
||||
_device_id.devid_s.devtype = DRV_MAG_DEVTYPE_RM3100;
|
||||
}
|
||||
|
||||
int
|
||||
RM3100_I2C::init()
|
||||
{
|
||||
/* this will call probe() */
|
||||
return I2C::init();
|
||||
}
|
||||
|
||||
int
|
||||
RM3100_I2C::ioctl(unsigned operation, unsigned &arg)
|
||||
{
|
||||
switch (operation) {
|
||||
|
||||
case MAGIOCGEXTERNAL:
|
||||
return external();
|
||||
|
||||
case DEVIOCGDEVICEID:
|
||||
return CDev::ioctl(nullptr, operation, arg);
|
||||
|
||||
default:
|
||||
return -EINVAL;
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
RM3100_I2C::probe()
|
||||
int RM3100_I2C::probe()
|
||||
{
|
||||
uint8_t data = 0;
|
||||
|
||||
@@ -135,8 +106,7 @@ RM3100_I2C::probe()
|
||||
return OK;
|
||||
}
|
||||
|
||||
int
|
||||
RM3100_I2C::read(unsigned address, void *data, unsigned count)
|
||||
int RM3100_I2C::read(unsigned address, void *data, unsigned count)
|
||||
{
|
||||
uint8_t cmd = address;
|
||||
int ret;
|
||||
@@ -154,8 +124,7 @@ RM3100_I2C::read(unsigned address, void *data, unsigned count)
|
||||
return ret;
|
||||
}
|
||||
|
||||
int
|
||||
RM3100_I2C::write(unsigned address, void *data, unsigned count)
|
||||
int RM3100_I2C::write(unsigned address, void *data, unsigned count)
|
||||
{
|
||||
uint8_t buf[32];
|
||||
|
||||
|
||||
Reference in New Issue
Block a user