mirror of
https://github.com/PX4/PX4-Autopilot.git
synced 2026-07-24 15:27:41 +08:00
feat(drivers): add DPS368 variant support via -8 flag (#27724)
* feat(drivers/dps310): add DPS368 variant support via -8 flag Register DRV_BARO_DEVTYPE_DPS368 (0x77) and extend the dps310 driver entry point with a -8 flag to select the DPS368 devtype at startup. * fix(drivers/dps310): set device type from devid_driver_index after init
This commit is contained in:
@@ -58,6 +58,7 @@ DPS310::print_usage()
|
||||
#else
|
||||
PRINT_MODULE_USAGE_PARAMS_I2C_SPI_DRIVER(false, true);
|
||||
#endif
|
||||
PRINT_MODULE_USAGE_PARAM_FLAG('8', "Drive DPS368", true);
|
||||
PRINT_MODULE_USAGE_DEFAULT_COMMANDS();
|
||||
}
|
||||
|
||||
@@ -87,6 +88,9 @@ I2CSPIDriverBase *DPS310::instantiate(const I2CSPIDriverConfig &config, int runt
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// device_id must reflect the requested variant, since DPS310_I2C/SPI hardcode DPS310
|
||||
interface->set_device_type(config.devid_driver_index);
|
||||
|
||||
DPS310 *dev = new DPS310(config, interface);
|
||||
|
||||
if (dev == nullptr) {
|
||||
@@ -116,14 +120,25 @@ extern "C" int dps310_main(int argc, char *argv[])
|
||||
|
||||
cli.default_spi_frequency = 10 * 1000 * 1000;
|
||||
|
||||
const char *verb = cli.parseDefaultArguments(argc, argv);
|
||||
int ch;
|
||||
|
||||
while ((ch = cli.getOpt(argc, argv, "8")) != EOF) {
|
||||
switch (ch) {
|
||||
case '8':
|
||||
cli.custom1 = DRV_BARO_DEVTYPE_DPS368;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
const char *verb = cli.optArg();
|
||||
|
||||
if (!verb) {
|
||||
ThisDriver::print_usage();
|
||||
return -1;
|
||||
}
|
||||
|
||||
BusInstanceIterator iterator(MODULE_NAME, cli, DRV_BARO_DEVTYPE_DPS310);
|
||||
BusInstanceIterator iterator(MODULE_NAME, cli,
|
||||
cli.custom1 ? DRV_BARO_DEVTYPE_DPS368 : DRV_BARO_DEVTYPE_DPS310);
|
||||
|
||||
if (!strcmp(verb, "start")) {
|
||||
return ThisDriver::module_start(cli, iterator);
|
||||
|
||||
@@ -154,6 +154,7 @@
|
||||
#define DRV_GYR_DEVTYPE_BMI088 0x66
|
||||
#define DRV_BARO_DEVTYPE_BMP388 0x67
|
||||
#define DRV_BARO_DEVTYPE_DPS310 0x68
|
||||
#define DRV_BARO_DEVTYPE_DPS368 0x77
|
||||
#define DRV_PWM_DEVTYPE_PCA9685 0x69
|
||||
#define DRV_ACC_DEVTYPE_BMI088 0x6a
|
||||
#define DRV_OSD_DEVTYPE_ATXXXX 0x6b
|
||||
|
||||
Reference in New Issue
Block a user