mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-04-14 10:07:39 +08:00
Fix incorrect MPU9250 device ID
We propagate the bus parameters from the bus interface to the sensor devices. Thus, the device ID of the sensor driver is set to the correct bus id and address. Otherwise it would be zero, which is an issue if several MPU9250s are running at the same time.
This commit is contained in:
parent
1fbc688757
commit
bdb76d013e
@ -130,6 +130,20 @@ public:
|
||||
*/
|
||||
virtual int ioctl(unsigned operation, unsigned &arg);
|
||||
|
||||
/**
|
||||
* Return the bus ID the device is connected to.
|
||||
*
|
||||
* @return The bus ID
|
||||
*/
|
||||
virtual uint8_t get_device_bus() {return _device_id.devid_s.bus;};
|
||||
|
||||
/**
|
||||
* Return the bus address of the device.
|
||||
*
|
||||
* @return The bus address
|
||||
*/
|
||||
virtual uint8_t get_device_address() {return _device_id.devid_s.address;};
|
||||
|
||||
/*
|
||||
device bus types for DEVID
|
||||
*/
|
||||
|
||||
@ -166,11 +166,17 @@ MPU9250::MPU9250(device::Device *interface, device::Device *mag_interface, const
|
||||
// disable debug() calls
|
||||
_debug_enabled = false;
|
||||
|
||||
/* Set device parameters and make sure parameters of the bus device are adopted */
|
||||
_device_id.devid_s.devtype = DRV_ACC_DEVTYPE_MPU9250;
|
||||
_device_id.devid_s.bus = _interface->get_device_bus();;
|
||||
_device_id.devid_s.address = _interface->get_device_address();;
|
||||
|
||||
/* Prime _gyro with parents devid. */
|
||||
/* Set device parameters and make sure parameters of the bus device are adopted */
|
||||
_gyro->_device_id.devid = _device_id.devid;
|
||||
_gyro->_device_id.devid_s.devtype = DRV_GYR_DEVTYPE_MPU9250;
|
||||
_gyro->_device_id.devid_s.bus = _interface->get_device_bus();
|
||||
_gyro->_device_id.devid_s.address = _interface->get_device_address();
|
||||
|
||||
/* Prime _mag with parents devid. */
|
||||
_mag->_device_id.devid = _device_id.devid;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user