mirror of
https://github.com/PX4/PX4-Autopilot.git
synced 2026-05-20 11:23:06 +08:00
param: automatically update calibration ID params on import
This avoids the need for recalibration, and also cleans up other driver ID's (merge separate accel/gyro). The SPI address was previously set to a board-specific (arbitrary) value, and is now set to 0. This will allow extending for multiple sensors of the same type on the same bus.
This commit is contained in:
@@ -109,7 +109,7 @@
|
||||
#define PX4_SPI_BUS_1_CS_GPIO {GPIO_SPI1_CS1_ICM20602, GPIO_SPI1_CS2_ICM20948}
|
||||
|
||||
#define PX4_SPIDEV_MEMORY SPIDEV_FLASH(0)
|
||||
#define PX4_SPIDEV_BARO PX4_MK_SPI_SEL(0,DRV_DEVTYPE_DPS310)
|
||||
#define PX4_SPIDEV_BARO PX4_MK_SPI_SEL(0,DRV_BARO_DEVTYPE_DPS310)
|
||||
#define PX4_SPI_BUS_2_CS_GPIO {GPIO_SPI2_CS1_FRAM, GPIO_SPI2_CS2_BARO}
|
||||
|
||||
#define PX4_SPIDEV_BMI088_ACC PX4_MK_SPI_SEL(0,DRV_ACC_DEVTYPE_BMI088)
|
||||
|
||||
@@ -43,7 +43,7 @@ constexpr px4_spi_bus_t px4_spi_buses[SPI_BUS_MAX_BUS_ITEMS] = {
|
||||
}, {GPIO::PortE, GPIO::Pin3}),
|
||||
initSPIBus(2, {
|
||||
initSPIDevice(SPIDEV_FLASH(0), SPI::CS{GPIO::PortD, GPIO::Pin10}),
|
||||
initSPIDevice(DRV_DEVTYPE_DPS310, SPI::CS{GPIO::PortD, GPIO::Pin7}),
|
||||
initSPIDevice(DRV_BARO_DEVTYPE_DPS310, SPI::CS{GPIO::PortD, GPIO::Pin7}),
|
||||
}),
|
||||
initSPIBus(5, {
|
||||
initSPIDevice(DRV_GYR_DEVTYPE_BMI088, SPI::CS{GPIO::PortF, GPIO::Pin10}, SPI::DRDY{GPIO::PortF, GPIO::Pin3}),
|
||||
|
||||
@@ -231,7 +231,7 @@
|
||||
#define PX4_SPIDEV_ICM_20602 PX4_MK_SPI_SEL(0,DRV_IMU_DEVTYPE_ICM20602)
|
||||
#define PX4_SENSORS1_BUS_CS_GPIO {GPIO_SPI1_nCS1_ICM20602}
|
||||
|
||||
#define PX4_SPIDEV_ISM330 PX4_MK_SPI_SEL(0,DRV_DEVTYPE_ST_ISM330DLC)
|
||||
#define PX4_SPIDEV_ISM330 PX4_MK_SPI_SEL(0,DRV_IMU_DEVTYPE_ST_ISM330DLC)
|
||||
#define PX4_SENSORS2_BUS_CS_GPIO {GPIO_SPI2_nCS1_ISM330}
|
||||
|
||||
#define PX4_SPIDEV_BMI088_GYR PX4_MK_SPI_SEL(0,DRV_GYR_DEVTYPE_BMI088)
|
||||
|
||||
@@ -40,7 +40,7 @@ constexpr px4_spi_bus_t px4_spi_buses[SPI_BUS_MAX_BUS_ITEMS] = {
|
||||
initSPIDevice(DRV_IMU_DEVTYPE_ICM20602, SPI::CS{GPIO::PortI, GPIO::Pin9}, SPI::DRDY{GPIO::PortF, GPIO::Pin2}),
|
||||
}, {GPIO::PortI, GPIO::Pin11}),
|
||||
initSPIBus(2, {
|
||||
initSPIDevice(DRV_DEVTYPE_ST_ISM330DLC, SPI::CS{GPIO::PortH, GPIO::Pin5}, SPI::DRDY{GPIO::PortH, GPIO::Pin12}),
|
||||
initSPIDevice(DRV_IMU_DEVTYPE_ST_ISM330DLC, SPI::CS{GPIO::PortH, GPIO::Pin5}, SPI::DRDY{GPIO::PortH, GPIO::Pin12}),
|
||||
}, {GPIO::PortD, GPIO::Pin15}),
|
||||
initSPIBus(3, {
|
||||
initSPIDevice(DRV_GYR_DEVTYPE_BMI088, SPI::CS{GPIO::PortI, GPIO::Pin8}, SPI::DRDY{GPIO::PortI, GPIO::Pin7}),
|
||||
|
||||
@@ -50,7 +50,7 @@ BMP388::BMP388(IBMP388 *interface) :
|
||||
_measure_perf(perf_alloc(PC_ELAPSED, MODULE_NAME": measure")),
|
||||
_comms_errors(perf_alloc(PC_COUNT, MODULE_NAME": comms errors"))
|
||||
{
|
||||
_px4_baro.set_device_type(DRV_DEVTYPE_BMP388);
|
||||
_px4_baro.set_device_type(DRV_BARO_DEVTYPE_BMP388);
|
||||
}
|
||||
|
||||
BMP388::~BMP388()
|
||||
|
||||
@@ -53,7 +53,7 @@ DPS310::DPS310(device::Device *interface) :
|
||||
_sample_perf(perf_alloc(PC_ELAPSED, MODULE_NAME": read")),
|
||||
_comms_errors(perf_alloc(PC_COUNT, MODULE_NAME": comm errors"))
|
||||
{
|
||||
_px4_barometer.set_device_type(DRV_DEVTYPE_DPS310);
|
||||
_px4_barometer.set_device_type(DRV_BARO_DEVTYPE_DPS310);
|
||||
}
|
||||
|
||||
DPS310::~DPS310()
|
||||
|
||||
+14
-19
@@ -61,21 +61,19 @@
|
||||
#define DRV_MAG_DEVTYPE_RM3100 0x07
|
||||
#define DRV_MAG_DEVTYPE_QMC5883 0x08
|
||||
#define DRV_MAG_DEVTYPE_AK09916 0x09
|
||||
#define DRV_DEVTYPE_ICM20948 0x0A
|
||||
#define DRV_IMU_DEVTYPE_ICM20948 0x0A
|
||||
|
||||
#define DRV_ACC_DEVTYPE_LSM303D 0x11
|
||||
#define DRV_ACC_DEVTYPE_BMA180 0x12
|
||||
#define DRV_ACC_DEVTYPE_MPU6000 0x13 // TODO: remove this
|
||||
#define DRV_ACC_DEVTYPE_MPU6000_LEGACY 0x13
|
||||
#define DRV_ACC_DEVTYPE_ACCELSIM 0x14
|
||||
#define DRV_ACC_DEVTYPE_MPU9250 0x16 // TOOD: remove this
|
||||
#define DRV_ACC_DEVTYPE_MPU9250_LEGACY 0x16
|
||||
#define DRV_ACC_DEVTYPE_BMI160 0x17
|
||||
|
||||
#define DRV_GYR_DEVTYPE_MPU6000 0x21
|
||||
#define DRV_IMU_DEVTYPE_MPU6000 DRV_GYR_DEVTYPE_MPU6000
|
||||
#define DRV_IMU_DEVTYPE_MPU6000 0x21
|
||||
#define DRV_GYR_DEVTYPE_L3GD20 0x22
|
||||
#define DRV_GYR_DEVTYPE_GYROSIM 0x23
|
||||
#define DRV_GYR_DEVTYPE_MPU9250 0x24
|
||||
#define DRV_IMU_DEVTYPE_MPU9250 DRV_GYR_DEVTYPE_MPU9250
|
||||
#define DRV_IMU_DEVTYPE_MPU9250 0x24
|
||||
#define DRV_GYR_DEVTYPE_BMI160 0x25
|
||||
|
||||
#define DRV_RNG_DEVTYPE_MB12XX 0x31
|
||||
@@ -84,15 +82,12 @@
|
||||
#define DRV_ACC_DEVTYPE_MPU6500 0x34
|
||||
#define DRV_GYR_DEVTYPE_MPU6050 0x35
|
||||
#define DRV_GYR_DEVTYPE_MPU6500 0x36
|
||||
#define DRV_ACC_DEVTYPE_ICM20602 0x37 // TODO: remove this
|
||||
#define DRV_GYR_DEVTYPE_ICM20602 0x38
|
||||
#define DRV_IMU_DEVTYPE_ICM20602 DRV_GYR_DEVTYPE_ICM20602
|
||||
#define DRV_ACC_DEVTYPE_ICM20608 0x39
|
||||
#define DRV_GYR_DEVTYPE_ICM20608 0x3A // TODO: remove this
|
||||
#define DRV_IMU_DEVTYPE_ICM20608 DRV_GYR_DEVTYPE_ICM20608
|
||||
#define DRV_ACC_DEVTYPE_ICM20689 0x3B
|
||||
#define DRV_GYR_DEVTYPE_ICM20689 0x3C // TODO: remove this
|
||||
#define DRV_IMU_DEVTYPE_ICM20689 DRV_GYR_DEVTYPE_ICM20689
|
||||
#define DRV_ACC_DEVTYPE_ICM20602_LEGACY 0x37
|
||||
#define DRV_IMU_DEVTYPE_ICM20602 0x38
|
||||
#define DRV_ACC_DEVTYPE_ICM20608_LEGACY 0x39
|
||||
#define DRV_IMU_DEVTYPE_ICM20608 0x3A
|
||||
#define DRV_ACC_DEVTYPE_ICM20689_LEGACY 0x3B
|
||||
#define DRV_IMU_DEVTYPE_ICM20689 0x3C
|
||||
#define DRV_BARO_DEVTYPE_MS5611 0x3D
|
||||
#define DRV_BARO_DEVTYPE_MS5607 0x3E
|
||||
#define DRV_BARO_DEVTYPE_BMP280 0x3F
|
||||
@@ -126,9 +121,9 @@
|
||||
#define DRV_GYR_DEVTYPE_ADIS16497 0x64
|
||||
#define DRV_BARO_DEVTYPE_BAROSIM 0x65
|
||||
#define DRV_GYR_DEVTYPE_BMI088 0x66
|
||||
#define DRV_DEVTYPE_BMP388 0x67
|
||||
#define DRV_DEVTYPE_DPS310 0x68
|
||||
#define DRV_DEVTYPE_ST_ISM330DLC 0x69
|
||||
#define DRV_BARO_DEVTYPE_BMP388 0x67
|
||||
#define DRV_BARO_DEVTYPE_DPS310 0x68
|
||||
#define DRV_IMU_DEVTYPE_ST_ISM330DLC 0x69
|
||||
#define DRV_ACC_DEVTYPE_BMI088 0x6a
|
||||
#define DRV_OSD_DEVTYPE_ATXXXX 0x6b
|
||||
#define DRV_FLOW_DEVTYPE_PMW3901 0x6c
|
||||
|
||||
@@ -62,7 +62,7 @@ BMI088_accel::BMI088_accel(int bus, const char *path_accel, uint32_t device, enu
|
||||
_duplicates(perf_alloc(PC_COUNT, "bmi088_accel_duplicates")),
|
||||
_got_duplicate(false)
|
||||
{
|
||||
_px4_accel.set_device_type(DRV_GYR_DEVTYPE_BMI088);
|
||||
_px4_accel.set_device_type(DRV_ACC_DEVTYPE_BMI088);
|
||||
}
|
||||
|
||||
BMI088_accel::~BMI088_accel()
|
||||
|
||||
@@ -100,8 +100,8 @@ ICM20948::ICM20948(device::Device *interface, device::Device *mag_interface, enu
|
||||
_good_transfers(perf_alloc(PC_COUNT, MODULE_NAME": good_trans")),
|
||||
_duplicates(perf_alloc(PC_COUNT, MODULE_NAME": dupe"))
|
||||
{
|
||||
_px4_accel.set_device_type(DRV_DEVTYPE_ICM20948);
|
||||
_px4_gyro.set_device_type(DRV_DEVTYPE_ICM20948);
|
||||
_px4_accel.set_device_type(DRV_IMU_DEVTYPE_ICM20948);
|
||||
_px4_gyro.set_device_type(DRV_IMU_DEVTYPE_ICM20948);
|
||||
}
|
||||
|
||||
ICM20948::~ICM20948()
|
||||
|
||||
@@ -72,7 +72,7 @@ ICM20948_I2C_interface(int bus, uint32_t address)
|
||||
ICM20948_I2C::ICM20948_I2C(int bus, uint32_t address) :
|
||||
I2C("ICM20948_I2C", nullptr, bus, address, 400000)
|
||||
{
|
||||
_device_id.devid_s.devtype = DRV_DEVTYPE_ICM20948;
|
||||
_device_id.devid_s.devtype = DRV_IMU_DEVTYPE_ICM20948;
|
||||
}
|
||||
|
||||
int
|
||||
|
||||
@@ -92,7 +92,7 @@ ICM20948_SPI_interface(int bus, uint32_t cs)
|
||||
ICM20948_SPI::ICM20948_SPI(int bus, uint32_t device) :
|
||||
SPI("ICM20948", nullptr, bus, device, SPIDEV_MODE3, ICM20948_LOW_SPI_BUS_SPEED)
|
||||
{
|
||||
_device_id.devid_s.devtype = DRV_DEVTYPE_ICM20948;
|
||||
_device_id.devid_s.devtype = DRV_IMU_DEVTYPE_ICM20948;
|
||||
}
|
||||
|
||||
void
|
||||
|
||||
@@ -69,7 +69,7 @@ AK09916_I2C_interface(int bus)
|
||||
AK09916_I2C::AK09916_I2C(int bus) :
|
||||
I2C("AK09916_I2C", nullptr, bus, AK09916_I2C_ADDR, 400000)
|
||||
{
|
||||
_device_id.devid_s.devtype = DRV_DEVTYPE_ICM20948;
|
||||
_device_id.devid_s.devtype = DRV_IMU_DEVTYPE_ICM20948;
|
||||
}
|
||||
|
||||
int
|
||||
|
||||
@@ -48,10 +48,9 @@ ICM20602::ICM20602(int bus, uint32_t device, enum Rotation rotation) :
|
||||
_px4_accel(get_device_id(), ORB_PRIO_VERY_HIGH, rotation),
|
||||
_px4_gyro(get_device_id(), ORB_PRIO_VERY_HIGH, rotation)
|
||||
{
|
||||
set_device_type(DRV_ACC_DEVTYPE_ICM20602);
|
||||
|
||||
_px4_accel.set_device_type(DRV_ACC_DEVTYPE_ICM20602);
|
||||
_px4_gyro.set_device_type(DRV_GYR_DEVTYPE_ICM20602);
|
||||
set_device_type(DRV_IMU_DEVTYPE_ICM20602);
|
||||
_px4_accel.set_device_type(DRV_IMU_DEVTYPE_ICM20602);
|
||||
_px4_gyro.set_device_type(DRV_IMU_DEVTYPE_ICM20602);
|
||||
|
||||
ConfigureSampleRate(_px4_gyro.get_max_rate_hz());
|
||||
}
|
||||
|
||||
@@ -48,10 +48,10 @@ ICM20608G::ICM20608G(int bus, uint32_t device, enum Rotation rotation) :
|
||||
_px4_accel(get_device_id(), ORB_PRIO_VERY_HIGH, rotation),
|
||||
_px4_gyro(get_device_id(), ORB_PRIO_VERY_HIGH, rotation)
|
||||
{
|
||||
set_device_type(DRV_ACC_DEVTYPE_ICM20608);
|
||||
set_device_type(DRV_IMU_DEVTYPE_ICM20608);
|
||||
|
||||
_px4_accel.set_device_type(DRV_ACC_DEVTYPE_ICM20608);
|
||||
_px4_gyro.set_device_type(DRV_GYR_DEVTYPE_ICM20608);
|
||||
_px4_accel.set_device_type(DRV_IMU_DEVTYPE_ICM20608);
|
||||
_px4_gyro.set_device_type(DRV_IMU_DEVTYPE_ICM20608);
|
||||
|
||||
ConfigureSampleRate(_px4_gyro.get_max_rate_hz());
|
||||
}
|
||||
|
||||
@@ -48,10 +48,9 @@ ICM20689::ICM20689(int bus, uint32_t device, enum Rotation rotation) :
|
||||
_px4_accel(get_device_id(), ORB_PRIO_VERY_HIGH, rotation),
|
||||
_px4_gyro(get_device_id(), ORB_PRIO_VERY_HIGH, rotation)
|
||||
{
|
||||
set_device_type(DRV_ACC_DEVTYPE_ICM20689);
|
||||
|
||||
_px4_accel.set_device_type(DRV_ACC_DEVTYPE_ICM20689);
|
||||
_px4_gyro.set_device_type(DRV_GYR_DEVTYPE_ICM20689);
|
||||
set_device_type(DRV_IMU_DEVTYPE_ICM20689);
|
||||
_px4_accel.set_device_type(DRV_IMU_DEVTYPE_ICM20689);
|
||||
_px4_gyro.set_device_type(DRV_IMU_DEVTYPE_ICM20689);
|
||||
|
||||
ConfigureSampleRate(_px4_gyro.get_max_rate_hz());
|
||||
}
|
||||
|
||||
@@ -54,9 +54,9 @@ MPU6000::MPU6000(int bus, uint32_t device, enum Rotation rotation) :
|
||||
_px4_accel(get_device_id(), ORB_PRIO_VERY_HIGH, rotation),
|
||||
_px4_gyro(get_device_id(), ORB_PRIO_VERY_HIGH, rotation)
|
||||
{
|
||||
set_device_type(DRV_ACC_DEVTYPE_MPU6000);
|
||||
_px4_accel.set_device_type(DRV_ACC_DEVTYPE_MPU6000);
|
||||
_px4_gyro.set_device_type(DRV_GYR_DEVTYPE_MPU6000);
|
||||
set_device_type(DRV_IMU_DEVTYPE_MPU6000);
|
||||
_px4_accel.set_device_type(DRV_IMU_DEVTYPE_MPU6000);
|
||||
_px4_gyro.set_device_type(DRV_IMU_DEVTYPE_MPU6000);
|
||||
|
||||
_px4_accel.set_update_rate(1000000 / FIFO_INTERVAL);
|
||||
_px4_gyro.set_update_rate(1000000 / FIFO_INTERVAL);
|
||||
|
||||
@@ -48,10 +48,9 @@ MPU9250::MPU9250(int bus, uint32_t device, enum Rotation rotation) :
|
||||
_px4_accel(get_device_id(), ORB_PRIO_VERY_HIGH, rotation),
|
||||
_px4_gyro(get_device_id(), ORB_PRIO_VERY_HIGH, rotation)
|
||||
{
|
||||
set_device_type(DRV_ACC_DEVTYPE_MPU9250);
|
||||
|
||||
_px4_accel.set_device_type(DRV_ACC_DEVTYPE_MPU9250);
|
||||
_px4_gyro.set_device_type(DRV_GYR_DEVTYPE_MPU9250);
|
||||
set_device_type(DRV_IMU_DEVTYPE_MPU9250);
|
||||
_px4_accel.set_device_type(DRV_IMU_DEVTYPE_MPU9250);
|
||||
_px4_gyro.set_device_type(DRV_IMU_DEVTYPE_MPU9250);
|
||||
|
||||
ConfigureSampleRate(_px4_gyro.get_max_rate_hz());
|
||||
}
|
||||
|
||||
@@ -54,23 +54,23 @@ MPU6000::MPU6000(device::Device *interface, enum Rotation rotation, int device_t
|
||||
switch (_device_type) {
|
||||
default:
|
||||
case MPU_DEVICE_TYPE_MPU6000:
|
||||
_px4_accel.set_device_type(DRV_ACC_DEVTYPE_MPU6000);
|
||||
_px4_gyro.set_device_type(DRV_GYR_DEVTYPE_MPU6000);
|
||||
_px4_accel.set_device_type(DRV_IMU_DEVTYPE_MPU6000);
|
||||
_px4_gyro.set_device_type(DRV_IMU_DEVTYPE_MPU6000);
|
||||
break;
|
||||
|
||||
case MPU_DEVICE_TYPE_ICM20602:
|
||||
_px4_accel.set_device_type(DRV_ACC_DEVTYPE_ICM20602);
|
||||
_px4_gyro.set_device_type(DRV_GYR_DEVTYPE_ICM20602);
|
||||
_px4_accel.set_device_type(DRV_IMU_DEVTYPE_ICM20602);
|
||||
_px4_gyro.set_device_type(DRV_IMU_DEVTYPE_ICM20602);
|
||||
break;
|
||||
|
||||
case MPU_DEVICE_TYPE_ICM20608:
|
||||
_px4_accel.set_device_type(DRV_ACC_DEVTYPE_ICM20608);
|
||||
_px4_gyro.set_device_type(DRV_GYR_DEVTYPE_ICM20608);
|
||||
_px4_accel.set_device_type(DRV_IMU_DEVTYPE_ICM20608);
|
||||
_px4_gyro.set_device_type(DRV_IMU_DEVTYPE_ICM20608);
|
||||
break;
|
||||
|
||||
case MPU_DEVICE_TYPE_ICM20689:
|
||||
_px4_accel.set_device_type(DRV_ACC_DEVTYPE_ICM20689);
|
||||
_px4_gyro.set_device_type(DRV_GYR_DEVTYPE_ICM20689);
|
||||
_px4_accel.set_device_type(DRV_IMU_DEVTYPE_ICM20689);
|
||||
_px4_gyro.set_device_type(DRV_IMU_DEVTYPE_ICM20689);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -81,8 +81,8 @@ MPU9250::MPU9250(device::Device *interface, device::Device *mag_interface, enum
|
||||
_bad_registers(perf_alloc(PC_COUNT, MODULE_NAME": bad_reg")),
|
||||
_duplicates(perf_alloc(PC_COUNT, MODULE_NAME": dupe"))
|
||||
{
|
||||
_px4_accel.set_device_type(DRV_ACC_DEVTYPE_MPU9250);
|
||||
_px4_gyro.set_device_type(DRV_GYR_DEVTYPE_MPU9250);
|
||||
_px4_accel.set_device_type(DRV_IMU_DEVTYPE_MPU9250);
|
||||
_px4_gyro.set_device_type(DRV_IMU_DEVTYPE_MPU9250);
|
||||
}
|
||||
|
||||
MPU9250::~MPU9250()
|
||||
|
||||
@@ -70,7 +70,7 @@ MPU9250_I2C_interface(int bus, uint32_t address)
|
||||
MPU9250_I2C::MPU9250_I2C(int bus, uint32_t address) :
|
||||
I2C("MPU9250_I2C", nullptr, bus, address, 400000)
|
||||
{
|
||||
set_device_type(DRV_ACC_DEVTYPE_MPU9250);
|
||||
set_device_type(DRV_IMU_DEVTYPE_MPU9250);
|
||||
}
|
||||
|
||||
int
|
||||
|
||||
@@ -88,7 +88,7 @@ MPU9250_SPI_interface(int bus, uint32_t cs)
|
||||
MPU9250_SPI::MPU9250_SPI(int bus, uint32_t device) :
|
||||
SPI("MPU9250", nullptr, bus, device, SPIDEV_MODE3, MPU9250_LOW_SPI_BUS_SPEED)
|
||||
{
|
||||
set_device_type(DRV_ACC_DEVTYPE_MPU9250);
|
||||
set_device_type(DRV_IMU_DEVTYPE_MPU9250);
|
||||
}
|
||||
|
||||
void
|
||||
|
||||
@@ -48,9 +48,9 @@ ISM330DLC::ISM330DLC(int bus, uint32_t device, enum Rotation rotation) :
|
||||
_px4_accel(get_device_id(), ORB_PRIO_DEFAULT, rotation),
|
||||
_px4_gyro(get_device_id(), ORB_PRIO_DEFAULT, rotation)
|
||||
{
|
||||
set_device_type(DRV_DEVTYPE_ST_ISM330DLC);
|
||||
_px4_accel.set_device_type(DRV_DEVTYPE_ST_ISM330DLC);
|
||||
_px4_gyro.set_device_type(DRV_DEVTYPE_ST_ISM330DLC);
|
||||
set_device_type(DRV_IMU_DEVTYPE_ST_ISM330DLC);
|
||||
_px4_accel.set_device_type(DRV_IMU_DEVTYPE_ST_ISM330DLC);
|
||||
_px4_gyro.set_device_type(DRV_IMU_DEVTYPE_ST_ISM330DLC);
|
||||
|
||||
_px4_accel.set_update_rate(1000000 / FIFO_INTERVAL);
|
||||
_px4_gyro.set_update_rate(1000000 / FIFO_INTERVAL);
|
||||
|
||||
@@ -67,7 +67,9 @@ SPI::SPI(const char *name, const char *devname, int bus, uint32_t device, enum s
|
||||
// fill in _device_id fields for a SPI device
|
||||
_device_id.devid_s.bus_type = DeviceBusType_SPI;
|
||||
_device_id.devid_s.bus = bus;
|
||||
_device_id.devid_s.address = (uint8_t)device;
|
||||
// Use the 2. LSB byte as SPI address. This is currently 0, but will allow to extend
|
||||
// for multiple instances of the same device on a bus, should that ever be required.
|
||||
_device_id.devid_s.address = (uint8_t)(device >> 8);
|
||||
// devtype needs to be filled in by the driver
|
||||
_device_id.devid_s.devtype = 0;
|
||||
|
||||
|
||||
@@ -128,6 +128,11 @@ if ("${CONFIG_SHMEM}" STREQUAL "1")
|
||||
list(APPEND SRCS parameters_shmem.cpp)
|
||||
else()
|
||||
list(APPEND SRCS parameters.cpp)
|
||||
if(PX4_TESTING)
|
||||
list(APPEND SRCS param_translation_unit_tests.cpp)
|
||||
else()
|
||||
list(APPEND SRCS param_translation.cpp)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(${PX4_PLATFORM} STREQUAL "nuttx")
|
||||
|
||||
@@ -57,6 +57,7 @@
|
||||
#include <parameters/tinybson/tinybson.h>
|
||||
#include "flashparams.h"
|
||||
#include "flashfs.h"
|
||||
#include "../param_translation.h"
|
||||
|
||||
#if 0
|
||||
# define debug(fmt, args...) do { warnx(fmt, ##args); } while(0)
|
||||
@@ -300,6 +301,8 @@ param_import_callback(bson_decoder_t decoder, void *priv, bson_node_t node)
|
||||
goto out;
|
||||
}
|
||||
|
||||
param_modify_on_import(node->name, node->type, v);
|
||||
|
||||
if (param_set_external(param, v, state->mark_saved, true)) {
|
||||
|
||||
debug("error setting value for '%s'", node->name);
|
||||
|
||||
@@ -0,0 +1,126 @@
|
||||
/****************************************************************************
|
||||
*
|
||||
* Copyright (c) 2020 PX4 Development Team. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name PX4 nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#include "param_translation.h"
|
||||
|
||||
|
||||
#include <px4_platform_common/log.h>
|
||||
#include <lib/drivers/device/Device.hpp>
|
||||
#include <drivers/drv_sensor.h>
|
||||
|
||||
bool param_modify_on_import(const char *name, bson_type_t type, void *value)
|
||||
{
|
||||
// translate (SPI) calibration ID parameters. This can be removed after the next release (current release=1.10)
|
||||
|
||||
if (type != BSON_INT32) {
|
||||
return false;
|
||||
}
|
||||
|
||||
int32_t *ivalue = (int32_t *)value;
|
||||
|
||||
const char *cal_id_params[] = {
|
||||
"CAL_ACC0_ID",
|
||||
"CAL_GYRO0_ID",
|
||||
"CAL_MAG0_ID",
|
||||
"TC_A0_ID",
|
||||
"TC_B0_ID",
|
||||
"TC_G0_ID",
|
||||
"CAL_ACC1_ID",
|
||||
"CAL_GYRO1_ID",
|
||||
"CAL_MAG1_ID",
|
||||
"TC_A1_ID",
|
||||
"TC_B1_ID",
|
||||
"TC_G1_ID",
|
||||
"CAL_ACC2_ID",
|
||||
"CAL_GYRO2_ID",
|
||||
"CAL_MAG2_ID",
|
||||
"TC_A2_ID",
|
||||
"TC_B2_ID",
|
||||
"TC_G2_ID",
|
||||
"CAL_ACC_PRIME",
|
||||
"CAL_GYRO_PRIME",
|
||||
"CAL_MAG_PRIME",
|
||||
};
|
||||
bool found = false;
|
||||
|
||||
for (int i = 0; i < sizeof(cal_id_params) / sizeof(cal_id_params[0]); ++i) {
|
||||
if (strcmp(cal_id_params[i], name) == 0) {
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!found) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
device::Device::DeviceId device_id;
|
||||
device_id.devid = (uint32_t) * ivalue;
|
||||
|
||||
// SPI board config translation
|
||||
if (device_id.devid_s.bus_type == device::Device::DeviceBusType_SPI) {
|
||||
device_id.devid_s.address = 0;
|
||||
}
|
||||
|
||||
// deprecated ACC -> IMU translations
|
||||
if (device_id.devid_s.devtype == DRV_ACC_DEVTYPE_MPU6000_LEGACY) {
|
||||
device_id.devid_s.devtype = DRV_IMU_DEVTYPE_MPU6000;
|
||||
}
|
||||
|
||||
if (device_id.devid_s.devtype == DRV_ACC_DEVTYPE_MPU9250_LEGACY) {
|
||||
device_id.devid_s.devtype = DRV_IMU_DEVTYPE_MPU9250;
|
||||
}
|
||||
|
||||
if (device_id.devid_s.devtype == DRV_ACC_DEVTYPE_ICM20602_LEGACY) {
|
||||
device_id.devid_s.devtype = DRV_IMU_DEVTYPE_ICM20602;
|
||||
}
|
||||
|
||||
if (device_id.devid_s.devtype == DRV_ACC_DEVTYPE_ICM20608_LEGACY) {
|
||||
device_id.devid_s.devtype = DRV_IMU_DEVTYPE_ICM20608;
|
||||
}
|
||||
|
||||
if (device_id.devid_s.devtype == DRV_ACC_DEVTYPE_ICM20689_LEGACY) {
|
||||
device_id.devid_s.devtype = DRV_IMU_DEVTYPE_ICM20689;
|
||||
}
|
||||
|
||||
int32_t new_value = (int32_t)device_id.devid;
|
||||
|
||||
if (new_value != *ivalue) {
|
||||
PX4_INFO("param modify: %s, value=0x%x (old=0x%x)", name, new_value, *ivalue);
|
||||
*ivalue = new_value;
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
/****************************************************************************
|
||||
*
|
||||
* Copyright (c) 2020 PX4 Development Team. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name PX4 nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "tinybson/tinybson.h"
|
||||
|
||||
__EXPORT bool param_modify_on_import(const char *name, bson_type_t type, void *value);
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
/****************************************************************************
|
||||
*
|
||||
* Copyright (c) 2020 PX4 Development Team. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name PX4 nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#include "param_translation.h"
|
||||
|
||||
bool param_modify_on_import(const char *name, bson_type_t type, void *value)
|
||||
{
|
||||
// don't modify params for unit tests
|
||||
return false;
|
||||
}
|
||||
@@ -42,6 +42,7 @@
|
||||
*/
|
||||
|
||||
#include "param.h"
|
||||
#include "param_translation.h"
|
||||
#include <parameters/px4_parameters.h>
|
||||
#include "tinybson/tinybson.h"
|
||||
|
||||
@@ -1261,6 +1262,8 @@ param_import_callback(bson_decoder_t decoder, void *priv, bson_node_t node)
|
||||
goto out;
|
||||
}
|
||||
|
||||
param_modify_on_import(node->name, node->type, v);
|
||||
|
||||
if (param_set_internal(param, v, state->mark_saved, true)) {
|
||||
PX4_DEBUG("error setting value for '%s'", node->name);
|
||||
goto out;
|
||||
|
||||
Reference in New Issue
Block a user