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:
Michael Schaeuble 2016-12-09 11:55:16 +01:00 committed by Lorenz Meier
parent 1fbc688757
commit bdb76d013e
2 changed files with 20 additions and 0 deletions

View File

@ -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
*/

View File

@ -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;