diff options
author | Lorenz Meier <lm@inf.ethz.ch> | 2013-08-19 08:37:11 -0700 |
---|---|---|
committer | Lorenz Meier <lm@inf.ethz.ch> | 2013-08-19 08:37:11 -0700 |
commit | 230c09e2f44e0bcf8613815e2f771b4dffe8b042 (patch) | |
tree | 37f2b731fb9a0097b64c42c59c6a6235c3318c31 /src/drivers/lsm303d | |
parent | cdd09333f946e746527c8e9af36e08dc3a29a975 (diff) | |
parent | a95e48c0b25c75548e923657247cdf268e654097 (diff) | |
download | px4-firmware-230c09e2f44e0bcf8613815e2f771b4dffe8b042.tar.gz px4-firmware-230c09e2f44e0bcf8613815e2f771b4dffe8b042.tar.bz2 px4-firmware-230c09e2f44e0bcf8613815e2f771b4dffe8b042.zip |
Merge pull request #11 from cvg/fmuv2_bringup_ext_mag_rotation
Support for external mags with different rotation
Diffstat (limited to 'src/drivers/lsm303d')
-rw-r--r-- | src/drivers/lsm303d/lsm303d.cpp | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/src/drivers/lsm303d/lsm303d.cpp b/src/drivers/lsm303d/lsm303d.cpp index 117583faf..3e6ce64b8 100644 --- a/src/drivers/lsm303d/lsm303d.cpp +++ b/src/drivers/lsm303d/lsm303d.cpp @@ -869,6 +869,10 @@ LSM303D::mag_ioctl(struct file *filp, int cmd, unsigned long arg) // return self_test(); return -EINVAL; + case MAGIOCGEXTERNAL: + /* no external mag board yet */ + return 0; + default: /* give it to the superclass */ return SPI::ioctl(filp, cmd, arg); @@ -1422,7 +1426,7 @@ test() int fd_accel = -1; struct accel_report accel_report; ssize_t sz; - int filter_bandwidth; + int ret; /* get the driver */ fd_accel = open(ACCEL_DEVICE_PATH, O_RDONLY); @@ -1445,10 +1449,10 @@ test() warnx("accel z: \t%d\traw", (int)accel_report.z_raw); warnx("accel range: %8.4f m/s^2", (double)accel_report.range_m_s2); - if (ERROR == (filter_bandwidth = ioctl(fd_accel, ACCELIOCGLOWPASS, 0))) + if (ERROR == (ret = ioctl(fd_accel, ACCELIOCGLOWPASS, 0))) warnx("accel antialias filter bandwidth: fail"); else - warnx("accel antialias filter bandwidth: %d Hz", filter_bandwidth); + warnx("accel antialias filter bandwidth: %d Hz", ret); int fd_mag = -1; struct mag_report m_report; @@ -1459,6 +1463,11 @@ test() if (fd_mag < 0) err(1, "%s open failed", MAG_DEVICE_PATH); + /* check if mag is onboard or external */ + if ((ret = ioctl(fd_mag, MAGIOCGEXTERNAL, 0)) < 0) + errx(1, "failed to get if mag is onboard or external"); + warnx("device active: %s", ret ? "external" : "onboard"); + /* do a simple demand read */ sz = read(fd_mag, &m_report, sizeof(m_report)); |