|
PX4 Firmware
PX4 Autopilot Software http://px4.io
|
Driver for the IST8310 magnetometer connected via I2C. More...
#include <px4_platform_common/px4_config.h>#include <px4_platform_common/defines.h>#include <px4_platform_common/getopt.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 <nuttx/clock.h>#include <board_config.h>#include <perf/perf_counter.h>#include <systemlib/err.h>#include <drivers/device/i2c.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 <lib/conversion/rotation.h>#include <px4_platform_common/px4_work_queue/ScheduledWorkItem.hpp>Go to the source code of this file.
Classes | |
| class | IST8310 |
| struct | IST8310::_scale |
| struct | ist8310::ist8310_bus_option |
Namespaces | |
| ist8310 | |
| Local functions in support of the shell command. | |
Macros | |
| #define | IST8310_CONVERSION_INTERVAL (1000000 / 100) /* microseconds */ |
| #define | IST8310_BUS_I2C_ADDR 0xE |
| #define | IST8310_DEFAULT_BUS_SPEED 400000 |
| #define | IST8310_RESOLUTION 0.3 |
| #define | ADDR_WAI 0 /* WAI means 'Who Am I'*/ |
| #define | WAI_EXPECTED_VALUE 0x10 |
| #define | ADDR_STAT1 0x02 |
| #define | STAT1_DRDY_SHFITS 0x0 |
| #define | STAT1_DRDY (1 << STAT1_DRDY_SHFITS) |
| #define | STAT1_DRO_SHFITS 0x1 |
| #define | STAT1_DRO (1 << STAT1_DRO_SHFITS) |
| #define | ADDR_DATA_OUT_X_LSB 0x03 |
| #define | ADDR_DATA_OUT_X_MSB 0x04 |
| #define | ADDR_DATA_OUT_Y_LSB 0x05 |
| #define | ADDR_DATA_OUT_Y_MSB 0x06 |
| #define | ADDR_DATA_OUT_Z_LSB 0x07 |
| #define | ADDR_DATA_OUT_Z_MSB 0x08 |
| #define | ADDR_STAT2 0x09 |
| #define | STAT2_INT_SHFITS 3 |
| #define | STAT2_INT (1 << STAT2_INT_SHFITS) |
| #define | ADDR_CTRL1 0x0a |
| #define | CTRL1_MODE_SHFITS 0 |
| #define | CTRL1_MODE_STDBY (0 << CTRL1_MODE_SHFITS) |
| #define | CTRL1_MODE_SINGLE (1 << CTRL1_MODE_SHFITS) |
| #define | ADDR_CTRL2 0x0b |
| #define | CTRL2_SRST_SHFITS 0 /* Begin POR (auto cleared) */ |
| #define | CTRL2_SRST (1 << CTRL2_SRST_SHFITS) |
| #define | CTRL2_DRP_SHIFTS 2 |
| #define | CTRL2_DRP (1 << CTRL2_DRP_SHIFTS) |
| #define | CTRL2_DREN_SHIFTS 3 |
| #define | CTRL2_DREN (1 << CTRL2_DREN_SHIFTS) |
| #define | ADDR_CTRL3 0x41 |
| #define | CTRL3_SAMPLEAVG_16 0x24 /* Sample Averaging 16 */ |
| #define | CTRL3_SAMPLEAVG_8 0x1b /* Sample Averaging 8 */ |
| #define | CTRL3_SAMPLEAVG_4 0x12 /* Sample Averaging 4 */ |
| #define | CTRL3_SAMPLEAVG_2 0x09 /* Sample Averaging 2 */ |
| #define | ADDR_CTRL4 0x42 |
| #define | CTRL4_SRPD 0xC0 /* Set Reset Pulse Duration */ |
| #define | ADDR_STR 0x0c |
| #define | STR_SELF_TEST_SHFITS 6 |
| #define | STR_SELF_TEST_ON (1 << STR_SELF_TEST_SHFITS) |
| #define | STR_SELF_TEST_OFF (0 << STR_SELF_TEST_SHFITS) |
| #define | ADDR_Y11_Low 0x9c |
| #define | ADDR_Y11_High 0x9d |
| #define | ADDR_Y12_Low 0x9e |
| #define | ADDR_Y12_High 0x9f |
| #define | ADDR_Y13_Low 0xa0 |
| #define | ADDR_Y13_High 0xa1 |
| #define | ADDR_Y21_Low 0xa2 |
| #define | ADDR_Y21_High 0xa3 |
| #define | ADDR_Y22_Low 0xa4 |
| #define | ADDR_Y22_High 0xa5 |
| #define | ADDR_Y23_Low 0xa6 |
| #define | ADDR_Y23_High 0xa7 |
| #define | ADDR_Y31_Low 0xa8 |
| #define | ADDR_Y31_High 0xa9 |
| #define | ADDR_Y32_Low 0xaa |
| #define | ADDR_Y32_High 0xab |
| #define | ADDR_Y33_Low 0xac |
| #define | ADDR_Y33_High 0xad |
| #define | ADDR_TEMPL 0x1c |
| #define | ADDR_TEMPH 0x1d |
| #define | NUM_BUS_OPTIONS (sizeof(bus_options)/sizeof(bus_options[0])) |
Enumerations | |
| enum | IST8310_BUS { IST8310_BUS_ALL = 0, IST8310_BUS_I2C_EXTERNAL = 1, IST8310_BUS_I2C_EXTERNAL1 = 2, IST8310_BUS_I2C_EXTERNAL2 = 3, IST8310_BUS_I2C_EXTERNAL3 = 4, IST8310_BUS_I2C_INTERNAL = 5 } |
Functions | |
| __EXPORT int | ist8310_main (int argc, char *argv[]) |
| void | ist8310::start (enum IST8310_BUS busid, int address, enum Rotation rotation) |
| Start the driver. More... | |
| bool | ist8310::start_bus (struct ist8310_bus_option &bus, int address, enum Rotation rotation) |
| start driver for a specific bus option More... | |
| struct ist8310_bus_option & | ist8310::find_bus (enum IST8310_BUS busid) |
| find a bus structure for a busid More... | |
| void | ist8310::test (enum IST8310_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 | ist8310::reset (enum IST8310_BUS busid) |
| Reset the driver. More... | |
| int | ist8310::info (enum IST8310_BUS busid) |
| Print a little info about the driver. More... | |
| int | ist8310::calibrate (enum IST8310_BUS busid) |
| Automatic scale calibration. More... | |
| void | ist8310::usage () |
| Prints info about the driver argument usage. More... | |
Variables | |
| static const int16_t | IST8310_MAX_VAL_XY = (1600 / IST8310_RESOLUTION) + 1 |
| static const int16_t | IST8310_MIN_VAL_XY = -IST8310_MAX_VAL_XY |
| static const int16_t | IST8310_MAX_VAL_Z = (2500 / IST8310_RESOLUTION) + 1 |
| static const int16_t | IST8310_MIN_VAL_Z = -IST8310_MAX_VAL_Z |
| struct ist8310::ist8310_bus_option | ist8310::bus_options [] |
Driver for the IST8310 magnetometer connected via I2C.
Definition in file ist8310.cpp.
| #define ADDR_CTRL1 0x0a |
Definition at line 128 of file ist8310.cpp.
Referenced by IST8310::measure().
| #define ADDR_CTRL2 0x0b |
Definition at line 133 of file ist8310.cpp.
Referenced by IST8310::reset().
| #define ADDR_CTRL3 0x41 |
Definition at line 141 of file ist8310.cpp.
Referenced by IST8310::check_conf(), and IST8310::reset().
| #define ADDR_CTRL4 0x42 |
Definition at line 147 of file ist8310.cpp.
Referenced by IST8310::check_conf(), and IST8310::reset().
| #define ADDR_DATA_OUT_X_LSB 0x03 |
Definition at line 117 of file ist8310.cpp.
Referenced by IST8310::collect().
| #define ADDR_DATA_OUT_X_MSB 0x04 |
Definition at line 118 of file ist8310.cpp.
| #define ADDR_DATA_OUT_Y_LSB 0x05 |
Definition at line 119 of file ist8310.cpp.
| #define ADDR_DATA_OUT_Y_MSB 0x06 |
Definition at line 120 of file ist8310.cpp.
| #define ADDR_DATA_OUT_Z_LSB 0x07 |
Definition at line 121 of file ist8310.cpp.
| #define ADDR_DATA_OUT_Z_MSB 0x08 |
Definition at line 122 of file ist8310.cpp.
| #define ADDR_STAT1 0x02 |
Definition at line 111 of file ist8310.cpp.
| #define ADDR_STAT2 0x09 |
Definition at line 124 of file ist8310.cpp.
| #define ADDR_STR 0x0c |
Definition at line 150 of file ist8310.cpp.
Referenced by IST8310::set_selftest().
| #define ADDR_TEMPH 0x1d |
Definition at line 175 of file ist8310.cpp.
| #define ADDR_TEMPL 0x1c |
Definition at line 174 of file ist8310.cpp.
| #define ADDR_WAI 0 /* WAI means 'Who Am I'*/ |
Definition at line 108 of file ist8310.cpp.
Referenced by IST8310::probe().
| #define ADDR_Y11_High 0x9d |
Definition at line 156 of file ist8310.cpp.
| #define ADDR_Y11_Low 0x9c |
Definition at line 155 of file ist8310.cpp.
| #define ADDR_Y12_High 0x9f |
Definition at line 158 of file ist8310.cpp.
| #define ADDR_Y12_Low 0x9e |
Definition at line 157 of file ist8310.cpp.
| #define ADDR_Y13_High 0xa1 |
Definition at line 160 of file ist8310.cpp.
| #define ADDR_Y13_Low 0xa0 |
Definition at line 159 of file ist8310.cpp.
| #define ADDR_Y21_High 0xa3 |
Definition at line 162 of file ist8310.cpp.
| #define ADDR_Y21_Low 0xa2 |
Definition at line 161 of file ist8310.cpp.
| #define ADDR_Y22_High 0xa5 |
Definition at line 164 of file ist8310.cpp.
| #define ADDR_Y22_Low 0xa4 |
Definition at line 163 of file ist8310.cpp.
| #define ADDR_Y23_High 0xa7 |
Definition at line 166 of file ist8310.cpp.
| #define ADDR_Y23_Low 0xa6 |
Definition at line 165 of file ist8310.cpp.
| #define ADDR_Y31_High 0xa9 |
Definition at line 168 of file ist8310.cpp.
| #define ADDR_Y31_Low 0xa8 |
Definition at line 167 of file ist8310.cpp.
| #define ADDR_Y32_High 0xab |
Definition at line 170 of file ist8310.cpp.
| #define ADDR_Y32_Low 0xaa |
Definition at line 169 of file ist8310.cpp.
| #define ADDR_Y33_High 0xad |
Definition at line 172 of file ist8310.cpp.
| #define ADDR_Y33_Low 0xac |
Definition at line 171 of file ist8310.cpp.
| #define CTRL1_MODE_SHFITS 0 |
Definition at line 129 of file ist8310.cpp.
| #define CTRL1_MODE_SINGLE (1 << CTRL1_MODE_SHFITS) |
Definition at line 131 of file ist8310.cpp.
Referenced by IST8310::measure().
| #define CTRL1_MODE_STDBY (0 << CTRL1_MODE_SHFITS) |
Definition at line 130 of file ist8310.cpp.
| #define CTRL2_DREN (1 << CTRL2_DREN_SHIFTS) |
Definition at line 139 of file ist8310.cpp.
| #define CTRL2_DREN_SHIFTS 3 |
Definition at line 138 of file ist8310.cpp.
| #define CTRL2_DRP (1 << CTRL2_DRP_SHIFTS) |
Definition at line 137 of file ist8310.cpp.
| #define CTRL2_DRP_SHIFTS 2 |
Definition at line 136 of file ist8310.cpp.
| #define CTRL2_SRST (1 << CTRL2_SRST_SHFITS) |
Definition at line 135 of file ist8310.cpp.
Referenced by IST8310::reset().
| #define CTRL2_SRST_SHFITS 0 /* Begin POR (auto cleared) */ |
Definition at line 134 of file ist8310.cpp.
| #define CTRL3_SAMPLEAVG_16 0x24 /* Sample Averaging 16 */ |
Definition at line 142 of file ist8310.cpp.
Referenced by IST8310::reset().
| #define CTRL3_SAMPLEAVG_2 0x09 /* Sample Averaging 2 */ |
Definition at line 145 of file ist8310.cpp.
| #define CTRL3_SAMPLEAVG_4 0x12 /* Sample Averaging 4 */ |
Definition at line 144 of file ist8310.cpp.
| #define CTRL3_SAMPLEAVG_8 0x1b /* Sample Averaging 8 */ |
Definition at line 143 of file ist8310.cpp.
| #define CTRL4_SRPD 0xC0 /* Set Reset Pulse Duration */ |
Definition at line 148 of file ist8310.cpp.
Referenced by IST8310::reset().
| #define IST8310_BUS_I2C_ADDR 0xE |
Definition at line 89 of file ist8310.cpp.
Referenced by ist8310_main(), and ist8310::usage().
| #define IST8310_CONVERSION_INTERVAL (1000000 / 100) /* microseconds */ |
Definition at line 87 of file ist8310.cpp.
Referenced by IST8310::ioctl(), IST8310::read(), and IST8310::Run().
| #define IST8310_DEFAULT_BUS_SPEED 400000 |
Definition at line 90 of file ist8310.cpp.
| #define IST8310_RESOLUTION 0.3 |
Definition at line 99 of file ist8310.cpp.
| #define NUM_BUS_OPTIONS (sizeof(bus_options)/sizeof(bus_options[0])) |
Definition at line 1149 of file ist8310.cpp.
Referenced by ist8310::find_bus(), and ist8310::start().
| #define STAT1_DRDY (1 << STAT1_DRDY_SHFITS) |
Definition at line 113 of file ist8310.cpp.
| #define STAT1_DRDY_SHFITS 0x0 |
Definition at line 112 of file ist8310.cpp.
| #define STAT1_DRO (1 << STAT1_DRO_SHFITS) |
Definition at line 115 of file ist8310.cpp.
| #define STAT1_DRO_SHFITS 0x1 |
Definition at line 114 of file ist8310.cpp.
| #define STAT2_INT (1 << STAT2_INT_SHFITS) |
Definition at line 126 of file ist8310.cpp.
| #define STAT2_INT_SHFITS 3 |
Definition at line 125 of file ist8310.cpp.
| #define STR_SELF_TEST_OFF (0 << STR_SELF_TEST_SHFITS) |
Definition at line 153 of file ist8310.cpp.
| #define STR_SELF_TEST_ON (1 << STR_SELF_TEST_SHFITS) |
Definition at line 152 of file ist8310.cpp.
Referenced by IST8310::set_selftest().
| #define STR_SELF_TEST_SHFITS 6 |
Definition at line 151 of file ist8310.cpp.
| #define WAI_EXPECTED_VALUE 0x10 |
Definition at line 109 of file ist8310.cpp.
Referenced by IST8310::probe().
| enum IST8310_BUS |
| Enumerator | |
|---|---|
| IST8310_BUS_ALL | |
| IST8310_BUS_I2C_EXTERNAL | |
| IST8310_BUS_I2C_EXTERNAL1 | |
| IST8310_BUS_I2C_EXTERNAL2 | |
| IST8310_BUS_I2C_EXTERNAL3 | |
| IST8310_BUS_I2C_INTERNAL | |
Definition at line 177 of file ist8310.cpp.
| int ist8310_main | ( | int | argc, |
| char * | argv[] | ||
| ) |
Definition at line 1406 of file ist8310.cpp.
References IST8310::calibrate(), ist8310::calibrate(), ist8310::info(), IST8310_BUS_ALL, IST8310_BUS_I2C_ADDR, ist8310::reset(), ROTATION_NONE, ist8310::start(), ist8310::test(), and ist8310::usage().
|
static |
Definition at line 101 of file ist8310.cpp.
Referenced by IST8310::collect().
|
static |
Definition at line 103 of file ist8310.cpp.
Referenced by IST8310::collect().
|
static |
Definition at line 102 of file ist8310.cpp.
Referenced by IST8310::collect().
|
static |
Definition at line 104 of file ist8310.cpp.
Referenced by IST8310::collect().