From 6f6efd60b7db2619daff1ec32fabd0fd76e37e75 Mon Sep 17 00:00:00 2001 From: Daniel Agar Date: Mon, 8 Jun 2020 10:28:38 -0400 Subject: [PATCH] boards: centralize optional external I2C sensor start - configured with new parameter SENS_EXT_I2C_PRB --- ROMFS/px4fmu_common/init.d/rc.sensors | 66 +++++++++++-------- .../airmind/mindpx-v2/init/rc.board_sensors | 4 -- boards/av/x-v1/init/rc.board_sensors | 5 -- .../bitcraze/crazyflie/init/rc.board_defaults | 4 +- boards/cuav/x7pro/init/rc.board_sensors | 7 -- boards/hex/cube-orange/init/rc.board_sensors | 6 -- boards/hex/cube-yellow/init/rc.board_sensors | 6 -- .../holybro/durandal-v1/init/rc.board_sensors | 12 +--- boards/holybro/kakutef7/init/rc.board_sensors | 5 -- boards/intel/aerofc-v1/init/rc.board_sensors | 3 - boards/modalai/fc-v1/init/rc.board_sensors | 12 +--- boards/mro/ctrl-zero-f7/init/rc.board_sensors | 7 -- boards/mro/x21-777/init/rc.board_sensors | 6 -- boards/mro/x21/init/rc.board_sensors | 6 -- boards/nxp/fmuk66-v3/init/rc.board_sensors | 6 -- boards/nxp/fmurt1062-v1/init/rc.board_sensors | 19 +----- boards/omnibus/f4sd/init/rc.board_sensors | 3 - boards/px4/fmu-v2/init/rc.board_sensors | 14 ---- boards/px4/fmu-v3/init/rc.board_sensors | 14 ---- boards/px4/fmu-v4/init/rc.board_sensors | 8 --- boards/px4/fmu-v4pro/init/rc.board_sensors | 7 -- boards/px4/fmu-v5/init/rc.board_sensors | 22 +------ boards/px4/fmu-v5x/init/rc.board_sensors | 12 +--- boards/px4/fmu-v6x/init/rc.board_sensors | 12 +--- boards/uvify/core/init/rc.board_defaults | 3 +- src/modules/sensors/sensor_params.c | 11 ++++ 26 files changed, 63 insertions(+), 217 deletions(-) diff --git a/ROMFS/px4fmu_common/init.d/rc.sensors b/ROMFS/px4fmu_common/init.d/rc.sensors index 2380707ccc..b2b7e93975 100644 --- a/ROMFS/px4fmu_common/init.d/rc.sensors +++ b/ROMFS/px4fmu_common/init.d/rc.sensors @@ -21,31 +21,6 @@ fi # Begin Optional drivers # ############################################################################### -if [ ${VEHICLE_TYPE} = fw -o ${VEHICLE_TYPE} = vtol ] -then - if param compare CBRK_AIRSPD_CHK 0 - then - sdp3x_airspeed start -X - sdp3x_airspeed start -X -a 0x22 - - # Pixhawk 2.1 has a MS5611 on I2C which gets wrongly - # detected as MS5525 because the chip manufacturer was so - # clever to assign the same I2C address and skip a WHO_AM_I - # register. - if [ $BOARD_FMUV3 = 21 ] - then - ms5525_airspeed start -X -b 2 - else - ms5525_airspeed start -X - fi - - ms4525_airspeed start -X - - ets_airspeed start -X - - fi -fi - if param compare -s SENS_EN_BATT 1 then batt_smbus start -X @@ -120,10 +95,47 @@ then paw3902 -S start fi +# probe for optional external I2C devices +if param compare SENS_EXT_I2C_PRB 1 +then + # compasses + ak09916 -X -R 6 start # external AK09916 (Here2) is rotated 270 degrees yaw + hmc5883 -T -X start + ist8308 -X start + ist8310 -X start + lis2mdl -X start + lis3mdl -X start + qmc5883 -X start + rm3100 -X start + + # differential pressure sensors + if [ ${VEHICLE_TYPE} = fw -o ${VEHICLE_TYPE} = vtol ] + then + if param compare CBRK_AIRSPD_CHK 0 + then + sdp3x_airspeed start -X + sdp3x_airspeed start -X -a 0x22 + + # Pixhawk 2.1 has a MS5611 on I2C which gets wrongly + # detected as MS5525 because the chip manufacturer was so + # clever to assign the same I2C address and skip a WHO_AM_I + # register. + if [ $BOARD_FMUV3 = 21 ] + then + ms5525_airspeed start -X -b 2 + else + ms5525_airspeed start -X + fi + + ms4525_airspeed start -X + + ets_airspeed start -X + fi + fi +fi + ############################################################################### # End Optional drivers # ############################################################################### -# Wait 20 ms for sensors (because we need to wait for the HRT and work queue callbacks to fire) -usleep 20000 sensors start diff --git a/boards/airmind/mindpx-v2/init/rc.board_sensors b/boards/airmind/mindpx-v2/init/rc.board_sensors index ad4521c331..eef88143cc 100644 --- a/boards/airmind/mindpx-v2/init/rc.board_sensors +++ b/boards/airmind/mindpx-v2/init/rc.board_sensors @@ -5,10 +5,6 @@ adc start -# External I2C bus -hmc5883 -T -X start -qmc5883 -X start - # Internal I2C bus hmc5883 -T -I -R 12 start qmc5883 -I -R 12 start diff --git a/boards/av/x-v1/init/rc.board_sensors b/boards/av/x-v1/init/rc.board_sensors index 862de804f2..961e306621 100644 --- a/boards/av/x-v1/init/rc.board_sensors +++ b/boards/av/x-v1/init/rc.board_sensors @@ -18,8 +18,3 @@ then # try to start adis16497 only if pmw3901 isn't enabled, or parameter doesn't exists adis16497 -S start fi - -# Possible external compasses -ist8310 -X start -hmc5883 -T -X start -qmc5883 -X start diff --git a/boards/bitcraze/crazyflie/init/rc.board_defaults b/boards/bitcraze/crazyflie/init/rc.board_defaults index f621c3d933..fdf37adf70 100644 --- a/boards/bitcraze/crazyflie/init/rc.board_defaults +++ b/boards/bitcraze/crazyflie/init/rc.board_defaults @@ -14,6 +14,6 @@ fi if [ $AUTOCNF = yes ] then - + # don't probe external I2C + param set SENS_EXT_I2C_PRB 0 fi - diff --git a/boards/cuav/x7pro/init/rc.board_sensors b/boards/cuav/x7pro/init/rc.board_sensors index 35b07367c7..b083d028fb 100644 --- a/boards/cuav/x7pro/init/rc.board_sensors +++ b/boards/cuav/x7pro/init/rc.board_sensors @@ -17,10 +17,3 @@ ms5611 -s -b 4 start # SPI6 (internal) icm20649 -s -b 6 -R 2 start ms5611 -s -b 6 start - - -# Possible external compasses -ist8310 -X start -hmc5883 -T -X start -qmc5883 -X start -lis3mdl -X start diff --git a/boards/hex/cube-orange/init/rc.board_sensors b/boards/hex/cube-orange/init/rc.board_sensors index d2f2d33b8d..d6c5c102e8 100644 --- a/boards/hex/cube-orange/init/rc.board_sensors +++ b/boards/hex/cube-orange/init/rc.board_sensors @@ -12,9 +12,3 @@ icm20649 -s -b 1 start ms5611 -s -b 4 start icm20602 -s -b 4 -R 12 start icm20948 -s -b 4 -R 10 -M start - -# Possible external compasses -ist8310 -X start -hmc5883 -T -X start -qmc5883 -X start -lis3mdl -X start diff --git a/boards/hex/cube-yellow/init/rc.board_sensors b/boards/hex/cube-yellow/init/rc.board_sensors index d2f2d33b8d..d6c5c102e8 100644 --- a/boards/hex/cube-yellow/init/rc.board_sensors +++ b/boards/hex/cube-yellow/init/rc.board_sensors @@ -12,9 +12,3 @@ icm20649 -s -b 1 start ms5611 -s -b 4 start icm20602 -s -b 4 -R 12 start icm20948 -s -b 4 -R 10 -M start - -# Possible external compasses -ist8310 -X start -hmc5883 -T -X start -qmc5883 -X start -lis3mdl -X start diff --git a/boards/holybro/durandal-v1/init/rc.board_sensors b/boards/holybro/durandal-v1/init/rc.board_sensors index 32d20c1fa6..df752f632f 100644 --- a/boards/holybro/durandal-v1/init/rc.board_sensors +++ b/boards/holybro/durandal-v1/init/rc.board_sensors @@ -7,19 +7,11 @@ adc start # Internal SPI bus ICM-20689 icm20689 -R 2 -s start -# Internal SPI bus BMI088 accel +# Internal SPI bus BMI088 accel/gyro bmi088 -A -R 10 -s start - -# Internal SPI bus BMI088 gyro bmi088 -G -R 10 -s start -# Possible external compasses -ist8310 -X start -hmc5883 -T -X start -qmc5883 -X start -lis3mdl -X start - -# Possible internal compass +# internal compass ist8310 -I start # Baro on internal SPI diff --git a/boards/holybro/kakutef7/init/rc.board_sensors b/boards/holybro/kakutef7/init/rc.board_sensors index 326b0ee081..637a968373 100644 --- a/boards/holybro/kakutef7/init/rc.board_sensors +++ b/boards/holybro/kakutef7/init/rc.board_sensors @@ -13,8 +13,3 @@ fi # Onboard Baro bmp280 -X start - -# Possible external compasses -ist8310 -X start -hmc5883 -T -X start -qmc5883 -X start diff --git a/boards/intel/aerofc-v1/init/rc.board_sensors b/boards/intel/aerofc-v1/init/rc.board_sensors index e6ec97e668..7dfd1ea869 100644 --- a/boards/intel/aerofc-v1/init/rc.board_sensors +++ b/boards/intel/aerofc-v1/init/rc.board_sensors @@ -12,9 +12,6 @@ fi mpu9250 -s -R 0 start -# Possible external compasses -hmc5883 -X start - ist8310 -I -R 4 start ll40ls start -X diff --git a/boards/modalai/fc-v1/init/rc.board_sensors b/boards/modalai/fc-v1/init/rc.board_sensors index 4db1232d20..3091895108 100644 --- a/boards/modalai/fc-v1/init/rc.board_sensors +++ b/boards/modalai/fc-v1/init/rc.board_sensors @@ -15,19 +15,9 @@ icm20602 -R 12 -s start # Internal SPI bus ICM-42688 icm42688p -R 12 -s start -# Internal SPI bus BMI088 accel +# Internal SPI bus BMI088 accel/gyro bmi088 -A -R 4 -s start - -# Internal SPI bus BMI088 gyro bmi088 -G -R 4 -s start -# Possible external compasses -ist8310 -X start -hmc5883 -T -X start -qmc5883 -X start - # Internal I2C Baro bmp388 -I start - -# External RM3100 -rm3100 -X start diff --git a/boards/mro/ctrl-zero-f7/init/rc.board_sensors b/boards/mro/ctrl-zero-f7/init/rc.board_sensors index 265c7de5e1..079bd61945 100644 --- a/boards/mro/ctrl-zero-f7/init/rc.board_sensors +++ b/boards/mro/ctrl-zero-f7/init/rc.board_sensors @@ -17,10 +17,3 @@ icm20948 -s -R 8 -M start # Interal DPS310 (barometer) dps310 -s start - -# Possible external compasses -ist8310 -X start -hmc5883 -T -X start -qmc5883 -X start -lis3mdl -X start -rm3100 -X start diff --git a/boards/mro/x21-777/init/rc.board_sensors b/boards/mro/x21-777/init/rc.board_sensors index 02e26db95b..1dfd8dea3d 100644 --- a/boards/mro/x21-777/init/rc.board_sensors +++ b/boards/mro/x21-777/init/rc.board_sensors @@ -13,9 +13,3 @@ icm20602 -s -R 8 start # Internal SPI bus mpu9250 mpu9250 -s -R 8 start - -# Possible external compasses -ist8310 -X start -hmc5883 -T -X start -qmc5883 -X start -lis3mdl -X start diff --git a/boards/mro/x21/init/rc.board_sensors b/boards/mro/x21/init/rc.board_sensors index dc78662a46..5efe2747dc 100644 --- a/boards/mro/x21/init/rc.board_sensors +++ b/boards/mro/x21/init/rc.board_sensors @@ -5,12 +5,6 @@ adc start -# External I2C bus -hmc5883 -T -X start -lis3mdl -X start -ist8310 -X start -qmc5883 -X start - # Internal SPI bus ICM-20608-G icm20608g -s -R 8 start diff --git a/boards/nxp/fmuk66-v3/init/rc.board_sensors b/boards/nxp/fmuk66-v3/init/rc.board_sensors index 082b60b6ec..ca32c571cc 100644 --- a/boards/nxp/fmuk66-v3/init/rc.board_sensors +++ b/boards/nxp/fmuk66-v3/init/rc.board_sensors @@ -5,12 +5,6 @@ adc start -# Possible external compasses -hmc5883 -X start -lis3mdl -X start -ist8310 -X start -qmc5883 -X start - # Internal Mag I2C bus roll 180, yaw 90 bmm150 -I -R 10 start diff --git a/boards/nxp/fmurt1062-v1/init/rc.board_sensors b/boards/nxp/fmurt1062-v1/init/rc.board_sensors index 3b6d1d68a3..bc4411fa7b 100644 --- a/boards/nxp/fmurt1062-v1/init/rc.board_sensors +++ b/boards/nxp/fmurt1062-v1/init/rc.board_sensors @@ -23,26 +23,11 @@ icm20602 -R 2 -s start # Internal SPI bus ICM-20689 icm20689 -R 2 -s start -# Internal SPI bus BMI055 accel +# Internal SPI bus BMI055 accel/gyro bmi055 -A -R 10 -s start - -# Internal SPI bus BMI055 gyro bmi055 -G -R 10 -s start -# Possible external compasses -ist8310 -X start -hmc5883 -T -X start -qmc5883 -X start -lis3mdl -X start - -# ICM20948 as external magnetometer on I2C (e.g. Here GPS) -if ! icm20948 -X -R 6 start -then - # external emulated AK09916 (Here2) is rotated 270 degrees yaw - ak09916 -X -R 6 start -fi - -# Possible internal compass +# internal compass ist8310 -I start # Baro on internal SPI diff --git a/boards/omnibus/f4sd/init/rc.board_sensors b/boards/omnibus/f4sd/init/rc.board_sensors index 36741187cd..f00d6bb4d2 100644 --- a/boards/omnibus/f4sd/init/rc.board_sensors +++ b/boards/omnibus/f4sd/init/rc.board_sensors @@ -11,7 +11,4 @@ then icm20602 -s -R 6 start fi -# Possible external compasses -hmc5883 -X start - bmp280 -s start diff --git a/boards/px4/fmu-v2/init/rc.board_sensors b/boards/px4/fmu-v2/init/rc.board_sensors index 3e7fa0b400..eda07d9c72 100644 --- a/boards/px4/fmu-v2/init/rc.board_sensors +++ b/boards/px4/fmu-v2/init/rc.board_sensors @@ -7,13 +7,6 @@ rgbled start -I adc start -# External I2C bus -hmc5883 -T -X start -lis3mdl -X start -ist8310 -X start -qmc5883 -X start -rm3100 -X start - # Internal I2C bus hmc5883 -T -I -R 4 start @@ -71,13 +64,6 @@ then # sensor heating is available, but we disable it for now param set SENS_EN_THERMAL 0 - # ICM20948 as external magnetometer on I2C (e.g. Here GPS) - if ! icm20948 -X -R 6 start - then - # external emulated AK09916 (Here2) is rotated 270 degrees yaw - ak09916 -X -R 6 start - fi - # l3gd20 (external/isolated SPI4) l3gd20 -s -b 4 -R 4 start diff --git a/boards/px4/fmu-v3/init/rc.board_sensors b/boards/px4/fmu-v3/init/rc.board_sensors index 459331466a..f2b4ba683b 100644 --- a/boards/px4/fmu-v3/init/rc.board_sensors +++ b/boards/px4/fmu-v3/init/rc.board_sensors @@ -7,13 +7,6 @@ rgbled start -I adc start -# External I2C bus -hmc5883 -T -X start -lis3mdl -X start -ist8310 -X start -qmc5883 -X start -rm3100 -X start - # Internal I2C bus hmc5883 -T -I -R 4 start @@ -71,13 +64,6 @@ then # sensor heating is available, but we disable it for now param set SENS_EN_THERMAL 0 - # ICM20948 as external magnetometer on I2C (e.g. Here GPS) - if ! icm20948 -X -R 6 start - then - # external emulated AK09916 (Here2) is rotated 270 degrees yaw - ak09916 -X -R 6 start - fi - # l3gd20 (external/isolated SPI4) l3gd20 -s -b 4 -R 4 start diff --git a/boards/px4/fmu-v4/init/rc.board_sensors b/boards/px4/fmu-v4/init/rc.board_sensors index 818a867efb..a5c89bbc3c 100644 --- a/boards/px4/fmu-v4/init/rc.board_sensors +++ b/boards/px4/fmu-v4/init/rc.board_sensors @@ -13,14 +13,6 @@ adc start # open hardware design do not require this. pwm_out sensor_reset 50 - -# External I2C bus -hmc5883 -T -X start -lis3mdl -X start -ist8310 -X start -qmc5883 -X start -rm3100 -X start - # Internal SPI ms5611 -s start diff --git a/boards/px4/fmu-v4pro/init/rc.board_sensors b/boards/px4/fmu-v4pro/init/rc.board_sensors index e45015c342..0b211f0cb9 100644 --- a/boards/px4/fmu-v4pro/init/rc.board_sensors +++ b/boards/px4/fmu-v4pro/init/rc.board_sensors @@ -21,10 +21,3 @@ lis3mdl -s -R 0 start # Internal SPI ms5611 -s start - -# Possible external compasses -hmc5883 -T -X start -lis3mdl -X start -ist8310 -X start -qmc5883 -X start -rm3100 -X start diff --git a/boards/px4/fmu-v5/init/rc.board_sensors b/boards/px4/fmu-v5/init/rc.board_sensors index 873854bd74..27805f1122 100644 --- a/boards/px4/fmu-v5/init/rc.board_sensors +++ b/boards/px4/fmu-v5/init/rc.board_sensors @@ -11,30 +11,12 @@ icm20602 -s -R 2 start # Internal SPI bus ICM-20689 icm20689 -s -R 2 start -# Internal SPI bus BMI055 accel +# Internal SPI bus BMI055 accel/gyro bmi055 -A -R 10 -s start - -# Internal SPI bus BMI055 gyro bmi055 -G -R 10 -s start -# Possible external compasses -ist8310 -X start -hmc5883 -T -X start -qmc5883 -X start -lis3mdl -X start - -# ICM20948 as external magnetometer on I2C (e.g. Here GPS) -if ! icm20948 -X -R 6 start -then - # external emulated AK09916 (Here2) is rotated 270 degrees yaw - ak09916 -X -R 6 start -fi - -# Possible internal compass +# internal compass ist8310 -I start # Baro on internal SPI ms5611 -s start - -# External RM3100 -rm3100 -X start diff --git a/boards/px4/fmu-v5x/init/rc.board_sensors b/boards/px4/fmu-v5x/init/rc.board_sensors index a65fe8117b..de751d3223 100644 --- a/boards/px4/fmu-v5x/init/rc.board_sensors +++ b/boards/px4/fmu-v5x/init/rc.board_sensors @@ -15,17 +15,10 @@ icm20602 -R 2 -s start # Internal SPI bus ISM300DLC ism330dlc -s start -# Internal SPI bus BMI088 accel +# Internal SPI bus BMI088 accel/gyro bmi088 -A -R 12 -s start - -# Internal SPI bus BMI088 gyro bmi088 -G -R 12 -s start -# Possible external compasses -ist8310 -X start -hmc5883 -T -X start -qmc5883 -X start - # Possible internal compass bmm150 -I start @@ -35,6 +28,3 @@ bmp388 -I -a 0x77 start # Baro on I2C3 ms5611 -X start - -# External RM3100 -rm3100 -X start diff --git a/boards/px4/fmu-v6x/init/rc.board_sensors b/boards/px4/fmu-v6x/init/rc.board_sensors index 145c17a9b8..bcc632848e 100644 --- a/boards/px4/fmu-v6x/init/rc.board_sensors +++ b/boards/px4/fmu-v6x/init/rc.board_sensors @@ -15,17 +15,10 @@ icm20649 -R 2 -s start # Internal SPI bus ISM300DLC ism330dlc -s start -# Internal SPI bus BMI088 accel +# Internal SPI bus BMI088 accel/gyro bmi088 -A -R 12 -s start - -# Internal SPI bus BMI088 gyro bmi088 -G -R 12 -s start -# Possible external compasses -ist8310 -X start -hmc5883 -T -X start -qmc5883 -X start - # Possible internal compass bmm150 -I start @@ -35,6 +28,3 @@ bmp388 -I -a 0x77 start # Baro on I2C3 ms5611 -X start - -# External RM3100 -rm3100 -X start diff --git a/boards/uvify/core/init/rc.board_defaults b/boards/uvify/core/init/rc.board_defaults index 0d7410d11a..fb4eddba94 100644 --- a/boards/uvify/core/init/rc.board_defaults +++ b/boards/uvify/core/init/rc.board_defaults @@ -9,5 +9,6 @@ then # Disable safety switch by default param set CBRK_IO_SAFETY 22027 + # don't probe external I2C + param set SENS_EXT_I2C_PRB 0 fi - diff --git a/src/modules/sensors/sensor_params.c b/src/modules/sensors/sensor_params.c index 8e036e348d..1e2de63ff1 100644 --- a/src/modules/sensors/sensor_params.c +++ b/src/modules/sensors/sensor_params.c @@ -191,3 +191,14 @@ PARAM_DEFINE_FLOAT(SENS_BOARD_Z_OFF, 0.0f); * @group Sensors */ PARAM_DEFINE_INT32(SENS_EN_THERMAL, -1); + +/** + * External I2C probe. + * + * Probe for optional external I2C devices. + * + * @boolean + * @category system + * @group Sensors + */ +PARAM_DEFINE_INT32(SENS_EXT_I2C_PRB, 1);