px4/fmu-v3: correctly identify internal mags (ist8310+hmc5883) on some boards

This commit is contained in:
Beat Küng
2021-12-10 17:39:51 +01:00
parent 95222baa33
commit b544b5c446
5 changed files with 20 additions and 4 deletions
+6
View File
@@ -33,6 +33,12 @@ then
if mpu9250 -s -b 4 -R 10 start
then
set BOARD_FMUV3 21
else
# some boards have an internal hmc5883 or ist8310, make sure they
# are not detected as external
hmc5883 start -X -b 2 -i
ist8310 start -X -b 2 -i
fi
fi
fi
+1 -1
View File
@@ -48,7 +48,7 @@ HMC5883::HMC5883(device::Device *interface, const I2CSPIDriverConfig &config) :
_temperature_counter(0),
_temperature_error_count(0)
{
_px4_mag.set_external(_interface->external());
_px4_mag.set_external(config.custom2 != 1 && _interface->external());
}
HMC5883::~HMC5883()
@@ -96,6 +96,7 @@ void HMC5883::print_usage()
PRINT_MODULE_USAGE_PARAMS_I2C_SPI_DRIVER(true, true);
PRINT_MODULE_USAGE_PARAM_INT('R', 0, 0, 35, "Rotation", true);
PRINT_MODULE_USAGE_PARAM_FLAG('T', "Enable temperature compensation", true);
PRINT_MODULE_USAGE_PARAM_FLAG('i', "Force as internal", true);
PRINT_MODULE_USAGE_DEFAULT_COMMANDS();
}
@@ -107,7 +108,7 @@ extern "C" int hmc5883_main(int argc, char *argv[])
cli.default_i2c_frequency = 400000;
cli.default_spi_frequency = 11 * 1000 * 1000;
while ((ch = cli.getOpt(argc, argv, "R:T")) != EOF) {
while ((ch = cli.getOpt(argc, argv, "R:Ti")) != EOF) {
switch (ch) {
case 'R':
cli.rotation = (enum Rotation)atoi(cli.optArg());
@@ -116,6 +117,10 @@ extern "C" int hmc5883_main(int argc, char *argv[])
case 'T':
cli.custom1 = 1;
break;
case 'i':
cli.custom2 = 1;
break;
}
}
@@ -45,7 +45,7 @@ IST8310::IST8310(const I2CSPIDriverConfig &config) :
I2CSPIDriver(config),
_px4_mag(get_device_id(), config.rotation)
{
_px4_mag.set_external(external());
_px4_mag.set_external(config.custom2 != 1 && external());
}
IST8310::~IST8310()
@@ -44,6 +44,7 @@ void IST8310::print_usage()
PRINT_MODULE_USAGE_PARAMS_I2C_SPI_DRIVER(true, false);
PRINT_MODULE_USAGE_PARAMS_I2C_ADDRESS(0x0E);
PRINT_MODULE_USAGE_PARAM_INT('R', 0, 0, 35, "Rotation", true);
PRINT_MODULE_USAGE_PARAM_FLAG('i', "Force as internal", true);
PRINT_MODULE_USAGE_DEFAULT_COMMANDS();
}
@@ -55,11 +56,15 @@ extern "C" int ist8310_main(int argc, char *argv[])
cli.i2c_address = I2C_ADDRESS_DEFAULT;
cli.default_i2c_frequency = I2C_SPEED;
while ((ch = cli.getOpt(argc, argv, "R:")) != EOF) {
while ((ch = cli.getOpt(argc, argv, "R:i")) != EOF) {
switch (ch) {
case 'R':
cli.rotation = (enum Rotation)atoi(cli.optArg());
break;
case 'i':
cli.custom2 = 1;
break;
}
}