vl53lxx driver: add -b, -a and -R flags to choose i2c busses and sensor rotation and remove nuttx stuff such as exit functions

This commit is contained in:
DanielePettenuzzo
2018-07-03 17:33:18 +02:00
committed by Beat Küng
parent 040662ff04
commit 5b259a008a
3 changed files with 142 additions and 63 deletions
@@ -53,13 +53,11 @@
#include <string.h>
#include <fcntl.h>
#include <poll.h>
#include <errno.h>
#include <stdio.h>
#include <math.h>
#include <unistd.h>
#include <perf/perf_counter.h>
#include <systemlib/err.h>
#include <drivers/drv_hrt.h>
#include <drivers/drv_range_finder.h>
@@ -784,6 +782,11 @@ int info();
int
start(uint8_t rotation)
{
if (g_dev != nullptr) {
PX4_ERR("already started");
return PX4_ERROR;
}
for (unsigned i = 0; i < NUM_BUS_OPTIONS; i++) {
if (start_bus(rotation, bus_options[i]) == PX4_OK) {
return PX4_OK;
@@ -802,12 +805,7 @@ start(uint8_t rotation)
int
start_bus(uint8_t rotation, int i2c_bus)
{
int fd;
if (g_dev != nullptr) {
PX4_ERR("already started");
return PX4_ERROR;
}
int fd = -1;
/* create the driver */
g_dev = new TERARANGER(rotation, i2c_bus);
@@ -832,10 +830,15 @@ start_bus(uint8_t rotation, int i2c_bus)
goto fail;
}
close(fd);
return PX4_OK;
fail:
if (fd >= 0) {
close(fd);
}
if (g_dev != nullptr) {
delete g_dev;
g_dev = nullptr;
@@ -929,6 +932,7 @@ test()
return PX4_ERROR;
}
close(fd);
PX4_INFO("PASS");
return PX4_OK;
@@ -957,6 +961,7 @@ reset()
return PX4_ERROR;
}
close(fd);
return PX4_OK;
}