61 if (g_dev !=
nullptr) {
62 PX4_INFO(
"already started");
68 #if defined(PX4_SPI_BUS_EXT) && defined(PX4_SPIDEV_EXT_GYRO) 69 g_dev =
new FXAS21002C(PX4_SPI_BUS_EXT, PX4_SPIDEV_EXT_GYRO, rotation);
71 PX4_ERR(
"External SPI not available");
76 g_dev =
new FXAS21002C(PX4_SPI_BUS_SENSORS, PX4_SPIDEV_GYRO, rotation);
79 if (g_dev ==
nullptr) {
80 PX4_ERR(
"failed instantiating FXAS21002C obj");
91 if (g_dev !=
nullptr) {
96 errx(1,
"driver start failed");
105 if (g_dev ==
nullptr) {
106 PX4_ERR(
"driver not running\n");
110 printf(
"state @ %p\n", g_dev);
122 if (g_dev ==
nullptr) {
123 PX4_ERR(
"driver not running\n");
127 printf(
"regdump @ %p\n", g_dev);
139 if (g_dev ==
nullptr) {
140 PX4_ERR(
"driver not running\n");
152 PX4_INFO(
"missing command: try 'start', 'info', 'testerror' or 'regdump'");
153 PX4_INFO(
"options:");
154 PX4_INFO(
" -X (external bus)");
155 PX4_INFO(
" -R rotation");
163 bool external_bus =
false;
168 const char *myoptarg = NULL;
170 while ((ch = px4_getopt(argc, argv,
"XR:", &myoptind, &myoptarg)) != EOF) {
177 rotation = (
enum Rotation)atoi(myoptarg);
186 const char *verb = argv[myoptind];
192 if (!strcmp(verb,
"start")) {
199 if (!strcmp(verb,
"info")) {
206 if (!strcmp(verb,
"regdump")) {
213 if (!strcmp(verb,
"testerror")) {
217 PX4_WARN(
"unrecognized command, try 'start', 'info', 'testerror' or 'regdump'");
void regdump()
dump registers from device
void test_error()
deliberately trigger an error
void info()
Print a little info about the driver.
void print_registers()
dump register values
void usage()
Prints info about the driver argument usage.
__EXPORT int fxas21002c_main(int argc, char *argv[])
void test_error()
trigger an error
Rotation
Enum for board and external compass rotations.
Local functions in support of the shell command.
void start(bool external_bus, enum Rotation rotation)
Start the driver.
Driver for the NXP FXAS21002C 3-Axis Digital Angular Rate Gyroscope connected via SPI...
void print_info()
Diagnostics - print some basic information about the driver.