diff --git a/libraries/AP_HAL/board/linux.h b/libraries/AP_HAL/board/linux.h index 57f2247523..58e131879f 100644 --- a/libraries/AP_HAL/board/linux.h +++ b/libraries/AP_HAL/board/linux.h @@ -7,6 +7,11 @@ #define HAL_STORAGE_SIZE 16384 #define HAL_STORAGE_SIZE_AVAILABLE HAL_STORAGE_SIZE +// make sensor selection clearer +#define PROBE_IMU_I2C(driver, bus, addr, args ...) ADD_BACKEND(AP_InertialSensor_ ## driver::probe(*this,hal.i2c_mgr->get_device(bus, addr),##args)) +#define PROBE_IMU_SPI(driver, devname, args ...) ADD_BACKEND(AP_InertialSensor_ ## driver::probe(*this,hal.spi->get_device(devname),##args)) +#define PROBE_IMU_SPI2(driver, devname1, devname2, args ...) ADD_BACKEND(AP_InertialSensor_ ## driver::probe(*this,hal.spi->get_device(devname1),hal.spi->get_device(devname2),##args)) + #if CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_NONE #define HAL_BOARD_LOG_DIRECTORY "logs" #define HAL_BOARD_TERRAIN_DIRECTORY "terrain" @@ -15,13 +20,11 @@ #define HAL_BARO_DEFAULT HAL_BARO_HIL #define HAL_COMPASS_DEFAULT HAL_COMPASS_HIL #elif CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_PXF || CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_ERLEBOARD - #define HAL_INS_DEFAULT HAL_INS_MPU9250_SPI #if CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_PXF - #define HAL_INS_DEFAULT_ROTATION ROTATION_ROLL_180_YAW_270 + #define HAL_INS_PROBE_LIST PROBE_IMU_SPI(Invensense, "mpu9250", ROTATION_ROLL_180_YAW_270) #else - #define HAL_INS_DEFAULT_ROTATION ROTATION_ROLL_180_YAW_90 + #define HAL_INS_PROBE_LIST PROBE_IMU_SPI(Invensense, "mpu9250", ROTATION_ROLL_180_YAW_90) #endif - #define HAL_INS_MPU9250_NAME "mpu9250" #define HAL_BARO_DEFAULT HAL_BARO_MS5611_SPI #define HAL_BARO_MS5611_NAME "ms5611" #define HAL_COMPASS_DEFAULT HAL_COMPASS_AK8963_MPU9250 @@ -36,10 +39,7 @@ #define HAL_BOARD_LOG_DIRECTORY "/data/ftp/internal_000/ardupilot/logs" #define HAL_BOARD_TERRAIN_DIRECTORY "/data/ftp/internal_000/ardupilot/terrain" #define HAL_BOARD_STORAGE_DIRECTORY "/data/ftp/internal_000/ardupilot" - #define HAL_INS_DEFAULT HAL_INS_MPU60XX_I2C - #define HAL_INS_DEFAULT_ROTATION ROTATION_YAW_270 - #define HAL_INS_MPU60x0_I2C_BUS 2 - #define HAL_INS_MPU60x0_I2C_ADDR 0x68 + #define HAL_INS_PROBE_LIST PROBE_IMU_I2C(Invensense, 2, 0x68, ROTATION_YAW_270) #define HAL_COMPASS_DEFAULT HAL_COMPASS_AK8963_I2C #define HAL_COMPASS_AK8963_I2C_BUS 1 #define HAL_COMPASS_AK8963_I2C_ADDR 0x0d @@ -80,10 +80,7 @@ #define HAL_BOARD_LOG_DIRECTORY "/data/ftp/internal_000/ardupilot/logs" #define HAL_BOARD_TERRAIN_DIRECTORY "/data/ftp/internal_000/ardupilot/terrain" #define HAL_BOARD_STORAGE_DIRECTORY "/data/ftp/internal_000/ardupilot" - #define HAL_INS_DEFAULT HAL_INS_MPU60XX_I2C - #define HAL_INS_DEFAULT_ROTATION ROTATION_PITCH_180_YAW_90 - #define HAL_INS_MPU60x0_I2C_BUS 2 - #define HAL_INS_MPU60x0_I2C_ADDR 0x68 + #define HAL_INS_PROBE_LIST PROBE_IMU_I2C(Invensense, 2, 0x68, ROTATION_PITCH_180_YAW_90) #define HAL_COMPASS_DEFAULT HAL_COMPASS_AK8963_I2C #define HAL_COMPASS_AK8963_I2C_BUS 1 #define HAL_COMPASS_AK8963_I2C_ADDR 0x0d @@ -127,9 +124,7 @@ #define HAL_GPIO_C_LED_PIN 2 #define HAL_GPIO_LED_ON HIGH #define HAL_GPIO_LED_OFF LOW - #define HAL_INS_DEFAULT HAL_INS_MPU9250_SPI - #define HAL_INS_DEFAULT_ROTATION ROTATION_NONE - #define HAL_INS_MPU9250_NAME "mpu9250" + #define HAL_INS_PROBE_LIST PROBE_IMU_SPI(Invensense, "mpu9250", ROTATION_NONE) #define HAL_BARO_DEFAULT HAL_BARO_MS5611_I2C #define HAL_BARO_MS5611_I2C_BUS 1 #define HAL_BARO_MS5611_I2C_ADDR 0x77 @@ -139,9 +134,7 @@ #define HAL_COMPASS_HMC5843_I2C_ADDR 0x1E #elif CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_NAVIO2 #define HAL_HAVE_SERVO_VOLTAGE 1 - #define HAL_INS_DEFAULT HAL_INS_MPU9250_SPI - #define HAL_INS_DEFAULT_ROTATION ROTATION_NONE - #define HAL_INS_MPU9250_NAME "mpu9250" + #define HAL_INS_PROBE_LIST PROBE_IMU_SPI(Invensense, "mpu9250", ROTATION_NONE) #define HAL_INS_LSM9DS1_NAME "lsm9ds1" #define HAL_BARO_DEFAULT HAL_BARO_MS5611_I2C #define HAL_BARO_MS5611_I2C_BUS 1 @@ -151,9 +144,7 @@ #define HAL_COMPASS_HMC5843_I2C_BUS 1 #define HAL_COMPASS_HMC5843_I2C_ADDR 0x1E #elif CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_ERLEBRAIN2 - #define HAL_INS_DEFAULT HAL_INS_MPU9250_SPI - #define HAL_INS_DEFAULT_ROTATION ROTATION_YAW_270 - #define HAL_INS_MPU9250_NAME "mpu9250" + #define HAL_INS_PROBE_LIST PROBE_IMU_SPI(Invensense, "mpu9250", ROTATION_YAW_270) #define HAL_BARO_DEFAULT HAL_BARO_MS5611_SPI #define HAL_BARO_MS5611_NAME "ms5611" #define HAL_COMPASS_DEFAULT HAL_COMPASS_AK8963_MPU9250 @@ -171,9 +162,7 @@ #define HAL_BARO_DEFAULT HAL_BARO_HIL #define HAL_COMPASS_DEFAULT HAL_COMPASS_HIL #elif CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_OCPOC_ZYNQ - #define HAL_INS_DEFAULT HAL_INS_MPU9250_SPI - #define HAL_INS_DEFAULT_ROTATION ROTATION_NONE - #define HAL_INS_MPU9250_NAME "mpu9250" + #define HAL_INS_PROBE_LIST PROBE_IMU_SPI(Invensense, "mpu9250", ROTATION_NONE) #define HAL_BARO_DEFAULT HAL_BARO_MS5611_SPI #define HAL_BARO_MS5611_NAME "ms5611" #define HAL_COMPASS_DEFAULT HAL_COMPASS_OCPOC_ZYNQ @@ -188,10 +177,9 @@ #define HAL_GPIO_LED_ON LOW #define HAL_GPIO_LED_OFF HIGH #define HAL_BUZZER_PIN 11 - #define HAL_INS_DEFAULT HAL_INS_BBBMINI - #define HAL_INS_DEFAULT_ROTATION ROTATION_NONE - #define HAL_INS_MPU9250_NAME "mpu9250" - #define HAL_INS_MPU9250_NAME_EXT "mpu9250ext" + #define HAL_INS_PROBE1 PROBE_IMU_SPI(Invensense, "mpu9250", ROTATION_NONE) + #define HAL_INS_PROBE2 PROBE_IMU_SPI(Invensense, "mpu9250ext", ROTATION_NONE) + #define HAL_INS_PROBE_LIST HAL_INS_PROBE1; HAL_INS_PROBE2 #define HAL_BARO_DEFAULT HAL_BARO_MS5611_SPI #define HAL_BARO_MS5611_NAME "ms5611" #define HAL_COMPASS_DEFAULT HAL_COMPASS_BBBMINI @@ -206,10 +194,7 @@ #define HAL_GPIO_B_LED_PIN 67 #define HAL_GPIO_LED_ON HIGH #define HAL_GPIO_LED_OFF LOW - #define HAL_INS_DEFAULT HAL_INS_MPU9250_I2C - #define HAL_INS_MPU9250_I2C_BUS 2 - #define HAL_INS_MPU9250_I2C_ADDR 0x68 - #define HAL_INS_DEFAULT_ROTATION ROTATION_NONE + #define HAL_INS_PROBE_LIST PROBE_IMU_I2C(Invensense, 2, 0x68, ROTATION_NONE) #define HAL_BARO_DEFAULT HAL_BARO_BMP280_I2C #define HAL_BARO_BMP280_BUS 2 #define HAL_BARO_BMP280_I2C_ADDR 0x76 @@ -229,9 +214,7 @@ #define HAL_GPIO_LED_ON HIGH #define HAL_GPIO_LED_OFF LOW #define HAL_BUZZER_PIN 28 - #define HAL_INS_DEFAULT HAL_INS_MPU9250_SPI - #define HAL_INS_MPU9250_NAME "mpu9250" - #define HAL_INS_DEFAULT_ROTATION ROTATION_NONE + #define HAL_INS_PROBE_LIST PROBE_IMU_SPI(Invensense, "mpu9250", ROTATION_NONE) #define HAL_BARO_DEFAULT HAL_BARO_BMP280_SPI #define HAL_BARO_BMP280_NAME "bmp280" #define HAL_COMPASS_DEFAULT HAL_COMPASS_AK8963_MPU9250 @@ -245,10 +228,9 @@ #define HAL_BARO_DEFAULT HAL_BARO_MS5611_I2C #define HAL_BARO_MS5611_I2C_BUS 1 #define HAL_BARO_MS5611_I2C_ADDR 0x77 - #define HAL_INS_DEFAULT HAL_INS_BH - #define HAL_INS_MPU9250_NAME "mpu9250" - #define HAL_INS_MPU60x0_I2C_BUS 1 - #define HAL_INS_MPU60x0_I2C_ADDR 0x69 + #define HAL_INS_PROBE1 PROBE_IMU_I2C(Invensense, 1, 0x69, ROTATION_NONE) + #define HAL_INS_PROBE2 PROBE_IMU_SPI(Invensense, "mpu9250", ROTATION_NONE) + #define HAL_INS_PROBE_LIST HAL_INS_PROBE1; HAL_INS_PROBE2 #define HAL_COMPASS_DEFAULT HAL_COMPASS_BH /* HMC5843 can be an external compass */ #define HAL_COMPASS_HMC5843_I2C_BUS 1 @@ -262,9 +244,7 @@ #define HAL_RCOUT_RGBLED_GREEN 14 #define HAL_RCOUT_RGBLED_BLUE 15 #elif CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_PXFMINI - #define HAL_INS_DEFAULT HAL_INS_MPU9250_SPI - #define HAL_INS_DEFAULT_ROTATION ROTATION_YAW_270 - #define HAL_INS_MPU9250_NAME "mpu9250" + #define HAL_INS_PROBE_LIST PROBE_IMU_SPI(Invensense, "mpu9250", ROTATION_YAW_270) #define HAL_BARO_DEFAULT HAL_BARO_MS5611_SPI #define HAL_BARO_MS5611_NAME "ms5611" #define HAL_COMPASS_DEFAULT HAL_COMPASS_AK8963_MPU9250 @@ -277,7 +257,7 @@ #define HAL_GPIO_LED_ON LOW #define HAL_GPIO_LED_OFF HIGH #elif CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_AERO - #define HAL_INS_DEFAULT HAL_INS_AERO + #define HAL_INS_PROBE_LIST PROBE_IMU_SPI(BMI160, "bmi160") #define HAL_BARO_DEFAULT HAL_BARO_MS5611_I2C #define HAL_BARO_MS5611_I2C_BUS 2 #define HAL_BARO_MS5611_I2C_ADDR 0x76 @@ -291,9 +271,7 @@ #define HAL_RCOUTPUT_TAP_DEVICE "/dev/ttyS1" #define HAL_WITH_UAVCAN 1 #elif CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_DARK - #define HAL_INS_DEFAULT HAL_INS_MPU9250_SPI - #define HAL_INS_DEFAULT_ROTATION ROTATION_NONE - #define HAL_INS_MPU9250_NAME "mpu9250" + #define HAL_INS_PROBE_LIST PROBE_IMU_SPI(Invensense, "mpu9250", ROTATION_NONE) #define HAL_COMPASS_DEFAULT HAL_COMPASS_AK8963_MPU9250 #define HAL_BARO_DEFAULT HAL_BARO_MS5611_I2C #define HAL_BARO_MS5611_I2C_BUS 1 @@ -308,9 +286,9 @@ #define HAL_BOARD_LOG_DIRECTORY "/edge/ardupilot/logs" #define HAL_BOARD_TERRAIN_DIRECTORY "/edge/ardupilot/terrain" #define HAL_BOARD_STORAGE_DIRECTORY "/edge/ardupilot" - #define HAL_INS_DEFAULT HAL_INS_EDGE - #define HAL_INS_MPU60x0_NAME "mpu60x0" - #define HAL_INS_MPU60x0_NAME_EXT "mpu60x0ext" + #define HAL_INS_PROBE1 PROBE_IMU_SPI(Invensense, "mpu60x0", ROTATION_YAW_90) + #define HAL_INS_PROBE2 PROBE_IMU_SPI(Invensense, "mpu60x0ext", ROTATION_YAW_90) + #define HAL_INS_PROBE_LIST HAL_INS_PROBE1; HAL_INS_PROBE2 #define HAL_BARO_DEFAULT HAL_BARO_MS5611_SPI #define HAL_BARO_MS5611_NAME "ms5611" #define HAL_COMPASS_HMC5843_I2C_BUS 1 @@ -330,11 +308,7 @@ #define HAL_GPS_TYPE_DEFAULT 9 #define HAL_CAN_DRIVER_DEFAULT 1 #elif CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_RST_ZYNQ - #define HAL_INS_DEFAULT HAL_INS_RST - #define HAL_INS_DEFAULT_G_ROTATION ROTATION_ROLL_180_YAW_90 - #define HAL_INS_DEFAULT_A_ROTATION ROTATION_ROLL_180_YAW_90 - #define HAL_INS_RST_G_NAME "rst_g" //gyro - #define HAL_INS_RST_A_NAME "rst_a" //accel + #define HAL_INS_PROBE_LIST PROBE_IMU_SPI2(Invensense, "rst_g", "rst_a", ROTATION_ROLL_180_YAW_90, ROTATION_ROLL_180_YAW_90) #define HAL_BARO_DEFAULT HAL_BARO_MS5611_SPI #define HAL_BARO_MS5611_NAME "ms5611" #define HAL_COMPASS_DEFAULT HAL_COMPASS_LIS3MDL