device: added a _device_id to all drivers

this device ID identifies a specific device via the tuple of (bus, bus
type, address, devtype). This allows device specific configuration
data to be stored along with a device ID, so the code can know when
the user has changed device configuration (such as removing an
external compass), and either invalidate the device configuration or
force the user to re-calibrate
This commit is contained in:
Andrew Tridgell
2014-07-08 21:09:12 +10:00
committed by Lorenz Meier
parent a2f528c5ba
commit 93d444d1aa
5 changed files with 57 additions and 1 deletions
+7 -1
View File
@@ -62,6 +62,12 @@ I2C::I2C(const char *name,
_frequency(frequency),
_dev(nullptr)
{
// fill in _device_id fields for a I2C device
_device_id.devid_s.bus_type = DeviceBusType_I2C;
_device_id.devid_s.bus = bus;
_device_id.devid_s.address = address;
// devtype needs to be filled in by the driver
_device_id.devid_s.devtype = 0;
}
I2C::~I2C()
@@ -201,4 +207,4 @@ I2C::transfer(i2c_msg_s *msgv, unsigned msgs)
return ret;
}
} // namespace device
} // namespace device