airspeed sensor: use bus_option array from i2c.h instead of one in each driver

This commit is contained in:
DanielePettenuzzo
2018-07-03 17:33:18 +02:00
committed by Beat Küng
parent 6cb17839ee
commit 84f937a098
4 changed files with 9 additions and 85 deletions
@@ -43,23 +43,6 @@ namespace ms5525_airspeed
{
MS5525 *g_dev = nullptr;
int bus_options[] = {
#ifdef PX4_I2C_BUS_EXPANSION
PX4_I2C_BUS_EXPANSION,
#endif
#ifdef PX4_I2C_BUS_EXPANSION1
PX4_I2C_BUS_EXPANSION1,
#endif
#ifdef PX4_I2C_BUS_EXPANSION2
PX4_I2C_BUS_EXPANSION2,
#endif
#ifdef PX4_I2C_BUS_ONBOARD
PX4_I2C_BUS_ONBOARD,
#endif
};
#define NUM_BUS_OPTIONS (sizeof(bus_options)/sizeof(bus_options[0]))
int start();
int start_bus(uint8_t i2c_bus);
int stop();
@@ -76,8 +59,8 @@ int reset();
int
start()
{
for (unsigned i = 0; i < NUM_BUS_OPTIONS; i++) {
if (start_bus(bus_options[i]) == PX4_OK) {
for (unsigned i = 0; i < NUM_I2C_BUS_OPTIONS; i++) {
if (start_bus(i2c_bus_options[i]) == PX4_OK) {
return PX4_OK;
}
}
@@ -133,8 +116,6 @@ fail:
g_dev = nullptr;
}
PX4_WARN("not started on bus %d", i2c_bus);
return PX4_ERROR;
}