Browse Source

Airspeed sensor driver operational, needs cleanup / testing

sbg
Lorenz Meier 12 years ago
parent
commit
edcd25b5ed
  1. 47
      src/drivers/meas_airspeed/meas_airspeed.cpp

47
src/drivers/meas_airspeed/meas_airspeed.cpp

@ -85,13 +85,10 @@
#include <drivers/airspeed/airspeed.h> #include <drivers/airspeed/airspeed.h>
/* Default I2C bus */
#define PX4_I2C_BUS_DEFAULT PX4_I2C_BUS_EXPANSION
/* I2C bus address is 1010001x */ /* I2C bus address is 1010001x */
#define I2C_ADDRESS_MS4525DO 0x51 /* 7-bit address. */ #define I2C_ADDRESS_MS4525DO 0x28 //0x51 /* 7-bit address. */
/* The MS5525DSO address is 111011Cx, where C is the complementary value of the pin CSB */ /* The MS5525DSO address is 111011Cx, where C is the complementary value of the pin CSB */
#define I2C_ADDRESS_MS5525DSO 0x77 /* 7-bit address, addr. pin pulled low */ #define I2C_ADDRESS_MS5525DSO 0x77 //0x77/* 7-bit address, addr. pin pulled low */
/* Register address */ /* Register address */
#define ADDR_RESET_CMD 0x1E /* write to this address to reset chip */ #define ADDR_RESET_CMD 0x1E /* write to this address to reset chip */
@ -298,49 +295,14 @@ start(int i2c_bus)
errx(1, "already started"); errx(1, "already started");
/* create the driver, try the MS4525DO first */ /* create the driver, try the MS4525DO first */
//g_dev = new MEASAirspeed(i2c_bus, I2C_ADDRESS_MS4525DO); g_dev = new MEASAirspeed(i2c_bus, I2C_ADDRESS_MS4525DO);
int bus = PX4_I2C_BUS_EXPANSION;
//delete g_dev;
// XXX hack scan all addresses
for (int i = 0x20 / 2; i < 0xFE / 2; i++) {
warnx("scanning addr (7 bit): 0x%02x", i);
g_dev = new MEASAirspeed(bus, i);
warnx("probing");
if (OK == g_dev->Airspeed::init()) {
warnx("SUCCESS!");
usleep(200000);
exit(0);
} else {
warnx("FAIL!");
usleep(200000);
delete g_dev;
}
}
bus = PX4_I2C_BUS_ESC;
for (int i = 1; i < 0xFF / 2; i++) {
warnx("scanning addr (7 bit): %0x", i);
g_dev = new MEASAirspeed(bus, i);
if (OK == g_dev->Airspeed::init()) {
warnx("SUCCESS!");
exit(0);
} else {
delete g_dev;
}
}
/* check if the MS4525DO was instantiated */ /* check if the MS4525DO was instantiated */
if (g_dev == nullptr) if (g_dev == nullptr)
goto fail; goto fail;
/* try the MS5525DSO next if init fails */ /* try the MS5525DSO next if init fails */
if (OK != g_dev->Airspeed::init()) if (OK != g_dev->Airspeed::init()) {
delete g_dev; delete g_dev;
g_dev = new MEASAirspeed(i2c_bus, I2C_ADDRESS_MS5525DSO); g_dev = new MEASAirspeed(i2c_bus, I2C_ADDRESS_MS5525DSO);
@ -351,6 +313,7 @@ start(int i2c_bus)
/* both versions failed if the init for the MS5525DSO fails, give up */ /* both versions failed if the init for the MS5525DSO fails, give up */
if (OK != g_dev->Airspeed::init()) if (OK != g_dev->Airspeed::init())
goto fail; goto fail;
}
/* set the poll rate to default, starts automatic data collection */ /* set the poll rate to default, starts automatic data collection */
fd = open(AIRSPEED_DEVICE_PATH, O_RDONLY); fd = open(AIRSPEED_DEVICE_PATH, O_RDONLY);

Loading…
Cancel
Save