diff options
author | Lorenz Meier <lm@inf.ethz.ch> | 2012-12-22 00:56:37 +0100 |
---|---|---|
committer | Lorenz Meier <lm@inf.ethz.ch> | 2012-12-22 00:56:37 +0100 |
commit | a2aa9dd8fd6f0d870f871e12d9b59d659b4a269c (patch) | |
tree | c191bd2cda4ef159d6e120dfa6741535e5b84a5d | |
parent | f40e4d13aa1c6cd854b848f1cd0c3a017e719138 (diff) | |
download | px4-firmware-a2aa9dd8fd6f0d870f871e12d9b59d659b4a269c.tar.gz px4-firmware-a2aa9dd8fd6f0d870f871e12d9b59d659b4a269c.tar.bz2 px4-firmware-a2aa9dd8fd6f0d870f871e12d9b59d659b4a269c.zip |
Made MPU-6000 gyro optional
-rw-r--r-- | apps/drivers/mpu6000/mpu6000.cpp | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/apps/drivers/mpu6000/mpu6000.cpp b/apps/drivers/mpu6000/mpu6000.cpp index ed79440cc..b6c8cacfd 100644 --- a/apps/drivers/mpu6000/mpu6000.cpp +++ b/apps/drivers/mpu6000/mpu6000.cpp @@ -446,8 +446,13 @@ MPU6000::init() // write_reg(MPUREG_PWR_MGMT_1,MPU_CLK_SEL_PLLGYROZ); usleep(1000); - /* do CDev init for the gyro device node */ - ret = _gyro->init(); + /* do CDev init for the gyro device node, keep it optional */ + int gyro_ret = _gyro->init(); + + if (gyro_ret != OK) { + ::close(_gyro_topic); + _gyro_topic = -1; + } return ret; } @@ -938,7 +943,9 @@ MPU6000::measure() /* and publish for subscribers */ orb_publish(ORB_ID(sensor_accel), _accel_topic, &_accel_report); - orb_publish(ORB_ID(sensor_gyro), _gyro_topic, &_gyro_report); + if (_gyro_topic != -1) { + orb_publish(ORB_ID(sensor_gyro), _gyro_topic, &_gyro_report); + } /* stop measuring */ perf_end(_sample_perf); |