AP_OpticalFlow: probe all I2C buses for px4flow on Hex Cubes
This commit is contained in:
parent
53ce463a90
commit
b47181a86f
@ -24,6 +24,7 @@
|
|||||||
#include <utility>
|
#include <utility>
|
||||||
#include "OpticalFlow.h"
|
#include "OpticalFlow.h"
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include <AP_BoardConfig/AP_BoardConfig.h>
|
||||||
|
|
||||||
extern const AP_HAL::HAL& hal;
|
extern const AP_HAL::HAL& hal;
|
||||||
|
|
||||||
@ -60,7 +61,9 @@ bool AP_OpticalFlow_PX4Flow::scan_buses(void)
|
|||||||
uint8_t retry_attempt = 0;
|
uint8_t retry_attempt = 0;
|
||||||
|
|
||||||
while (!success && retry_attempt < PX4FLOW_INIT_RETRIES) {
|
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
|
#ifdef HAL_OPTFLOW_PX4FLOW_I2C_BUS
|
||||||
// only one bus from HAL
|
// only one bus from HAL
|
||||||
if (bus != HAL_OPTFLOW_PX4FLOW_I2C_BUS) {
|
if (bus != HAL_OPTFLOW_PX4FLOW_I2C_BUS) {
|
||||||
|
Loading…
Reference in New Issue
Block a user