59 #ifdef PX4_I2C_BUS_EXPANSION1 62 #ifdef PX4_I2C_BUS_EXPANSION2 65 #ifdef PX4_I2C_BUS_ONBOARD 68 #ifdef PX4_SPIDEV_LPS22HB 72 #define NUM_BUS_OPTIONS (sizeof(bus_options)/sizeof(bus_options[0])) 75 bool start_bus(
struct lps22hb_bus_option &bus);
87 PX4_INFO(
"starting %s", bus.
devpath);
89 if (bus.
dev !=
nullptr) {
90 PX4_WARN(
"bus option already started");
96 if (interface->init() !=
OK) {
98 PX4_WARN(
"no device on bus %u", (
unsigned)bus.busid);
102 bus.dev =
new LPS22HB(interface, bus.devpath);
104 if (bus.dev !=
nullptr &&
OK != bus.dev->init()) {
105 PX4_WARN(
"init failed");
115 PX4_ERR(
"can't open baro device");
121 PX4_ERR(
"failed setting default poll rate");
140 bool started =
false;
175 errx(1,
"bus %u not started", (
unsigned)busid);
185 const char *path = bus.
devpath;
187 int fd = open(path, O_RDONLY);
195 PX4_ERR(
"driver reset failed");
200 PX4_ERR(
"driver poll restart failed");
216 if (bus.dev !=
nullptr) {
217 warnx(
"%s", bus.devpath);
218 bus.dev->print_info();
228 PX4_INFO(
"missing command: try 'start', 'info', 'reset'");
229 PX4_INFO(
"options:");
230 PX4_INFO(
" -X (external I2C bus)");
231 PX4_INFO(
" -I (internal I2C bus)");
232 PX4_INFO(
" -S (external SPI bus)");
242 const char *myoptarg =
nullptr;
246 while ((ch = px4_getopt(argc, argv,
"IXS", &myoptind, &myoptarg)) != EOF) {
248 #if (PX4_I2C_BUS_ONBOARD) 269 if (myoptind >= argc) {
274 const char *verb = argv[myoptind];
279 if (!strcmp(verb,
"start")) {
286 if (!strcmp(verb,
"reset")) {
293 if (!strcmp(verb,
"info")) {
297 PX4_WARN(
"unrecognised command, try 'start', 'reset' or 'info'");
struct lps22hb::lps22hb_bus_option bus_options[]
#define SENSOR_POLLRATE_DEFAULT
poll at driver normal rate
int info()
Print a little info about the driver.
int reset(enum LPS22HB_BUS busid)
Reset the driver.
int start(enum LPS22HB_BUS busid)
Start the driver.
LPS22HB_constructor interface_constructor
void usage()
Prints info about the driver argument usage.
struct lps22hb_bus_option & find_bus(enum LPS22HB_BUS busid)
find a bus structure for a busid
#define SENSORIOCSPOLLRATE
Set the driver polling rate to (arg) Hz, or one of the SENSOR_POLLRATE constants. ...
device::Device * LPS22HB_I2C_interface(int bus)
device::Device * LPS22HB_SPI_interface(int bus)
bool start_bus(struct lps22hb_bus_option &bus)
start driver for a specific bus option
device::Device *(* LPS22HB_constructor)(int)
__EXPORT int lps22hb_main(int argc, char *argv[])
#define SENSORIOCRESET
Reset the sensor to its default configuration.
Fundamental base class for all physical drivers (I2C, SPI).
Local functions in support of the shell command.