67 if (*g_dev_ptr !=
nullptr)
70 errx(0,
"already started");
75 #if defined(PX4_SPI_BUS_EXT) && defined(PX4_SPIDEV_EXT_BMI) 76 *g_dev_ptr =
new BMI160(PX4_SPI_BUS_EXT, PX4_SPIDEV_EXT_BMI, rotation);
78 errx(0,
"External SPI not available");
82 #if defined(PX4_SPIDEV_BMI) 83 *g_dev_ptr =
new BMI160(PX4_SPI_BUS_SENSORS, PX4_SPIDEV_BMI, rotation);
85 errx(0,
"No Internal SPI CS");
89 if (*g_dev_ptr ==
nullptr) {
93 if (
OK != (*g_dev_ptr)->init()) {
100 if (*g_dev_ptr !=
nullptr) {
102 *g_dev_ptr =
nullptr;
105 errx(1,
"driver start failed");
113 if (*g_dev_ptr !=
nullptr) {
115 *g_dev_ptr =
nullptr;
119 warnx(
"already stopped.");
133 if (*g_dev_ptr ==
nullptr) {
134 errx(1,
"driver not running");
137 printf(
"state @ %p\n", *g_dev_ptr);
138 (*g_dev_ptr)->print_info();
151 if (*g_dev_ptr ==
nullptr) {
152 errx(1,
"driver not running");
155 printf(
"regdump @ %p\n", *g_dev_ptr);
156 (*g_dev_ptr)->print_registers();
170 if (*g_dev_ptr ==
nullptr) {
171 errx(1,
"driver not running");
174 (*g_dev_ptr)->test_error();
182 warnx(
"missing command: try 'start', 'info', 'stop', 'regdump', 'testerror'");
184 warnx(
" -X (external bus)");
185 warnx(
" -R rotation");
195 const char *myoptarg =
nullptr;
196 bool external_bus =
false;
199 while ((ch = px4_getopt(argc, argv,
"XR:", &myoptind, &myoptarg)) != EOF) {
206 rotation = (
enum Rotation)atoi(myoptarg);
215 if (myoptind >= argc) {
220 const char *verb = argv[myoptind];
225 if (!strcmp(verb,
"start")) {
229 if (!strcmp(verb,
"stop")) {
236 if (!strcmp(verb,
"info")) {
243 if (!strcmp(verb,
"regdump")) {
247 if (!strcmp(verb,
"testerror")) {
void testerror(bool)
deliberately produce an error to test recovery
Local functions in support of the shell command.
void start(bool, enum Rotation)
Start the driver.
void regdump(bool)
Dump the register information.
Rotation
Enum for board and external compass rotations.
void info(bool)
Print a little info about the driver.
void usage()
Prints info about the driver argument usage.
__EXPORT int bmi160_main(int argc, char *argv[])
driver 'main' command