diff options
author | Lorenz Meier <lm@inf.ethz.ch> | 2014-06-10 15:08:47 +0200 |
---|---|---|
committer | Lorenz Meier <lm@inf.ethz.ch> | 2014-06-10 15:08:47 +0200 |
commit | becfed9fbd93204134c44f6da09d954151dff10d (patch) | |
tree | 06929cb109ff1c9d82b1df58088d5bdb6ecac282 /src/drivers | |
parent | c35a25e70a57229b58fe065fda23003de856e9f5 (diff) | |
download | px4-firmware-becfed9fbd93204134c44f6da09d954151dff10d.tar.gz px4-firmware-becfed9fbd93204134c44f6da09d954151dff10d.tar.bz2 px4-firmware-becfed9fbd93204134c44f6da09d954151dff10d.zip |
MS5611: Add support for multi uORB devices
Diffstat (limited to 'src/drivers')
-rw-r--r-- | src/drivers/ms5611/ms5611.cpp | 27 |
1 files changed, 20 insertions, 7 deletions
diff --git a/src/drivers/ms5611/ms5611.cpp b/src/drivers/ms5611/ms5611.cpp index 1ce93aeea..2d85a5e0d 100644 --- a/src/drivers/ms5611/ms5611.cpp +++ b/src/drivers/ms5611/ms5611.cpp @@ -299,12 +299,17 @@ MS5611::init() ret = OK; - if (_class_instance == CLASS_DEVICE_PRIMARY) { - - _baro_topic = orb_advertise(ORB_ID(sensor_baro), &brp); + switch (_class_instance) { + case CLASS_DEVICE_PRIMARY: + _baro_topic = orb_advertise(ORB_ID(sensor_baro0), &brp); + break; + case CLASS_DEVICE_SECONDARY: + _baro_topic = orb_advertise(ORB_ID(sensor_baro1), &brp); + break; + } - if (_baro_topic < 0) - debug("failed to create sensor_baro publication"); + if (_baro_topic < 0) { + warnx("failed to create sensor_baro publication"); } } while (0); @@ -721,9 +726,17 @@ MS5611::collect() report.altitude = (((pow((p / p1), (-(a * R) / g))) * T1) - T1) / a; /* publish it */ - if (_baro_topic > 0 && !(_pub_blocked)) { + if (!(_pub_blocked)) { /* publish it */ - orb_publish(ORB_ID(sensor_baro), _baro_topic, &report); + switch (_class_instance) { + case CLASS_DEVICE_PRIMARY: + orb_publish(ORB_ID(sensor_baro0), _baro_topic, &report); + break; + + case CLASS_DEVICE_SECONDARY: + orb_publish(ORB_ID(sensor_baro1), _baro_topic, &report); + break; + } } if (_reports->force(&report)) { |