36 #include <px4_platform_common/px4_config.h> 37 #include <px4_platform_common/defines.h> 38 #include <px4_platform_common/getopt.h> 40 #define LSM303AGR_DEVICE_PATH_MAG "/dev/lsm303agr_mag" 67 if (g_dev !=
nullptr) {
68 errx(0,
"already started");
72 #if defined(PX4_SPIDEV_LSM303A_M) && defined(PX4_SPIDEV_LSM303A_X) 75 errx(0,
"External SPI not available");
78 if (g_dev ==
nullptr) {
79 PX4_ERR(
"alloc failed");
101 if (g_dev !=
nullptr) {
106 errx(1,
"driver start failed");
115 if (g_dev ==
nullptr) {
116 errx(1,
"driver not running\n");
119 printf(
"state @ %p\n", g_dev);
128 PX4_INFO(
"missing command: try 'start', 'info', 'reset'");
129 PX4_INFO(
"options:");
130 PX4_INFO(
" -X (external bus)");
131 PX4_INFO(
" -R rotation");
141 const char *myoptarg =
nullptr;
146 while ((ch = px4_getopt(argc, argv,
"XR:a:", &myoptind, &myoptarg)) != EOF) {
149 rotation = (
enum Rotation)atoi(myoptarg);
158 if (myoptind >= argc) {
163 const char *verb = argv[myoptind];
169 if (!strcmp(verb,
"start")) {
176 if (!strcmp(verb,
"info")) {
180 errx(1,
"unrecognized command, try 'start', 'info'");
#define SENSOR_POLLRATE_DEFAULT
poll at driver normal rate
#define SENSORIOCSPOLLRATE
Set the driver polling rate to (arg) Hz, or one of the SENSOR_POLLRATE constants. ...
void info()
Print a little info about the driver.
Rotation
Enum for board and external compass rotations.
__EXPORT int lsm303agr_main(int argc, char *argv[])
Local functions in support of the shell command.
void print_info()
Diagnostics - print some basic information about the driver.
#define LSM303AGR_DEVICE_PATH_MAG
void start(enum Rotation rotation)
Start the driver.
void usage()
Prints info about the driver argument usage.