34 #include <px4_platform_common/px4_config.h> 35 #include <px4_platform_common/getopt.h> 58 #if defined(PX4_SPI_BUS_EXT) && defined(PX4_SPIDEV_EXT_BARO) 61 #if defined(PX4_SPIDEV_BARO_BUS) && defined(PX4_SPIDEV_BARO) 63 #elif defined(PX4_SPI_BUS_SENSORS) && defined(PX4_SPIDEV_BARO) 66 #if defined(PX4_I2C_BUS_ONBOARD) && defined(PX4_I2C_OBDEV_BMP280) 69 #if defined(PX4_I2C_BUS_EXPANSION) && defined(PX4_I2C_OBDEV_BMP280) 79 busid == bus_option.busid) && bus_option.dev !=
nullptr) {
90 bmp280::IBMP280 *
interface = bus.interface_constructor(bus.busnum, bus.address);
92 if ((interface ==
nullptr) || (interface->init() != PX4_OK)) {
93 PX4_WARN(
"no device on bus %u", (
unsigned)bus.busid);
100 if (dev ==
nullptr) {
101 PX4_ERR(
"driver allocate failed");
106 if (dev->
init() != PX4_OK) {
107 PX4_ERR(
"driver start failed");
120 if (bus_option.dev !=
nullptr) {
122 PX4_WARN(
"already started");
143 if (bus !=
nullptr && bus->
dev !=
nullptr) {
148 PX4_WARN(
"driver not running");
159 if (bus !=
nullptr && bus->
dev !=
nullptr) {
164 PX4_WARN(
"driver not running");
170 PX4_INFO(
"missing command: try 'start', 'stop', 'status'");
171 PX4_INFO(
"options:");
172 PX4_INFO(
" -X (i2c external bus)");
173 PX4_INFO(
" -I (i2c internal bus)");
174 PX4_INFO(
" -s (spi internal bus)");
175 PX4_INFO(
" -S (spi external bus)");
186 const char *myoptarg =
nullptr;
190 while ((ch = px4_getopt(argc, argv,
"XISs:", &myoptind, &myoptarg)) != EOF) {
213 if (myoptind >= argc) {
217 const char *verb = argv[myoptind];
219 if (!strcmp(verb,
"start")) {
222 }
else if (!strcmp(verb,
"stop")) {
225 }
else if (!strcmp(verb,
"status")) {
BMP280_constructor interface_constructor
bmp280::IBMP280 * bmp280_spi_interface(uint8_t busnum, uint32_t device)
static struct bmp280_bus_option * find_bus(BMP280_BUS busid)
static int start(BMP280_BUS busid)
static int stop(BMP280_BUS busid)
void usage(const char *reason)
Print the correct usage.
int bmp280_main(int argc, char *argv[])
bmp280::IBMP280 * bmp280_i2c_interface(uint8_t busnum, uint32_t device)
struct bmp280::bmp280_bus_option bus_options[]
static int status(BMP280_BUS busid)
bmp280::IBMP280 *(* BMP280_constructor)(uint8_t, uint32_t)
static bool start_bus(bmp280_bus_option &bus)