PX4 Firmware
PX4 Autopilot Software http://px4.io
|
Driver for the ST LSM303D MEMS accelerometer / magnetometer connected via SPI. More...
#include <drivers/device/spi.h>
#include <ecl/geo/geo.h>
#include <perf/perf_counter.h>
#include <px4_platform_common/px4_work_queue/ScheduledWorkItem.hpp>
#include <lib/drivers/accelerometer/PX4Accelerometer.hpp>
#include <lib/drivers/magnetometer/PX4Magnetometer.hpp>
Go to the source code of this file.
Classes | |
class | LSM303D |
Macros | |
#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 0x49 |
#define | ADDR_OUT_TEMP_L 0x05 |
#define | ADDR_STATUS_A 0x27 |
#define | ADDR_CTRL_REG0 0x1F |
#define | ADDR_CTRL_REG1 0x20 |
#define | ADDR_CTRL_REG2 0x21 |
#define | ADDR_CTRL_REG3 0x22 |
#define | ADDR_CTRL_REG4 0x23 |
#define | ADDR_CTRL_REG5 0x24 |
#define | ADDR_CTRL_REG6 0x25 |
#define | ADDR_CTRL_REG7 0x26 |
#define | REG1_RATE_BITS_A ((1<<7) | (1<<6) | (1<<5) | (1<<4)) |
#define | REG1_POWERDOWN_A ((0<<7) | (0<<6) | (0<<5) | (0<<4)) |
#define | REG1_RATE_3_125HZ_A ((0<<7) | (0<<6) | (0<<5) | (1<<4)) |
#define | REG1_RATE_6_25HZ_A ((0<<7) | (0<<6) | (1<<5) | (0<<4)) |
#define | REG1_RATE_12_5HZ_A ((0<<7) | (0<<6) | (1<<5) | (1<<4)) |
#define | REG1_RATE_25HZ_A ((0<<7) | (1<<6) | (0<<5) | (0<<4)) |
#define | REG1_RATE_50HZ_A ((0<<7) | (1<<6) | (0<<5) | (1<<4)) |
#define | REG1_RATE_100HZ_A ((0<<7) | (1<<6) | (1<<5) | (0<<4)) |
#define | REG1_RATE_200HZ_A ((0<<7) | (1<<6) | (1<<5) | (1<<4)) |
#define | REG1_RATE_400HZ_A ((1<<7) | (0<<6) | (0<<5) | (0<<4)) |
#define | REG1_RATE_800HZ_A ((1<<7) | (0<<6) | (0<<5) | (1<<4)) |
#define | REG1_RATE_1600HZ_A ((1<<7) | (0<<6) | (1<<5) | (0<<4)) |
#define | REG1_BDU_UPDATE (1<<3) |
#define | REG1_Z_ENABLE_A (1<<2) |
#define | REG1_Y_ENABLE_A (1<<1) |
#define | REG1_X_ENABLE_A (1<<0) |
#define | REG2_ANTIALIAS_FILTER_BW_BITS_A ((1<<7) | (1<<6)) |
#define | REG2_AA_FILTER_BW_773HZ_A ((0<<7) | (0<<6)) |
#define | REG2_AA_FILTER_BW_194HZ_A ((0<<7) | (1<<6)) |
#define | REG2_AA_FILTER_BW_362HZ_A ((1<<7) | (0<<6)) |
#define | REG2_AA_FILTER_BW_50HZ_A ((1<<7) | (1<<6)) |
#define | REG2_FULL_SCALE_BITS_A ((1<<5) | (1<<4) | (1<<3)) |
#define | REG2_FULL_SCALE_2G_A ((0<<5) | (0<<4) | (0<<3)) |
#define | REG2_FULL_SCALE_4G_A ((0<<5) | (0<<4) | (1<<3)) |
#define | REG2_FULL_SCALE_6G_A ((0<<5) | (1<<4) | (0<<3)) |
#define | REG2_FULL_SCALE_8G_A ((0<<5) | (1<<4) | (1<<3)) |
#define | REG2_FULL_SCALE_16G_A ((1<<5) | (0<<4) | (0<<3)) |
#define | REG5_ENABLE_T (1<<7) |
#define | REG5_RES_HIGH_M ((1<<6) | (1<<5)) |
#define | REG5_RES_LOW_M ((0<<6) | (0<<5)) |
#define | REG5_RATE_BITS_M ((1<<4) | (1<<3) | (1<<2)) |
#define | REG5_RATE_3_125HZ_M ((0<<4) | (0<<3) | (0<<2)) |
#define | REG5_RATE_6_25HZ_M ((0<<4) | (0<<3) | (1<<2)) |
#define | REG5_RATE_12_5HZ_M ((0<<4) | (1<<3) | (0<<2)) |
#define | REG5_RATE_25HZ_M ((0<<4) | (1<<3) | (1<<2)) |
#define | REG5_RATE_50HZ_M ((1<<4) | (0<<3) | (0<<2)) |
#define | REG5_RATE_100HZ_M ((1<<4) | (0<<3) | (1<<2)) |
#define | REG5_RATE_DO_NOT_USE_M ((1<<4) | (1<<3) | (0<<2)) |
#define | REG6_FULL_SCALE_BITS_M ((1<<6) | (1<<5)) |
#define | REG6_FULL_SCALE_2GA_M ((0<<6) | (0<<5)) |
#define | REG6_FULL_SCALE_4GA_M ((0<<6) | (1<<5)) |
#define | REG6_FULL_SCALE_8GA_M ((1<<6) | (0<<5)) |
#define | REG6_FULL_SCALE_12GA_M ((1<<6) | (1<<5)) |
#define | REG7_CONT_MODE_M ((0<<1) | (0<<0)) |
#define | REG_STATUS_A_NEW_ZYXADA 0x08 |
#define | LSM303D_ACCEL_DEFAULT_RANGE_G 16 |
#define | LSM303D_ACCEL_DEFAULT_RATE 800 |
#define | LSM303D_ACCEL_DEFAULT_ONCHIP_FILTER_FREQ 50 |
#define | LSM303D_MAG_DEFAULT_RANGE_GA 2 |
#define | LSM303D_MAG_DEFAULT_RATE 100 |
#define | LSM303D_TIMER_REDUCTION 200 |
Functions | |
__EXPORT int | lsm303d_main (int argc, char *argv[]) |
Driver for the ST LSM303D MEMS accelerometer / magnetometer connected via SPI.
Definition in file LSM303D.hpp.
#define ADDR_CTRL_REG0 0x1F |
Definition at line 61 of file LSM303D.hpp.
#define ADDR_CTRL_REG1 0x20 |
Definition at line 62 of file LSM303D.hpp.
#define ADDR_CTRL_REG2 0x21 |
Definition at line 63 of file LSM303D.hpp.
#define ADDR_CTRL_REG3 0x22 |
Definition at line 64 of file LSM303D.hpp.
#define ADDR_CTRL_REG4 0x23 |
Definition at line 65 of file LSM303D.hpp.
#define ADDR_CTRL_REG5 0x24 |
Definition at line 66 of file LSM303D.hpp.
#define ADDR_CTRL_REG6 0x25 |
Definition at line 67 of file LSM303D.hpp.
Referenced by LSM303D::mag_set_range().
#define ADDR_CTRL_REG7 0x26 |
Definition at line 68 of file LSM303D.hpp.
Referenced by LSM303D::reset().
#define ADDR_INCREMENT (1<<6) |
Definition at line 51 of file LSM303D.hpp.
#define ADDR_OUT_TEMP_L 0x05 |
Definition at line 57 of file LSM303D.hpp.
Referenced by LSM303D::measureMagnetometer().
#define ADDR_STATUS_A 0x27 |
Definition at line 59 of file LSM303D.hpp.
Referenced by LSM303D::measureAccelerometer().
#define ADDR_WHO_AM_I 0x0F |
Definition at line 54 of file LSM303D.hpp.
#define DIR_READ (1<<7) |
Definition at line 49 of file LSM303D.hpp.
#define DIR_WRITE (0<<7) |
Definition at line 50 of file LSM303D.hpp.
#define LSM303D_ACCEL_DEFAULT_ONCHIP_FILTER_FREQ 50 |
Definition at line 128 of file LSM303D.hpp.
Referenced by LSM303D::reset().
#define LSM303D_ACCEL_DEFAULT_RANGE_G 16 |
Definition at line 126 of file LSM303D.hpp.
Referenced by LSM303D::reset().
#define LSM303D_ACCEL_DEFAULT_RATE 800 |
Definition at line 127 of file LSM303D.hpp.
Referenced by LSM303D::reset().
#define LSM303D_MAG_DEFAULT_RANGE_GA 2 |
Definition at line 130 of file LSM303D.hpp.
Referenced by LSM303D::reset().
#define LSM303D_MAG_DEFAULT_RATE 100 |
Definition at line 131 of file LSM303D.hpp.
Referenced by LSM303D::reset().
#define LSM303D_TIMER_REDUCTION 200 |
Definition at line 139 of file LSM303D.hpp.
Referenced by LSM303D::start().
#define REG1_BDU_UPDATE (1<<3) |
Definition at line 83 of file LSM303D.hpp.
Referenced by LSM303D::reset().
#define REG1_POWERDOWN_A ((0<<7) | (0<<6) | (0<<5) | (0<<4)) |
Definition at line 71 of file LSM303D.hpp.
#define REG1_RATE_100HZ_A ((0<<7) | (1<<6) | (1<<5) | (0<<4)) |
Definition at line 77 of file LSM303D.hpp.
Referenced by LSM303D::accel_set_samplerate().
#define REG1_RATE_12_5HZ_A ((0<<7) | (0<<6) | (1<<5) | (1<<4)) |
Definition at line 74 of file LSM303D.hpp.
#define REG1_RATE_1600HZ_A ((1<<7) | (0<<6) | (1<<5) | (0<<4)) |
Definition at line 81 of file LSM303D.hpp.
Referenced by LSM303D::accel_set_samplerate().
#define REG1_RATE_200HZ_A ((0<<7) | (1<<6) | (1<<5) | (1<<4)) |
Definition at line 78 of file LSM303D.hpp.
Referenced by LSM303D::accel_set_samplerate().
#define REG1_RATE_25HZ_A ((0<<7) | (1<<6) | (0<<5) | (0<<4)) |
Definition at line 75 of file LSM303D.hpp.
#define REG1_RATE_3_125HZ_A ((0<<7) | (0<<6) | (0<<5) | (1<<4)) |
Definition at line 72 of file LSM303D.hpp.
#define REG1_RATE_400HZ_A ((1<<7) | (0<<6) | (0<<5) | (0<<4)) |
Definition at line 79 of file LSM303D.hpp.
Referenced by LSM303D::accel_set_samplerate().
#define REG1_RATE_50HZ_A ((0<<7) | (1<<6) | (0<<5) | (1<<4)) |
Definition at line 76 of file LSM303D.hpp.
#define REG1_RATE_6_25HZ_A ((0<<7) | (0<<6) | (1<<5) | (0<<4)) |
Definition at line 73 of file LSM303D.hpp.
#define REG1_RATE_800HZ_A ((1<<7) | (0<<6) | (0<<5) | (1<<4)) |
Definition at line 80 of file LSM303D.hpp.
Referenced by LSM303D::accel_set_samplerate(), and LSM303D::reset().
#define REG1_RATE_BITS_A ((1<<7) | (1<<6) | (1<<5) | (1<<4)) |
Definition at line 70 of file LSM303D.hpp.
Referenced by LSM303D::accel_set_samplerate().
#define REG1_X_ENABLE_A (1<<0) |
Definition at line 86 of file LSM303D.hpp.
Referenced by LSM303D::reset().
#define REG1_Y_ENABLE_A (1<<1) |
Definition at line 85 of file LSM303D.hpp.
Referenced by LSM303D::reset().
#define REG1_Z_ENABLE_A (1<<2) |
Definition at line 84 of file LSM303D.hpp.
Referenced by LSM303D::reset().
#define REG2_AA_FILTER_BW_194HZ_A ((0<<7) | (1<<6)) |
Definition at line 90 of file LSM303D.hpp.
Referenced by LSM303D::accel_set_onchip_lowpass_filter_bandwidth().
#define REG2_AA_FILTER_BW_362HZ_A ((1<<7) | (0<<6)) |
Definition at line 91 of file LSM303D.hpp.
Referenced by LSM303D::accel_set_onchip_lowpass_filter_bandwidth().
#define REG2_AA_FILTER_BW_50HZ_A ((1<<7) | (1<<6)) |
Definition at line 92 of file LSM303D.hpp.
Referenced by LSM303D::accel_set_onchip_lowpass_filter_bandwidth().
#define REG2_AA_FILTER_BW_773HZ_A ((0<<7) | (0<<6)) |
Definition at line 89 of file LSM303D.hpp.
Referenced by LSM303D::accel_set_onchip_lowpass_filter_bandwidth().
#define REG2_ANTIALIAS_FILTER_BW_BITS_A ((1<<7) | (1<<6)) |
Definition at line 88 of file LSM303D.hpp.
Referenced by LSM303D::accel_set_onchip_lowpass_filter_bandwidth().
#define REG2_FULL_SCALE_16G_A ((1<<5) | (0<<4) | (0<<3)) |
Definition at line 99 of file LSM303D.hpp.
Referenced by LSM303D::accel_set_range().
#define REG2_FULL_SCALE_2G_A ((0<<5) | (0<<4) | (0<<3)) |
Definition at line 95 of file LSM303D.hpp.
Referenced by LSM303D::accel_set_range().
#define REG2_FULL_SCALE_4G_A ((0<<5) | (0<<4) | (1<<3)) |
Definition at line 96 of file LSM303D.hpp.
Referenced by LSM303D::accel_set_range().
#define REG2_FULL_SCALE_6G_A ((0<<5) | (1<<4) | (0<<3)) |
Definition at line 97 of file LSM303D.hpp.
Referenced by LSM303D::accel_set_range().
#define REG2_FULL_SCALE_8G_A ((0<<5) | (1<<4) | (1<<3)) |
Definition at line 98 of file LSM303D.hpp.
Referenced by LSM303D::accel_set_range().
#define REG2_FULL_SCALE_BITS_A ((1<<5) | (1<<4) | (1<<3)) |
Definition at line 94 of file LSM303D.hpp.
Referenced by LSM303D::accel_set_range().
#define REG5_ENABLE_T (1<<7) |
Definition at line 101 of file LSM303D.hpp.
Referenced by LSM303D::reset().
#define REG5_RATE_100HZ_M ((1<<4) | (0<<3) | (1<<2)) |
Definition at line 112 of file LSM303D.hpp.
Referenced by LSM303D::mag_set_samplerate().
#define REG5_RATE_12_5HZ_M ((0<<4) | (1<<3) | (0<<2)) |
Definition at line 109 of file LSM303D.hpp.
#define REG5_RATE_25HZ_M ((0<<4) | (1<<3) | (1<<2)) |
Definition at line 110 of file LSM303D.hpp.
Referenced by LSM303D::mag_set_samplerate().
#define REG5_RATE_3_125HZ_M ((0<<4) | (0<<3) | (0<<2)) |
Definition at line 107 of file LSM303D.hpp.
#define REG5_RATE_50HZ_M ((1<<4) | (0<<3) | (0<<2)) |
Definition at line 111 of file LSM303D.hpp.
Referenced by LSM303D::mag_set_samplerate().
#define REG5_RATE_6_25HZ_M ((0<<4) | (0<<3) | (1<<2)) |
Definition at line 108 of file LSM303D.hpp.
#define REG5_RATE_BITS_M ((1<<4) | (1<<3) | (1<<2)) |
Definition at line 106 of file LSM303D.hpp.
Referenced by LSM303D::mag_set_samplerate().
#define REG5_RATE_DO_NOT_USE_M ((1<<4) | (1<<3) | (0<<2)) |
Definition at line 113 of file LSM303D.hpp.
#define REG5_RES_HIGH_M ((1<<6) | (1<<5)) |
Definition at line 103 of file LSM303D.hpp.
Referenced by LSM303D::reset().
#define REG5_RES_LOW_M ((0<<6) | (0<<5)) |
Definition at line 104 of file LSM303D.hpp.
#define REG6_FULL_SCALE_12GA_M ((1<<6) | (1<<5)) |
Definition at line 119 of file LSM303D.hpp.
Referenced by LSM303D::mag_set_range().
#define REG6_FULL_SCALE_2GA_M ((0<<6) | (0<<5)) |
Definition at line 116 of file LSM303D.hpp.
Referenced by LSM303D::mag_set_range().
#define REG6_FULL_SCALE_4GA_M ((0<<6) | (1<<5)) |
Definition at line 117 of file LSM303D.hpp.
Referenced by LSM303D::mag_set_range().
#define REG6_FULL_SCALE_8GA_M ((1<<6) | (0<<5)) |
Definition at line 118 of file LSM303D.hpp.
Referenced by LSM303D::mag_set_range().
#define REG6_FULL_SCALE_BITS_M ((1<<6) | (1<<5)) |
Definition at line 115 of file LSM303D.hpp.
Referenced by LSM303D::mag_set_range().
#define REG7_CONT_MODE_M ((0<<1) | (0<<0)) |
Definition at line 121 of file LSM303D.hpp.
Referenced by LSM303D::reset().
#define REG_STATUS_A_NEW_ZYXADA 0x08 |
Definition at line 123 of file LSM303D.hpp.
Referenced by LSM303D::measureAccelerometer().
#define WHO_I_AM 0x49 |
Definition at line 55 of file LSM303D.hpp.
__EXPORT int lsm303d_main | ( | int | argc, |
char * | argv[] | ||
) |
Definition at line 128 of file lsm303d_main.cpp.
References errx, lsm303d::info(), ROTATION_NONE, lsm303d::start(), and lsm303d::usage().