PX4 Firmware
PX4 Autopilot Software http://px4.io
|
Driver for the ST L3GD20 MEMS and L3GD20H mems gyros connected via SPI. More...
#include <drivers/device/spi.h>
#include <lib/conversion/rotation.h>
#include <lib/drivers/gyroscope/PX4Gyroscope.hpp>
#include <perf/perf_counter.h>
#include <px4_platform_common/getopt.h>
#include <px4_platform_common/px4_work_queue/ScheduledWorkItem.hpp>
Go to the source code of this file.
Classes | |
class | L3GD20 |
Namespaces | |
l3gd20 | |
Local functions in support of the shell command. | |
Macros | |
#define | L3GD20_DEVICE_PATH "/dev/l3gd20" |
#define | SENSOR_BOARD_ROTATION_000_DEG 0 |
#define | SENSOR_BOARD_ROTATION_090_DEG 1 |
#define | SENSOR_BOARD_ROTATION_180_DEG 2 |
#define | SENSOR_BOARD_ROTATION_270_DEG 3 |
#define | DIR_READ (1<<7) |
#define | DIR_WRITE (0<<7) |
#define | ADDR_INCREMENT (1<<6) |
#define | ADDR_WHO_AM_I 0x0F |
#define | WHO_I_AM_H 0xD7 |
#define | WHO_I_AM 0xD4 |
#define | WHO_I_AM_L3G4200D 0xD3 /* for L3G4200D */ |
#define | ADDR_CTRL_REG1 0x20 |
#define | REG1_RATE_LP_MASK 0xF0 /* Mask to guard partial register update */ |
#define | RATE_95HZ_LP_25HZ ((0<<7) | (0<<6) | (0<<5) | (1<<4)) |
#define | RATE_190HZ_LP_25HZ ((0<<7) | (1<<6) | (0<<5) | (1<<4)) |
#define | RATE_190HZ_LP_50HZ ((0<<7) | (1<<6) | (1<<5) | (0<<4)) |
#define | RATE_190HZ_LP_70HZ ((0<<7) | (1<<6) | (1<<5) | (1<<4)) |
#define | RATE_380HZ_LP_20HZ ((1<<7) | (0<<6) | (1<<5) | (0<<4)) |
#define | RATE_380HZ_LP_25HZ ((1<<7) | (0<<6) | (0<<5) | (1<<4)) |
#define | RATE_380HZ_LP_50HZ ((1<<7) | (0<<6) | (1<<5) | (0<<4)) |
#define | RATE_380HZ_LP_100HZ ((1<<7) | (0<<6) | (1<<5) | (1<<4)) |
#define | RATE_760HZ_LP_30HZ ((1<<7) | (1<<6) | (0<<5) | (0<<4)) |
#define | RATE_760HZ_LP_35HZ ((1<<7) | (1<<6) | (0<<5) | (1<<4)) |
#define | RATE_760HZ_LP_50HZ ((1<<7) | (1<<6) | (1<<5) | (0<<4)) |
#define | RATE_760HZ_LP_100HZ ((1<<7) | (1<<6) | (1<<5) | (1<<4)) |
#define | ADDR_CTRL_REG2 0x21 |
#define | ADDR_CTRL_REG3 0x22 |
#define | ADDR_CTRL_REG4 0x23 |
#define | REG4_RANGE_MASK 0x30 /* Mask to guard partial register update */ |
#define | RANGE_250DPS (0<<4) |
#define | RANGE_500DPS (1<<4) |
#define | RANGE_2000DPS (3<<4) |
#define | ADDR_CTRL_REG5 0x24 |
#define | ADDR_REFERENCE 0x25 |
#define | ADDR_OUT_TEMP 0x26 |
#define | ADDR_STATUS_REG 0x27 |
#define | ADDR_OUT_X_L 0x28 |
#define | ADDR_OUT_X_H 0x29 |
#define | ADDR_OUT_Y_L 0x2A |
#define | ADDR_OUT_Y_H 0x2B |
#define | ADDR_OUT_Z_L 0x2C |
#define | ADDR_OUT_Z_H 0x2D |
#define | ADDR_FIFO_CTRL_REG 0x2E |
#define | ADDR_FIFO_SRC_REG 0x2F |
#define | ADDR_INT1_CFG 0x30 |
#define | ADDR_INT1_SRC 0x31 |
#define | ADDR_INT1_TSH_XH 0x32 |
#define | ADDR_INT1_TSH_XL 0x33 |
#define | ADDR_INT1_TSH_YH 0x34 |
#define | ADDR_INT1_TSH_YL 0x35 |
#define | ADDR_INT1_TSH_ZH 0x36 |
#define | ADDR_INT1_TSH_ZL 0x37 |
#define | ADDR_INT1_DURATION 0x38 |
#define | ADDR_LOW_ODR 0x39 |
#define | REG1_POWER_NORMAL (1<<3) |
#define | REG1_Z_ENABLE (1<<2) |
#define | REG1_Y_ENABLE (1<<1) |
#define | REG1_X_ENABLE (1<<0) |
#define | REG4_BDU (1<<7) |
#define | REG4_BLE (1<<6) |
#define | REG5_FIFO_ENABLE (1<<6) |
#define | REG5_REBOOT_MEMORY (1<<7) |
#define | STATUS_ZYXOR (1<<7) |
#define | STATUS_ZOR (1<<6) |
#define | STATUS_YOR (1<<5) |
#define | STATUS_XOR (1<<4) |
#define | STATUS_ZYXDA (1<<3) |
#define | STATUS_ZDA (1<<2) |
#define | STATUS_YDA (1<<1) |
#define | STATUS_XDA (1<<0) |
#define | FIFO_CTRL_BYPASS_MODE (0<<5) |
#define | FIFO_CTRL_FIFO_MODE (1<<5) |
#define | FIFO_CTRL_STREAM_MODE (1<<6) |
#define | FIFO_CTRL_STREAM_TO_FIFO_MODE (3<<5) |
#define | FIFO_CTRL_BYPASS_TO_STREAM_MODE (1<<7) |
#define | L3GD20_DEFAULT_RATE 760 |
#define | L3G4200D_DEFAULT_RATE 800 |
#define | L3GD20_MAX_OUTPUT_RATE 280 |
#define | L3GD20_DEFAULT_RANGE_DPS 2000 |
#define | L3GD20_DEFAULT_FILTER_FREQ 30 |
#define | L3GD20_TEMP_OFFSET_CELSIUS 40 |
#define | L3GD20_MAX_OFFSET 0.45f |
max offset: 25 degrees/s More... | |
#define | SENSOR_BOARD_ROTATION_DEFAULT SENSOR_BOARD_ROTATION_270_DEG |
#define | L3GD20_TIMER_REDUCTION 600 |
Functions | |
__EXPORT int | l3gd20_main (int argc, char *argv[]) |
void | l3gd20::usage () |
Prints info about the driver argument usage. More... | |
void | l3gd20::start (bool external_bus, enum Rotation rotation) |
Start the driver. More... | |
void | l3gd20::info () |
Print a little info about the driver. More... | |
void | l3gd20::regdump (void) |
Dump the register information. More... | |
void | l3gd20::test_error (void) |
trigger an error More... | |
Variables | |
L3GD20 * | l3gd20::g_dev |
Driver for the ST L3GD20 MEMS and L3GD20H mems gyros connected via SPI.
Note: With the exception of the self-test feature, the ST L3G4200D is also supported by this driver.
Definition in file l3gd20.cpp.
#define ADDR_CTRL_REG1 0x20 |
Definition at line 68 of file l3gd20.cpp.
Referenced by L3GD20::reset(), and L3GD20::set_samplerate().
#define ADDR_CTRL_REG2 0x21 |
Definition at line 85 of file l3gd20.cpp.
Referenced by L3GD20::reset().
#define ADDR_CTRL_REG3 0x22 |
Definition at line 86 of file l3gd20.cpp.
Referenced by L3GD20::reset(), and L3GD20::test_error().
#define ADDR_CTRL_REG4 0x23 |
Definition at line 87 of file l3gd20.cpp.
Referenced by L3GD20::reset(), and L3GD20::set_range().
#define ADDR_CTRL_REG5 0x24 |
Definition at line 93 of file l3gd20.cpp.
Referenced by LSM303D::mag_set_samplerate(), LSM303D::reset(), L3GD20::reset(), and LIS3MDL::set_default_register_values().
#define ADDR_FIFO_CTRL_REG 0x2E |
Definition at line 103 of file l3gd20.cpp.
Referenced by L3GD20::reset().
#define ADDR_FIFO_SRC_REG 0x2F |
Definition at line 104 of file l3gd20.cpp.
#define ADDR_INCREMENT (1<<6) |
Definition at line 60 of file l3gd20.cpp.
Referenced by L3GD20::measure().
#define ADDR_INT1_CFG 0x30 |
Definition at line 105 of file l3gd20.cpp.
#define ADDR_INT1_DURATION 0x38 |
Definition at line 113 of file l3gd20.cpp.
#define ADDR_INT1_SRC 0x31 |
Definition at line 106 of file l3gd20.cpp.
#define ADDR_INT1_TSH_XH 0x32 |
Definition at line 107 of file l3gd20.cpp.
#define ADDR_INT1_TSH_XL 0x33 |
Definition at line 108 of file l3gd20.cpp.
#define ADDR_INT1_TSH_YH 0x34 |
Definition at line 109 of file l3gd20.cpp.
#define ADDR_INT1_TSH_YL 0x35 |
Definition at line 110 of file l3gd20.cpp.
#define ADDR_INT1_TSH_ZH 0x36 |
Definition at line 111 of file l3gd20.cpp.
#define ADDR_INT1_TSH_ZL 0x37 |
Definition at line 112 of file l3gd20.cpp.
#define ADDR_LOW_ODR 0x39 |
Definition at line 114 of file l3gd20.cpp.
Referenced by L3GD20::disable_i2c().
#define ADDR_OUT_TEMP 0x26 |
Definition at line 95 of file l3gd20.cpp.
Referenced by L3GD20::measure().
#define ADDR_OUT_X_H 0x29 |
Definition at line 98 of file l3gd20.cpp.
#define ADDR_OUT_X_L 0x28 |
Definition at line 97 of file l3gd20.cpp.
Referenced by LIS3MDL::collect().
#define ADDR_OUT_Y_H 0x2B |
Definition at line 100 of file l3gd20.cpp.
#define ADDR_OUT_Y_L 0x2A |
Definition at line 99 of file l3gd20.cpp.
#define ADDR_OUT_Z_H 0x2D |
Definition at line 102 of file l3gd20.cpp.
#define ADDR_OUT_Z_L 0x2C |
Definition at line 101 of file l3gd20.cpp.
#define ADDR_REFERENCE 0x25 |
Definition at line 94 of file l3gd20.cpp.
#define ADDR_STATUS_REG 0x27 |
Definition at line 96 of file l3gd20.cpp.
#define ADDR_WHO_AM_I 0x0F |
Definition at line 63 of file l3gd20.cpp.
Referenced by L3GD20::probe().
#define DIR_READ (1<<7) |
Definition at line 58 of file l3gd20.cpp.
Referenced by L3GD20::measure(), and L3GD20::read_reg().
#define DIR_WRITE (0<<7) |
Definition at line 59 of file l3gd20.cpp.
Referenced by L3GD20::write_reg().
#define FIFO_CTRL_BYPASS_MODE (0<<5) |
Definition at line 139 of file l3gd20.cpp.
Referenced by L3GD20::reset().
#define FIFO_CTRL_BYPASS_TO_STREAM_MODE (1<<7) |
Definition at line 143 of file l3gd20.cpp.
#define FIFO_CTRL_FIFO_MODE (1<<5) |
Definition at line 140 of file l3gd20.cpp.
#define FIFO_CTRL_STREAM_MODE (1<<6) |
Definition at line 141 of file l3gd20.cpp.
#define FIFO_CTRL_STREAM_TO_FIFO_MODE (3<<5) |
Definition at line 142 of file l3gd20.cpp.
#define L3G4200D_DEFAULT_RATE 800 |
Definition at line 146 of file l3gd20.cpp.
Referenced by L3GD20::start().
#define L3GD20_DEFAULT_FILTER_FREQ 30 |
Definition at line 149 of file l3gd20.cpp.
#define L3GD20_DEFAULT_RANGE_DPS 2000 |
Definition at line 148 of file l3gd20.cpp.
Referenced by L3GD20::reset().
#define L3GD20_DEFAULT_RATE 760 |
Definition at line 145 of file l3gd20.cpp.
#define L3GD20_DEVICE_PATH "/dev/l3gd20" |
Definition at line 49 of file l3gd20.cpp.
Referenced by l3gd20::start().
#define L3GD20_MAX_OFFSET 0.45f |
max offset: 25 degrees/s
Definition at line 152 of file l3gd20.cpp.
#define L3GD20_MAX_OUTPUT_RATE 280 |
Definition at line 147 of file l3gd20.cpp.
#define L3GD20_TEMP_OFFSET_CELSIUS 40 |
Definition at line 150 of file l3gd20.cpp.
Referenced by L3GD20::measure().
#define L3GD20_TIMER_REDUCTION 600 |
Definition at line 164 of file l3gd20.cpp.
Referenced by L3GD20::start().
#define RANGE_2000DPS (3<<4) |
Definition at line 91 of file l3gd20.cpp.
Referenced by L3GD20::set_range().
#define RANGE_250DPS (0<<4) |
Definition at line 89 of file l3gd20.cpp.
Referenced by L3GD20::set_range().
#define RANGE_500DPS (1<<4) |
Definition at line 90 of file l3gd20.cpp.
Referenced by L3GD20::set_range().
#define RATE_190HZ_LP_25HZ ((0<<7) | (1<<6) | (0<<5) | (1<<4)) |
Definition at line 73 of file l3gd20.cpp.
#define RATE_190HZ_LP_50HZ ((0<<7) | (1<<6) | (1<<5) | (0<<4)) |
Definition at line 74 of file l3gd20.cpp.
Referenced by L3GD20::set_samplerate().
#define RATE_190HZ_LP_70HZ ((0<<7) | (1<<6) | (1<<5) | (1<<4)) |
Definition at line 75 of file l3gd20.cpp.
#define RATE_380HZ_LP_100HZ ((1<<7) | (0<<6) | (1<<5) | (1<<4)) |
Definition at line 79 of file l3gd20.cpp.
#define RATE_380HZ_LP_20HZ ((1<<7) | (0<<6) | (1<<5) | (0<<4)) |
Definition at line 76 of file l3gd20.cpp.
#define RATE_380HZ_LP_25HZ ((1<<7) | (0<<6) | (0<<5) | (1<<4)) |
Definition at line 77 of file l3gd20.cpp.
#define RATE_380HZ_LP_50HZ ((1<<7) | (0<<6) | (1<<5) | (0<<4)) |
Definition at line 78 of file l3gd20.cpp.
Referenced by L3GD20::set_samplerate().
#define RATE_760HZ_LP_100HZ ((1<<7) | (1<<6) | (1<<5) | (1<<4)) |
Definition at line 83 of file l3gd20.cpp.
#define RATE_760HZ_LP_30HZ ((1<<7) | (1<<6) | (0<<5) | (0<<4)) |
Definition at line 80 of file l3gd20.cpp.
#define RATE_760HZ_LP_35HZ ((1<<7) | (1<<6) | (0<<5) | (1<<4)) |
Definition at line 81 of file l3gd20.cpp.
#define RATE_760HZ_LP_50HZ ((1<<7) | (1<<6) | (1<<5) | (0<<4)) |
Definition at line 82 of file l3gd20.cpp.
Referenced by L3GD20::set_samplerate().
#define RATE_95HZ_LP_25HZ ((0<<7) | (0<<6) | (0<<5) | (1<<4)) |
Definition at line 72 of file l3gd20.cpp.
Referenced by L3GD20::set_samplerate().
#define REG1_POWER_NORMAL (1<<3) |
Definition at line 118 of file l3gd20.cpp.
Referenced by L3GD20::reset(), and L3GD20::set_samplerate().
#define REG1_RATE_LP_MASK 0xF0 /* Mask to guard partial register update */ |
Definition at line 69 of file l3gd20.cpp.
#define REG1_X_ENABLE (1<<0) |
Definition at line 121 of file l3gd20.cpp.
Referenced by L3GD20::reset(), and L3GD20::set_samplerate().
#define REG1_Y_ENABLE (1<<1) |
Definition at line 120 of file l3gd20.cpp.
Referenced by L3GD20::reset(), and L3GD20::set_samplerate().
#define REG1_Z_ENABLE (1<<2) |
Definition at line 119 of file l3gd20.cpp.
Referenced by L3GD20::reset(), and L3GD20::set_samplerate().
#define REG4_BDU (1<<7) |
Definition at line 123 of file l3gd20.cpp.
Referenced by L3GD20::reset(), and L3GD20::set_range().
#define REG4_BLE (1<<6) |
Definition at line 124 of file l3gd20.cpp.
#define REG4_RANGE_MASK 0x30 /* Mask to guard partial register update */ |
Definition at line 88 of file l3gd20.cpp.
#define REG5_FIFO_ENABLE (1<<6) |
Definition at line 127 of file l3gd20.cpp.
Referenced by L3GD20::reset().
#define REG5_REBOOT_MEMORY (1<<7) |
Definition at line 128 of file l3gd20.cpp.
#define SENSOR_BOARD_ROTATION_000_DEG 0 |
Definition at line 52 of file l3gd20.cpp.
Referenced by L3GD20::measure().
#define SENSOR_BOARD_ROTATION_090_DEG 1 |
Definition at line 53 of file l3gd20.cpp.
Referenced by L3GD20::measure().
#define SENSOR_BOARD_ROTATION_180_DEG 2 |
Definition at line 54 of file l3gd20.cpp.
Referenced by L3GD20::measure(), and L3GD20::probe().
#define SENSOR_BOARD_ROTATION_270_DEG 3 |
Definition at line 55 of file l3gd20.cpp.
Referenced by L3GD20::measure().
#define SENSOR_BOARD_ROTATION_DEFAULT SENSOR_BOARD_ROTATION_270_DEG |
Definition at line 155 of file l3gd20.cpp.
Referenced by L3GD20::probe().
#define STATUS_XDA (1<<0) |
Definition at line 137 of file l3gd20.cpp.
#define STATUS_XOR (1<<4) |
Definition at line 133 of file l3gd20.cpp.
#define STATUS_YDA (1<<1) |
Definition at line 136 of file l3gd20.cpp.
#define STATUS_YOR (1<<5) |
Definition at line 132 of file l3gd20.cpp.
#define STATUS_ZDA (1<<2) |
Definition at line 135 of file l3gd20.cpp.
#define STATUS_ZOR (1<<6) |
Definition at line 131 of file l3gd20.cpp.
#define STATUS_ZYXDA (1<<3) |
Definition at line 134 of file l3gd20.cpp.
Referenced by L3GD20::measure().
#define STATUS_ZYXOR (1<<7) |
Definition at line 130 of file l3gd20.cpp.
#define WHO_I_AM 0xD4 |
Definition at line 65 of file l3gd20.cpp.
Referenced by LSM303D::probe(), and L3GD20::probe().
#define WHO_I_AM_H 0xD7 |
Definition at line 64 of file l3gd20.cpp.
Referenced by L3GD20::probe().
#define WHO_I_AM_L3G4200D 0xD3 /* for L3G4200D */ |
Definition at line 66 of file l3gd20.cpp.
Referenced by L3GD20::probe().
int l3gd20_main | ( | int | argc, |
char * | argv[] | ||
) |
Definition at line 872 of file l3gd20.cpp.
References l3gd20::info(), l3gd20::regdump(), ROTATION_NONE, l3gd20::start(), l3gd20::test_error(), and l3gd20::usage().