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-12 16:25:43 +02:00
committed by Lorenz Meier
parent a2f528c5ba
commit 93d444d1aa
5 changed files with 57 additions and 1 deletions
+25
View File
@@ -124,9 +124,34 @@ public:
*/
virtual int ioctl(unsigned operation, unsigned &arg);
/*
device bus types for DEVID
*/
enum DeviceBusType {
DeviceBusType_UNKNOWN = 0,
DeviceBusType_I2C = 1,
DeviceBusType_SPI = 2
};
/*
broken out
*/
struct DeviceStructure {
enum DeviceBusType bus_type;
uint8_t bus; // which instance of the bus type
uint8_t address; // address on the bus (eg. I2C address)
uint8_t devtype; // device class specific device type
};
union DeviceId {
struct DeviceStructure devid_s;
uint32_t devid;
};
protected:
const char *_name; /**< driver name */
bool _debug_enabled; /**< if true, debug messages are printed */
union DeviceId _device_id; /**< device identifier information */
/**
* Constructor