|
|
@ -63,12 +63,12 @@ |
|
|
|
|
|
|
|
|
|
|
|
extern const AP_HAL::HAL &hal; |
|
|
|
extern const AP_HAL::HAL &hal; |
|
|
|
|
|
|
|
|
|
|
|
AP_Compass_Backend *AP_Compass_BMM150::probe(AP_HAL::OwnPtr<AP_HAL::I2CDevice> dev) |
|
|
|
AP_Compass_Backend *AP_Compass_BMM150::probe(AP_HAL::OwnPtr<AP_HAL::I2CDevice> dev, enum Rotation rotation) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (!dev) { |
|
|
|
if (!dev) { |
|
|
|
return nullptr; |
|
|
|
return nullptr; |
|
|
|
} |
|
|
|
} |
|
|
|
AP_Compass_BMM150 *sensor = new AP_Compass_BMM150(std::move(dev)); |
|
|
|
AP_Compass_BMM150 *sensor = new AP_Compass_BMM150(std::move(dev), rotation); |
|
|
|
if (!sensor || !sensor->init()) { |
|
|
|
if (!sensor || !sensor->init()) { |
|
|
|
delete sensor; |
|
|
|
delete sensor; |
|
|
|
return nullptr; |
|
|
|
return nullptr; |
|
|
@ -77,8 +77,8 @@ AP_Compass_Backend *AP_Compass_BMM150::probe(AP_HAL::OwnPtr<AP_HAL::I2CDevice> d |
|
|
|
return sensor; |
|
|
|
return sensor; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
AP_Compass_BMM150::AP_Compass_BMM150(AP_HAL::OwnPtr<AP_HAL::Device> dev) |
|
|
|
AP_Compass_BMM150::AP_Compass_BMM150(AP_HAL::OwnPtr<AP_HAL::Device> dev, enum Rotation rotation) |
|
|
|
: _dev(std::move(dev)) |
|
|
|
: _dev(std::move(dev)), _rotation(rotation) |
|
|
|
{ |
|
|
|
{ |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -216,6 +216,8 @@ bool AP_Compass_BMM150::init() |
|
|
|
/* register the compass instance in the frontend */ |
|
|
|
/* register the compass instance in the frontend */ |
|
|
|
_compass_instance = register_compass(); |
|
|
|
_compass_instance = register_compass(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
set_rotation(_compass_instance, _rotation); |
|
|
|
|
|
|
|
|
|
|
|
_dev->set_device_type(DEVTYPE_BMM150); |
|
|
|
_dev->set_device_type(DEVTYPE_BMM150); |
|
|
|
set_dev_id(_compass_instance, _dev->get_bus_id()); |
|
|
|
set_dev_id(_compass_instance, _dev->get_bus_id()); |
|
|
|
|
|
|
|
|
|
|
|