From c38c78d7186fcd7de5f2dcb334222a2e22a3578a Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Mon, 27 Jan 2020 17:32:14 +1100 Subject: [PATCH] AP_OpticalFlow: probe all I2C buses for px4flow on Hex Cubes --- libraries/AP_OpticalFlow/AP_OpticalFlow_PX4Flow.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/libraries/AP_OpticalFlow/AP_OpticalFlow_PX4Flow.cpp b/libraries/AP_OpticalFlow/AP_OpticalFlow_PX4Flow.cpp index 32246249ac..e86ca16d28 100644 --- a/libraries/AP_OpticalFlow/AP_OpticalFlow_PX4Flow.cpp +++ b/libraries/AP_OpticalFlow/AP_OpticalFlow_PX4Flow.cpp @@ -24,6 +24,7 @@ #include #include "OpticalFlow.h" #include +#include extern const AP_HAL::HAL& hal; @@ -60,7 +61,9 @@ bool AP_OpticalFlow_PX4Flow::scan_buses(void) uint8_t retry_attempt = 0; while (!success && retry_attempt < PX4FLOW_INIT_RETRIES) { - FOREACH_I2C_EXTERNAL(bus) { + bool all_external = (AP_BoardConfig::get_board_type() == AP_BoardConfig::PX4_BOARD_PIXHAWK2); + uint32_t bus_mask = all_external? hal.i2c_mgr->get_bus_mask() : hal.i2c_mgr->get_bus_mask_external(); + FOREACH_I2C_MASK(bus, bus_mask) { #ifdef HAL_OPTFLOW_PX4FLOW_I2C_BUS // only one bus from HAL if (bus != HAL_OPTFLOW_PX4FLOW_I2C_BUS) {