aboutsummaryrefslogtreecommitdiff
path: root/src/drivers
diff options
context:
space:
mode:
authorLorenz Meier <lm@inf.ethz.ch>2013-12-07 10:44:29 +0100
committerLorenz Meier <lm@inf.ethz.ch>2013-12-10 12:05:21 +0100
commit1fb406ba094a091c6976f752c3b6db71fc895605 (patch)
tree4a4d9f6ce06e90707e290ea395fdb0acada59ebd /src/drivers
parent3d27dd7246c660bb0a00caae3cd0b0e66bfa6467 (diff)
downloadpx4-firmware-1fb406ba094a091c6976f752c3b6db71fc895605.tar.gz
px4-firmware-1fb406ba094a091c6976f752c3b6db71fc895605.tar.bz2
px4-firmware-1fb406ba094a091c6976f752c3b6db71fc895605.zip
Add also default descriptor for alternate sensors
Diffstat (limited to 'src/drivers')
-rw-r--r--src/drivers/lsm303d/lsm303d.cpp22
1 files changed, 21 insertions, 1 deletions
diff --git a/src/drivers/lsm303d/lsm303d.cpp b/src/drivers/lsm303d/lsm303d.cpp
index a3409cbac..94966a963 100644
--- a/src/drivers/lsm303d/lsm303d.cpp
+++ b/src/drivers/lsm303d/lsm303d.cpp
@@ -586,11 +586,21 @@ LSM303D::init()
reset();
- /* try to claim the generic accel node as well - it's OK if we fail at this */
+ /* register the first instance as plain name, the 2nd as two and counting */
ret = register_driver(ACCEL_DEVICE_PATH, &fops, 0666, (void *)this);
if (ret == OK) {
log("default accel device");
+
+ } else {
+
+ unsigned instance = 1;
+ do {
+ char name[32];
+ sprintf(name, "%s%d", ACCEL_DEVICE_PATH, instance);
+ ret = register_driver(name, &fops, 0666, (void *)this);
+ instance++;
+ } while (ret);
}
/* try to claim the generic accel node as well - it's OK if we fail at this */
@@ -598,6 +608,16 @@ LSM303D::init()
if (mag_ret == OK) {
log("default mag device");
+
+ } else {
+
+ unsigned instance = 1;
+ do {
+ char name[32];
+ sprintf(name, "%s%d", MAG_DEVICE_PATH, instance);
+ ret = register_driver(name, &fops, 0666, (void *)this);
+ instance++;
+ } while (ret);
}
/* advertise mag topic */