From 78f1d9d01782a9019c98749e108567d2b2a0115f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beat=20K=C3=BCng?= Date: Wed, 7 Dec 2016 10:46:48 +0100 Subject: [PATCH] hmc5883: fix MAGIOCGEXTERNAL ioctl for non fmuv1 boards This makes the onboard check consistent with hmc5883_bus_option initialization. If the current bus is the onboard bus, return !external. It fixes the onboard mag (HMC5883) for AeroFC. Its priority is now 100, previously it was 255, so that if an external mag is attached, it will be preferred. --- src/drivers/hmc5883/hmc5883_i2c.cpp | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/drivers/hmc5883/hmc5883_i2c.cpp b/src/drivers/hmc5883/hmc5883_i2c.cpp index d29ffbe0b4..339115c2fd 100644 --- a/src/drivers/hmc5883/hmc5883_i2c.cpp +++ b/src/drivers/hmc5883/hmc5883_i2c.cpp @@ -113,17 +113,16 @@ HMC5883_I2C::ioctl(unsigned operation, unsigned &arg) switch (operation) { case MAGIOCGEXTERNAL: -// On PX4v1 the MAG can be on an internal I2C -// On everything else its always external -#ifdef CONFIG_ARCH_BOARD_PX4FMU_V1 - if (_bus == PX4_I2C_BUS_EXPANSION) { - return 1; +#ifdef PX4_I2C_BUS_ONBOARD + if (_bus == PX4_I2C_BUS_ONBOARD) { + return 0; } else { - return 0; + return 1; } #else + /* assume external for all boards that don't define PX4_I2C_BUS_ONBOARD */ return 1; #endif