PX4 Firmware
PX4 Autopilot Software http://px4.io
|
Driver for the QMC5883 magnetometer connected via I2C or SPI. More...
#include <px4_platform_common/px4_config.h>
#include <px4_platform_common/defines.h>
#include <drivers/device/i2c.h>
#include <sys/types.h>
#include <stdint.h>
#include <stdlib.h>
#include <stdbool.h>
#include <semaphore.h>
#include <string.h>
#include <fcntl.h>
#include <poll.h>
#include <errno.h>
#include <stdio.h>
#include <math.h>
#include <unistd.h>
#include <nuttx/arch.h>
#include <px4_platform_common/px4_work_queue/ScheduledWorkItem.hpp>
#include <nuttx/clock.h>
#include <board_config.h>
#include <perf/perf_counter.h>
#include <systemlib/err.h>
#include <drivers/drv_mag.h>
#include <drivers/drv_hrt.h>
#include <drivers/device/ringbuffer.h>
#include <drivers/drv_device.h>
#include <uORB/uORB.h>
#include <float.h>
#include <getopt.h>
#include <lib/conversion/rotation.h>
#include "qmc5883.h"
Go to the source code of this file.
Classes | |
class | QMC5883 |
struct | QMC5883::_last_report |
used for info() More... | |
struct | qmc5883::qmc5883_bus_option |
Namespaces | |
qmc5883 | |
Local functions in support of the shell command. | |
Macros | |
#define | QMC5883_CONVERSION_INTERVAL (1000000 / 150) /* microseconds */ |
#define | QMC5883_MAX_COUNT 32767 |
#define | QMC5883_ADDR_DATA_OUT_X_LSB 0x00 |
#define | QMC5883_ADDR_DATA_OUT_X_MSB 0x01 |
#define | QMC5883_ADDR_DATA_OUT_Y_LSB 0x02 |
#define | QMC5883_ADDR_DATA_OUT_Y_MSB 0x03 |
#define | QMC5883_ADDR_DATA_OUT_Z_LSB 0x04 |
#define | QMC5883_ADDR_DATA_OUT_Z_MSB 0x05 |
#define | QMC5883_ADDR_STATUS 0x06 |
#define | QMC5883_ADDR_TEMP_OUT_LSB 0x07 |
#define | QMC5883_ADDR_TEMP_OUT_MSB 0x08 |
#define | QMC5883_ADDR_CONTROL_1 0x09 |
#define | QMC5883_ADDR_CONTROL_2 0x0A |
#define | QMC5883_ADDR_SET_RESET 0x0B |
#define | QMC5883_STATUS_REG_DRDY (1 << 0) /* Data Ready: "0": no new data, "1": new data is ready */ |
#define | QMC5883_STATUS_REG_OVL (1 << 1) /* Overflow Flag: "0": normal, "1": data overflow */ |
#define | QMC5883_STATUS_REG_DOR (1 << 2) /* Data Skip: "0": normal, "1": data skipped for reading */ |
#define | QMC5883_MODE_REG_STANDBY (0 << 0) |
#define | QMC5883_MODE_REG_CONTINOUS_MODE (1 << 0) |
#define | QMC5883_OUTPUT_DATA_RATE_10 (0 << 2) /* Hz */ |
#define | QMC5883_OUTPUT_DATA_RATE_50 (1 << 2) |
#define | QMC5883_OUTPUT_DATA_RATE_100 (2 << 2) |
#define | QMC5883_OUTPUT_DATA_RATE_200 (3 << 2) |
#define | QMC5883_OUTPUT_RANGE_2G (0 << 4) /* +/- 2 gauss */ |
#define | QMC5883_OUTPUT_RANGE_8G (1 << 4) /* +/- 8 gauss */ |
#define | QMC5883_OVERSAMPLE_512 (0 << 6) /* controls digital filter bw - larger OSR -> smaller bw */ |
#define | QMC5883_OVERSAMPLE_256 (1 << 6) |
#define | QMC5883_OVERSAMPLE_128 (2 << 6) |
#define | QMC5883_OVERSAMPLE_64 (3 << 6) |
#define | QMC5883_INT_ENB (1 << 0) |
#define | QMC5883_ROL_PNT (1 << 6) |
#define | QMC5883_SOFT_RESET (1 << 7) |
#define | QMC5883_SET_DEFAULT (1 << 0) |
#define | QMC5883_TEMP_OFFSET 50 /* deg celsius */ |
#define | NUM_BUS_OPTIONS (sizeof(bus_options)/sizeof(bus_options[0])) |
Enumerations | |
enum | QMC5883_BUS { QMC5883_BUS_ALL = 0, QMC5883_BUS_I2C_INTERNAL, QMC5883_BUS_I2C_EXTERNAL, QMC5883_BUS_SPI } |
Functions | |
__EXPORT int | qmc5883_main (int argc, char *argv[]) |
void | qmc5883::start (enum QMC5883_BUS busid, enum Rotation rotation) |
Start the driver. More... | |
int | qmc5883::stop () |
Stop the driver. More... | |
bool | qmc5883::start_bus (struct qmc5883_bus_option &bus, enum Rotation rotation) |
start driver for a specific bus option More... | |
struct qmc5883_bus_option & | qmc5883::find_bus (enum QMC5883_BUS busid) |
find a bus structure for a busid More... | |
void | qmc5883::test (enum QMC5883_BUS busid) |
Perform some basic functional tests on the driver; make sure we can collect data from the sensor in polled and automatic modes. More... | |
void | qmc5883::reset (enum QMC5883_BUS busid) |
Reset the driver. More... | |
int | qmc5883::info (enum QMC5883_BUS busid) |
Print a little info about the driver. More... | |
int | qmc5883::temp_enable (QMC5883_BUS busid, bool enable) |
void | qmc5883::usage () |
Prints info about the driver argument usage. More... | |
Variables | |
struct qmc5883::qmc5883_bus_option | qmc5883::bus_options [] |
Driver for the QMC5883 magnetometer connected via I2C or SPI.
Definition in file qmc5883.cpp.
#define NUM_BUS_OPTIONS (sizeof(bus_options)/sizeof(bus_options[0])) |
Definition at line 830 of file qmc5883.cpp.
Referenced by qmc5883::find_bus(), qmc5883::start(), and qmc5883::stop().
#define QMC5883_ADDR_CONTROL_1 0x09 |
Definition at line 97 of file qmc5883.cpp.
Referenced by QMC5883::check_conf(), and QMC5883::reset().
#define QMC5883_ADDR_CONTROL_2 0x0A |
Definition at line 98 of file qmc5883.cpp.
Referenced by QMC5883::reset().
#define QMC5883_ADDR_DATA_OUT_X_LSB 0x00 |
Definition at line 88 of file qmc5883.cpp.
Referenced by QMC5883::collect(), and QMC5883::reset().
#define QMC5883_ADDR_DATA_OUT_X_MSB 0x01 |
Definition at line 89 of file qmc5883.cpp.
#define QMC5883_ADDR_DATA_OUT_Y_LSB 0x02 |
Definition at line 90 of file qmc5883.cpp.
#define QMC5883_ADDR_DATA_OUT_Y_MSB 0x03 |
Definition at line 91 of file qmc5883.cpp.
#define QMC5883_ADDR_DATA_OUT_Z_LSB 0x04 |
Definition at line 92 of file qmc5883.cpp.
#define QMC5883_ADDR_DATA_OUT_Z_MSB 0x05 |
Definition at line 93 of file qmc5883.cpp.
#define QMC5883_ADDR_SET_RESET 0x0B |
Definition at line 99 of file qmc5883.cpp.
Referenced by QMC5883::reset().
#define QMC5883_ADDR_STATUS 0x06 |
Definition at line 94 of file qmc5883.cpp.
#define QMC5883_ADDR_TEMP_OUT_LSB 0x07 |
Definition at line 95 of file qmc5883.cpp.
Referenced by QMC5883::collect().
#define QMC5883_ADDR_TEMP_OUT_MSB 0x08 |
Definition at line 96 of file qmc5883.cpp.
#define QMC5883_CONVERSION_INTERVAL (1000000 / 150) /* microseconds */ |
Definition at line 85 of file qmc5883.cpp.
Referenced by QMC5883::ioctl(), QMC5883::read(), and QMC5883::Run().
#define QMC5883_INT_ENB (1 << 0) |
Definition at line 121 of file qmc5883.cpp.
#define QMC5883_MAX_COUNT 32767 |
Definition at line 86 of file qmc5883.cpp.
Referenced by QMC5883::collect().
#define QMC5883_MODE_REG_CONTINOUS_MODE (1 << 0) |
Definition at line 108 of file qmc5883.cpp.
Referenced by QMC5883::reset().
#define QMC5883_MODE_REG_STANDBY (0 << 0) |
Definition at line 107 of file qmc5883.cpp.
#define QMC5883_OUTPUT_DATA_RATE_10 (0 << 2) /* Hz */ |
Definition at line 109 of file qmc5883.cpp.
#define QMC5883_OUTPUT_DATA_RATE_100 (2 << 2) |
Definition at line 111 of file qmc5883.cpp.
#define QMC5883_OUTPUT_DATA_RATE_200 (3 << 2) |
Definition at line 112 of file qmc5883.cpp.
Referenced by QMC5883::reset().
#define QMC5883_OUTPUT_DATA_RATE_50 (1 << 2) |
Definition at line 110 of file qmc5883.cpp.
#define QMC5883_OUTPUT_RANGE_2G (0 << 4) /* +/- 2 gauss */ |
Definition at line 113 of file qmc5883.cpp.
Referenced by QMC5883::reset().
#define QMC5883_OUTPUT_RANGE_8G (1 << 4) /* +/- 8 gauss */ |
Definition at line 114 of file qmc5883.cpp.
#define QMC5883_OVERSAMPLE_128 (2 << 6) |
Definition at line 117 of file qmc5883.cpp.
#define QMC5883_OVERSAMPLE_256 (1 << 6) |
Definition at line 116 of file qmc5883.cpp.
#define QMC5883_OVERSAMPLE_512 (0 << 6) /* controls digital filter bw - larger OSR -> smaller bw */ |
Definition at line 115 of file qmc5883.cpp.
Referenced by QMC5883::reset().
#define QMC5883_OVERSAMPLE_64 (3 << 6) |
Definition at line 118 of file qmc5883.cpp.
#define QMC5883_ROL_PNT (1 << 6) |
Definition at line 122 of file qmc5883.cpp.
#define QMC5883_SET_DEFAULT (1 << 0) |
Definition at line 126 of file qmc5883.cpp.
Referenced by QMC5883::reset().
#define QMC5883_SOFT_RESET (1 << 7) |
Definition at line 123 of file qmc5883.cpp.
Referenced by QMC5883::reset().
#define QMC5883_STATUS_REG_DOR (1 << 2) /* Data Skip: "0": normal, "1": data skipped for reading */ |
Definition at line 104 of file qmc5883.cpp.
Definition at line 102 of file qmc5883.cpp.
#define QMC5883_STATUS_REG_OVL (1 << 1) /* Overflow Flag: "0": normal, "1": data overflow */ |
Definition at line 103 of file qmc5883.cpp.
#define QMC5883_TEMP_OFFSET 50 /* deg celsius */ |
Definition at line 128 of file qmc5883.cpp.
Referenced by QMC5883::collect().
enum QMC5883_BUS |
Enumerator | |
---|---|
QMC5883_BUS_ALL | |
QMC5883_BUS_I2C_INTERNAL | |
QMC5883_BUS_I2C_EXTERNAL | |
QMC5883_BUS_SPI |
Definition at line 130 of file qmc5883.cpp.
int qmc5883_main | ( | int | argc, |
char * | argv[] | ||
) |
Definition at line 1065 of file qmc5883.cpp.
References errx, qmc5883::info(), QMC5883_BUS_ALL, QMC5883_BUS_I2C_EXTERNAL, QMC5883_BUS_I2C_INTERNAL, QMC5883_BUS_SPI, qmc5883::reset(), ROTATION_NONE, qmc5883::start(), qmc5883::stop(), qmc5883::test(), and qmc5883::usage().