You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
444 lines
8.2 KiB
444 lines
8.2 KiB
#!nsh |
|
# |
|
# Standard startup script for sensor drivers. |
|
# |
|
|
|
if ver hwcmp AEROFC_V1 |
|
then |
|
# Aero FC uses separate driver |
|
else |
|
if ver hwcmp CRAZYFLIE |
|
then |
|
# Crazyflie uses separate driver |
|
else |
|
# Configure all I2C buses to 100 KHz as they |
|
# are all external or slow |
|
fmu i2c 1 100000 |
|
fmu i2c 2 100000 |
|
fi |
|
|
|
if ver hwcmp PX4FMU_V4 |
|
then |
|
# We know there are sketchy boards out there |
|
# as chinese companies produce Pixracers without |
|
# fully understanding the critical parts of the |
|
# schematic and BOM, leading to sensor brownouts |
|
# on boot. Original Pixracers following the |
|
# open hardware design do not require this. |
|
fmu sensor_reset 50 |
|
fi |
|
|
|
# External SPI |
|
ms5611 -S start |
|
|
|
# Internal SPI (auto detect ms5611 or ms5607) |
|
ms5611 -T 0 -s start |
|
|
|
# Blacksheep telemetry |
|
bst start |
|
|
|
adc start |
|
fi |
|
|
|
if ver hwcmp NXPHLITE_V3 |
|
then |
|
# Internal I2C (baro) |
|
mpl3115a2 -I start |
|
|
|
# Internal SPI (accel + mag) |
|
fxos8701cq start -a 8 -R 0 |
|
|
|
# Internal SPI (gyro) |
|
fxas21002c start -R 0 |
|
fi |
|
|
|
if ver hwcmp AUAV_X21 |
|
then |
|
# External I2C bus |
|
hmc5883 -C -T -X start |
|
lis3mdl -X start |
|
|
|
# Internal SPI bus ICM-20608-G is rotated 90 deg yaw |
|
mpu6000 -R 2 -T 20608 start |
|
|
|
# Internal SPI bus ICM-20602-G is rotated 90 deg yaw |
|
mpu6000 -R 2 -T 20602 start |
|
|
|
# Internal SPI bus mpu9250 is rotated 90 deg yaw |
|
mpu9250 -R 2 start |
|
fi |
|
|
|
if ver hwcmp PX4FMU_V2 |
|
then |
|
# V2 build hwtypecmp is always false |
|
set BOARD_FMUV3 0 |
|
|
|
# External I2C bus |
|
hmc5883 -C -T -X start |
|
lis3mdl -X start |
|
|
|
# Internal I2C bus |
|
hmc5883 -C -T -I -R 4 start |
|
|
|
# Internal SPI bus ICM-20608-G |
|
mpu6000 -T 20608 start |
|
|
|
# V3 build hwtypecmp supports V2|V2M|V30 |
|
if ver hwtypecmp V30 |
|
then |
|
# Check for Pixhawk 2.0 cube |
|
# external MPU6K is rotated 180 degrees yaw |
|
if mpu6000 -S -R 4 start |
|
then |
|
set BOARD_FMUV3 20 |
|
else |
|
# Check for Pixhawk 2.1 cube |
|
# external MPU9250 is rotated 180 degrees yaw |
|
if mpu9250 -S -R 4 start |
|
then |
|
set BOARD_FMUV3 21 |
|
fi |
|
fi |
|
fi |
|
|
|
# Check if a Pixhack (which reports as V2M) is present |
|
if ver hwtypecmp V2M |
|
then |
|
# Pixhawk Mini doesn't have these sensors, |
|
# so if they are found we know its a Pixhack |
|
|
|
# external MPU6K is rotated 180 degrees yaw |
|
if mpu6000 -S -R 4 start |
|
then |
|
set BOARD_FMUV3 20 |
|
else |
|
# Check for Pixhack 3.1 |
|
# external MPU9250 is rotated 180 degrees yaw |
|
if mpu9250 -S -R 4 start |
|
then |
|
set BOARD_FMUV3 21 |
|
fi |
|
fi |
|
fi |
|
|
|
if [ $BOARD_FMUV3 != 0 ] |
|
then |
|
# sensor heating is available, but we disable it for now |
|
param set SENS_EN_THERMAL 0 |
|
|
|
# external L3GD20H is rotated 180 degrees yaw |
|
l3gd20 -X -R 4 start |
|
|
|
# external LSM303D is rotated 270 degrees yaw |
|
lsm303d -X -R 6 start |
|
|
|
if [ $BOARD_FMUV3 == 20 ] |
|
then |
|
# v2.0 internal MPU6000 is rotated 180 deg roll, 270 deg yaw |
|
mpu6000 -R 14 start |
|
|
|
# v2.0 Has internal hmc5883 on SPI1 |
|
hmc5883 -C -T -S -R 8 start |
|
fi |
|
|
|
if [ $BOARD_FMUV3 == 21 ] |
|
then |
|
# v2.1 internal MPU9250 is rotated 180 deg roll, 270 deg yaw |
|
mpu9250 -R 14 start |
|
fi |
|
|
|
else |
|
# $BOARD_FMUV3 == 0 -> FMUv2 |
|
|
|
mpu6000 start |
|
|
|
# As we will use the external mag and the ICM-20608-G |
|
# V2 build hwtypecmp is always false |
|
# V3 build hwtypecmp supports V2|V2M|V30 |
|
if ver hwtypecmp V2M |
|
then |
|
# On the PixhawkMini the mpu9250 has been disabled due to HW errata |
|
else |
|
mpu9250 start |
|
fi |
|
|
|
l3gd20 start |
|
lsm303d start |
|
fi |
|
|
|
unset BOARD_FMUV3 |
|
fi |
|
|
|
if ver hwcmp PX4_SAME70XPLAINED_V1 |
|
then |
|
# External I2C bus |
|
hmc5883 -C -T -X start |
|
|
|
# Internal SPI bus mpu9250 is rotated 90 deg yaw |
|
mpu9250 -R 2 start |
|
fi |
|
|
|
if ver hwcmp PX4FMU_V4 |
|
then |
|
# External I2C bus |
|
hmc5883 -C -T -X start |
|
lis3mdl -X start |
|
bmp280 -I start |
|
|
|
# expansion i2c used for BMM150 rotated by 90deg |
|
bmm150 -R 2 start |
|
|
|
if hmc5883 -C -T -S -R 2 start |
|
then |
|
# hmc5883 internal SPI bus is rotated 90 deg yaw |
|
else |
|
if lis3mdl -R 2 start |
|
then |
|
# lis3mdl internal SPI bus is rotated 90 deg yaw |
|
else |
|
# BMI055 gyro internal SPI bus |
|
bmi055 -G start |
|
fi |
|
fi |
|
|
|
# Start either ICM2060X or BMI055. They are both connected to the same SPI bus and use the same |
|
# chip select pin. There are different boards with either one of them and the WHO_AM_I register |
|
# will prevent the incorrect driver from a successful initialization. |
|
|
|
if mpu6000 -R 2 -T 20602 start |
|
then |
|
# ICM20602 internal SPI bus ICM-20608-G is rotated 90 deg yaw |
|
else |
|
if mpu6000 -R 2 -T 20608 start |
|
then |
|
# ICM20608 internal SPI bus ICM-20602-G is rotated 90 deg yaw |
|
else |
|
# BMI055 accel internal SPI bus |
|
bmi055 -A start |
|
fi |
|
fi |
|
|
|
# Start either MPU9250 or BMI160. They are both connected to the same SPI bus and use the same |
|
# chip select pin. There are different boards with either one of them and the WHO_AM_I register |
|
# will prevent the incorrect driver from a successful initialization. |
|
|
|
if mpu9250 -R 2 start |
|
then |
|
# mpu9250 internal SPI bus mpu9250 is rotated 90 deg yaw |
|
else |
|
# BMI160 internal SPI bus |
|
bmi160 start |
|
fi |
|
fi |
|
|
|
if ver hwcmp MINDPX_V2 |
|
then |
|
# External I2C bus |
|
hmc5883 -C -T -X start |
|
|
|
# Internal I2C bus |
|
hmc5883 -C -T -I -R 12 start |
|
|
|
mpu6000 -s -R 8 start |
|
mpu9250 -s -R 8 start |
|
lsm303d -R 10 start |
|
l3gd20 -R 14 start |
|
fi |
|
|
|
if ver hwcmp CRAZYFLIE |
|
then |
|
# Onboard I2C |
|
mpu9250 -R 12 start |
|
|
|
# I2C bypass of mpu |
|
lps25h start |
|
fi |
|
|
|
if ver hwcmp AEROFC_V1 |
|
then |
|
ms5611 -T 0 start |
|
mpu9250 -s -R 14 start |
|
|
|
# Possible external compasses |
|
hmc5883 -X start |
|
|
|
ist8310 -C -b 1 -R 4 start |
|
aerofc_adc start |
|
ll40ls start i2c |
|
fi |
|
|
|
if ver hwcmp PX4FMU_V4PRO |
|
then |
|
# Internal SPI bus ICM-20608-G |
|
mpu6000 -R 2 -T 20608 start |
|
|
|
# Internal SPI bus ICM-20602 |
|
mpu6000 -R 2 -T 20602 start |
|
|
|
# Internal SPI bus mpu9250 |
|
mpu9250 -R 2 start |
|
|
|
# Internal SPI bus |
|
lis3mdl -R 0 start |
|
|
|
# Possible external compasses |
|
hmc5883 -C -T -X start |
|
fi |
|
|
|
if ver hwcmp PX4FMU_V5 |
|
then |
|
|
|
# Internal SPI bus ICM-20602 |
|
mpu6000 -R 8 -s -T 20602 start |
|
|
|
# Internal SPI bus ICM-20689 |
|
mpu6000 -R 8 -z -T 20689 start |
|
|
|
# Internal SPI bus BMI055 accel |
|
bmi055 -A -R 10 start |
|
|
|
# Internal SPI bus BMI055 gyro |
|
bmi055 -G -R 10 start |
|
|
|
# Possible external compasses |
|
hmc5883 -C -T -X start |
|
|
|
# Possible external compasses |
|
|
|
ist8310 -C -b 1 start |
|
ist8310 -C -b 2 start |
|
|
|
# Possible internal compass |
|
ist8310 -C -b 5 start |
|
fi |
|
|
|
if ver hwcmp AEROCORE2 |
|
then |
|
l3gd20 -R 12 start |
|
lsm303d start |
|
fi |
|
|
|
# |
|
# Optional drivers |
|
# |
|
|
|
if [ ${VEHICLE_TYPE} == fw -o ${VEHICLE_TYPE} == vtol ] |
|
then |
|
if param compare CBRK_AIRSPD_CHK 0 |
|
then |
|
if sdp3x_airspeed start |
|
then |
|
else |
|
sdp3x_airspeed start -b 2 |
|
fi |
|
|
|
# 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 -b 2 |
|
else |
|
ms5525_airspeed start |
|
fi |
|
|
|
if ms4525_airspeed start |
|
then |
|
else |
|
ms4525_airspeed start -b 2 |
|
fi |
|
|
|
if ets_airspeed start |
|
then |
|
else |
|
ets_airspeed start -b 1 |
|
fi |
|
fi |
|
fi |
|
|
|
# Sensors on the PWM interface bank |
|
if param compare SENS_EN_LL40LS 1 |
|
then |
|
if pwm_input start |
|
then |
|
ll40ls start pwm |
|
fi |
|
fi |
|
|
|
# Lidar-Lite on I2C |
|
if param compare SENS_EN_LL40LS 2 |
|
then |
|
ll40ls start i2c |
|
fi |
|
|
|
# lightware serial lidar sensor |
|
if param greater SENS_EN_SF0X 0 |
|
then |
|
sf0x start |
|
fi |
|
|
|
# lightware i2c lidar sensor |
|
if param greater SENS_EN_SF1XX 0 |
|
then |
|
sf1xx start |
|
fi |
|
|
|
# mb12xx sonar sensor |
|
if param greater SENS_EN_MB12XX 0 |
|
then |
|
mb12xx start |
|
fi |
|
|
|
# teraranger one tof sensor |
|
if param greater SENS_EN_TRANGER 0 |
|
then |
|
teraranger start |
|
fi |
|
|
|
# Benewake TFMini |
|
if param greater SENS_EN_TFMINI 0 |
|
then |
|
if ver hwcmp PX4FMU_V2 PX4FMU_V4PRO |
|
then |
|
# start the driver on serial 4/5 |
|
tfmini start -d /dev/ttyS6 |
|
else |
|
if ver hwcmp AEROFC_V1 |
|
then |
|
# start the driver on telemetry |
|
tfmini start -d /dev/ttyS3 |
|
else |
|
if param compare SYS_COMPANION 0 |
|
then |
|
# start on default mavlink companion device |
|
tfmini start -d /dev/ttyS2 |
|
fi |
|
fi |
|
fi |
|
fi |
|
|
|
# LeddarOne |
|
if param greater SENS_EN_LEDDAR1 0 |
|
then |
|
if ver hwcmp PX4FMU_V2 PX4FMU_V4PRO |
|
then |
|
# start the driver on serial 4/5 |
|
leddar_one -d /dev/ttyS6 start |
|
fi |
|
if ver hwcmp AEROFC_V1 |
|
then |
|
# start the driver on telemetry |
|
leddar_one -d /dev/ttyS3 start |
|
else |
|
if param compare SYS_COMPANION 0 |
|
then |
|
# start on default mavlink companion device |
|
leddar_one -d /dev/ttyS2 start |
|
fi |
|
fi |
|
fi |
|
|
|
# Wait 20 ms for sensors (because we need to wait for the HRT and work queue callbacks to fire) |
|
usleep 20000 |
|
sensors start
|
|
|