PX4 Firmware
PX4 Autopilot Software http://px4.io
bmm150.hpp File Reference
#include <px4_platform_common/px4_config.h>
#include <sys/types.h>
#include <stdint.h>
#include <stdbool.h>
#include <stddef.h>
#include <stdlib.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 <px4_platform_common/log.h>
#include <perf/perf_counter.h>
#include <systemlib/err.h>
#include <px4_platform_common/px4_work_queue/ScheduledWorkItem.hpp>
#include <systemlib/conversions.h>
#include <nuttx/arch.h>
#include <nuttx/clock.h>
#include <board_config.h>
#include <drivers/drv_hrt.h>
#include <drivers/device/ringbuffer.h>
#include <drivers/device/integrator.h>
#include <drivers/device/i2c.h>
#include <drivers/drv_mag.h>
#include <mathlib/math/filter/LowPassFilter2p.hpp>
#include <lib/conversion/rotation.h>
Include dependency graph for bmm150.hpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  bmm150_data
 
class  BMM150
 

Macros

#define BMM150_DEVICE_PATH_MAG   "/dev/bmm150_i2c_int"
 
#define BMM150_DEVICE_PATH_MAG_EXT   "/dev/bmm150_i2c_ext"
 
#define BMM150_SLAVE_ADDRESS   0x10
 
#define BMM150_BUS_SPEED   1000*100
 
#define BMM150_CHIP_ID   0x32
 
#define BMM150_CHIP_ID_REG   0x40
 
#define BMM150_DATA_X_LSB_REG   0x42
 
#define BMM150_DATA_X_MSB_REG   0x43
 
#define BMM150_DATA_Y_LSB_REG   0x44
 
#define BMM150_DATA_Y_MSB_REG   0x45
 
#define BMM150_DATA_Z_LSB_REG   0x46
 
#define BMM150_DATA_Z_MSB_REG   0x47
 
#define BMM150_R_LSB   0x48
 
#define BMM150_R_MSB   0x49
 
#define BMM150_INT_STATUS_REG   0x4A
 
#define BMM150_POWER_CTRL_REG   0x4B
 
#define BMM150_CTRL_REG   0x4C
 
#define BMM150_INT_SETT_CTRL_REG   0x4D
 
#define BMM150_AXES_EN_CTRL_REG   0x4E
 
#define BMM150_LOW_THRES_SETT_REG   0x4F
 
#define BMM150_HIGH_THERS_SETT_REG   0x50
 
#define BMM150_XY_REP_CTRL_REG   0x51
 
#define BMM150_Z_REP_CTRL_REG   0x52
 
#define BMM150_PRESETMODE_LOWPOWER   1
 
#define BMM150_PRESETMODE_REGULAR   2
 
#define BMM150_PRESETMODE_HIGHACCURACY   3
 
#define BMM150_PRESETMODE_ENHANCED   4
 
#define BMM150_DATA_RATE_10HZ   0x00
 
#define BMM150_DATA_RATE_02HZ   0x08
 
#define BMM150_DATA_RATE_06HZ   0x10
 
#define BMM150_DATA_RATE_08HZ   0x18
 
#define BMM150_DATA_RATE_15HZ   0x20
 
#define BMM150_DATA_RATE_20HZ   0x28
 
#define BMM150_DATA_RATE_25HZ   0x30
 
#define BMM150_DATA_RATE_30HZ   0x38
 
#define BMM150_ADV_ST_OFF   0x00
 
#define BMM150_ADV_ST_NEG   0x80
 
#define BMM150_ADV_ST_POS   0xC0
 
#define BMM150_CHANNEL_X_ENABLE   0x08
 
#define BMM150_CHANNEL_Y_ENABLE   0x10
 
#define BMM150_OVERFLOW_OUTPUT   -32768
 
#define BMM150_OVERFLOW_OUTPUT_S32   ((int32_t)(-2147483647-1))
 
#define BMM150_OVERFLOW_OUTPUT_FLOAT   0.0f
 
#define BMM150_FLIP_OVERFLOW_ADCVAL   -4096
 
#define BMM150_HALL_OVERFLOW_ADCVAL   -16384
 
#define BMM150_LOWPOWER_REPXY   1
 
#define BMM150_REGULAR_REPXY   4
 
#define BMM150_HIGHACCURACY_REPXY   23
 
#define BMM150_ENHANCED_REPXY   7
 
#define BMM150_LOWPOWER_REPZ   2
 
#define BMM150_REGULAR_REPZ   14
 
#define BMM150_HIGHACCURACY_REPZ   82
 
#define BMM150_ENHANCED_REPZ   26
 
#define BMM150_LOWPOWER_DR   BMM150_DATA_RATE_30HZ
 
#define BMM150_REGULAR_DR   BMM150_DATA_RATE_30HZ
 
#define BMM150_HIGHACCURACY_DR   BMM150_DATA_RATE_20HZ
 
#define BMM150_ENHANCED_DR   BMM150_DATA_RATE_10HZ
 
#define BMM150_NORMAL_MODE   0x00
 
#define BMM150_FORCED_MODE   0x02
 
#define BMM150_SLEEP_MODE   0x06
 
#define BMM150_DEFAULT_POWER_MODE   BMM150_NORMAL_MODE
 
#define BMM150_DEFAULT_ODR   BMM150_DATA_RATE_30HZ
 
#define BMM150_MAX_DATA_RATE   100
 
#define BMM150_DEFAULT_INT_SETT   0x3F
 
#define BMM150_DIG_X1   0x5D
 
#define BMM150_DIG_Y1   0x5E
 
#define BMM150_DIG_Z4_LSB   0x62
 
#define BMM150_DIG_Z4_MSB   0x63
 
#define BMM150_DIG_X2   0x64
 
#define BMM150_DIG_Y2   0x65
 
#define BMM150_DIG_Z2_LSB   0x68
 
#define BMM150_DIG_Z2_MSB   0x69
 
#define BMM150_DIG_Z1_LSB   0x6A
 
#define BMM150_DIG_Z1_MSB   0x6B
 
#define BMM150_DIG_XYZ1_LSB   0x6C
 
#define BMM150_DIG_XYZ1_MSB   0x6D
 
#define BMM150_DIG_Z3_LSB   0x6E
 
#define BMM150_DIG_Z3_MSB   0x6F
 
#define BMM150_DIG_XY2   0x70
 
#define BMM150_DIG_XY1   0x71
 
#define BMM150_POWER_MASK   0x06
 
#define BMM150_OUTPUT_DATA_RATE_MASK   0x38
 
#define BMM150_SOFT_RESET_VALUE   0x82
 
#define BMM150_SOFT_RESET_MASK   0x82
 
#define BMM150_CONVERSION_INTERVAL   (1000000 / 100) /* microseconds */
 

Macro Definition Documentation

◆ BMM150_ADV_ST_NEG

#define BMM150_ADV_ST_NEG   0x80

Definition at line 98 of file bmm150.hpp.

◆ BMM150_ADV_ST_OFF

#define BMM150_ADV_ST_OFF   0x00

Definition at line 97 of file bmm150.hpp.

◆ BMM150_ADV_ST_POS

#define BMM150_ADV_ST_POS   0xC0

Definition at line 99 of file bmm150.hpp.

◆ BMM150_AXES_EN_CTRL_REG

#define BMM150_AXES_EN_CTRL_REG   0x4E

Definition at line 71 of file bmm150.hpp.

Referenced by BMM150::print_registers().

◆ BMM150_BUS_SPEED

#define BMM150_BUS_SPEED   1000*100

Definition at line 46 of file bmm150.hpp.

◆ BMM150_CHANNEL_X_ENABLE

#define BMM150_CHANNEL_X_ENABLE   0x08

Definition at line 103 of file bmm150.hpp.

◆ BMM150_CHANNEL_Y_ENABLE

#define BMM150_CHANNEL_Y_ENABLE   0x10

Definition at line 104 of file bmm150.hpp.

◆ BMM150_CHIP_ID

#define BMM150_CHIP_ID   0x32

Definition at line 49 of file bmm150.hpp.

Referenced by BMM150::init().

◆ BMM150_CHIP_ID_REG

#define BMM150_CHIP_ID_REG   0x40

Definition at line 52 of file bmm150.hpp.

Referenced by BMM150::init(), and BMM150::print_registers().

◆ BMM150_CONVERSION_INTERVAL

#define BMM150_CONVERSION_INTERVAL   (1000000 / 100) /* microseconds */

Definition at line 183 of file bmm150.hpp.

Referenced by BMM150::ioctl(), BMM150::read(), and BMM150::Run().

◆ BMM150_CTRL_REG

#define BMM150_CTRL_REG   0x4C

Definition at line 69 of file bmm150.hpp.

Referenced by BMM150::set_data_rate(), and BMM150::set_power_mode().

◆ BMM150_DATA_RATE_02HZ

#define BMM150_DATA_RATE_02HZ   0x08

Definition at line 88 of file bmm150.hpp.

Referenced by BMM150::set_data_rate().

◆ BMM150_DATA_RATE_06HZ

#define BMM150_DATA_RATE_06HZ   0x10

Definition at line 89 of file bmm150.hpp.

Referenced by BMM150::set_data_rate().

◆ BMM150_DATA_RATE_08HZ

#define BMM150_DATA_RATE_08HZ   0x18

Definition at line 90 of file bmm150.hpp.

Referenced by BMM150::set_data_rate().

◆ BMM150_DATA_RATE_10HZ

#define BMM150_DATA_RATE_10HZ   0x00

Definition at line 87 of file bmm150.hpp.

Referenced by BMM150::set_data_rate().

◆ BMM150_DATA_RATE_15HZ

#define BMM150_DATA_RATE_15HZ   0x20

Definition at line 91 of file bmm150.hpp.

Referenced by BMM150::set_data_rate().

◆ BMM150_DATA_RATE_20HZ

#define BMM150_DATA_RATE_20HZ   0x28

Definition at line 92 of file bmm150.hpp.

Referenced by BMM150::set_data_rate().

◆ BMM150_DATA_RATE_25HZ

#define BMM150_DATA_RATE_25HZ   0x30

Definition at line 93 of file bmm150.hpp.

Referenced by BMM150::set_data_rate().

◆ BMM150_DATA_RATE_30HZ

#define BMM150_DATA_RATE_30HZ   0x38

Definition at line 94 of file bmm150.hpp.

Referenced by BMM150::BMM150(), and BMM150::set_data_rate().

◆ BMM150_DATA_X_LSB_REG

#define BMM150_DATA_X_LSB_REG   0x42

Definition at line 55 of file bmm150.hpp.

Referenced by BMM150::collect().

◆ BMM150_DATA_X_MSB_REG

#define BMM150_DATA_X_MSB_REG   0x43

Definition at line 56 of file bmm150.hpp.

◆ BMM150_DATA_Y_LSB_REG

#define BMM150_DATA_Y_LSB_REG   0x44

Definition at line 57 of file bmm150.hpp.

◆ BMM150_DATA_Y_MSB_REG

#define BMM150_DATA_Y_MSB_REG   0x45

Definition at line 58 of file bmm150.hpp.

◆ BMM150_DATA_Z_LSB_REG

#define BMM150_DATA_Z_LSB_REG   0x46

Definition at line 59 of file bmm150.hpp.

◆ BMM150_DATA_Z_MSB_REG

#define BMM150_DATA_Z_MSB_REG   0x47

Definition at line 60 of file bmm150.hpp.

◆ BMM150_DEFAULT_INT_SETT

#define BMM150_DEFAULT_INT_SETT   0x3F

Definition at line 150 of file bmm150.hpp.

◆ BMM150_DEFAULT_ODR

#define BMM150_DEFAULT_ODR   BMM150_DATA_RATE_30HZ

Definition at line 144 of file bmm150.hpp.

Referenced by BMM150::reset().

◆ BMM150_DEFAULT_POWER_MODE

#define BMM150_DEFAULT_POWER_MODE   BMM150_NORMAL_MODE

Definition at line 141 of file bmm150.hpp.

Referenced by BMM150::BMM150(), and BMM150::reset().

◆ BMM150_DEVICE_PATH_MAG

#define BMM150_DEVICE_PATH_MAG   "/dev/bmm150_i2c_int"

Definition at line 40 of file bmm150.hpp.

Referenced by bmm150::reset(), bmm150::start(), and bmm150::test().

◆ BMM150_DEVICE_PATH_MAG_EXT

#define BMM150_DEVICE_PATH_MAG_EXT   "/dev/bmm150_i2c_ext"

Definition at line 42 of file bmm150.hpp.

Referenced by bmm150::reset(), bmm150::start(), and bmm150::test().

◆ BMM150_DIG_X1

#define BMM150_DIG_X1   0x5D

Definition at line 153 of file bmm150.hpp.

Referenced by BMM150::init_trim_registers().

◆ BMM150_DIG_X2

#define BMM150_DIG_X2   0x64

Definition at line 157 of file bmm150.hpp.

Referenced by BMM150::init_trim_registers().

◆ BMM150_DIG_XY1

#define BMM150_DIG_XY1   0x71

Definition at line 168 of file bmm150.hpp.

Referenced by BMM150::init_trim_registers().

◆ BMM150_DIG_XY2

#define BMM150_DIG_XY2   0x70

Definition at line 167 of file bmm150.hpp.

Referenced by BMM150::init_trim_registers().

◆ BMM150_DIG_XYZ1_LSB

#define BMM150_DIG_XYZ1_LSB   0x6C

Definition at line 163 of file bmm150.hpp.

Referenced by BMM150::init_trim_registers().

◆ BMM150_DIG_XYZ1_MSB

#define BMM150_DIG_XYZ1_MSB   0x6D

Definition at line 164 of file bmm150.hpp.

◆ BMM150_DIG_Y1

#define BMM150_DIG_Y1   0x5E

Definition at line 154 of file bmm150.hpp.

Referenced by BMM150::init_trim_registers().

◆ BMM150_DIG_Y2

#define BMM150_DIG_Y2   0x65

Definition at line 158 of file bmm150.hpp.

Referenced by BMM150::init_trim_registers().

◆ BMM150_DIG_Z1_LSB

#define BMM150_DIG_Z1_LSB   0x6A

Definition at line 161 of file bmm150.hpp.

Referenced by BMM150::init_trim_registers().

◆ BMM150_DIG_Z1_MSB

#define BMM150_DIG_Z1_MSB   0x6B

Definition at line 162 of file bmm150.hpp.

◆ BMM150_DIG_Z2_LSB

#define BMM150_DIG_Z2_LSB   0x68

Definition at line 159 of file bmm150.hpp.

Referenced by BMM150::init_trim_registers().

◆ BMM150_DIG_Z2_MSB

#define BMM150_DIG_Z2_MSB   0x69

Definition at line 160 of file bmm150.hpp.

◆ BMM150_DIG_Z3_LSB

#define BMM150_DIG_Z3_LSB   0x6E

Definition at line 165 of file bmm150.hpp.

Referenced by BMM150::init_trim_registers().

◆ BMM150_DIG_Z3_MSB

#define BMM150_DIG_Z3_MSB   0x6F

Definition at line 166 of file bmm150.hpp.

◆ BMM150_DIG_Z4_LSB

#define BMM150_DIG_Z4_LSB   0x62

Definition at line 155 of file bmm150.hpp.

Referenced by BMM150::init_trim_registers().

◆ BMM150_DIG_Z4_MSB

#define BMM150_DIG_Z4_MSB   0x63

Definition at line 156 of file bmm150.hpp.

◆ BMM150_ENHANCED_DR

#define BMM150_ENHANCED_DR   BMM150_DATA_RATE_10HZ

Definition at line 132 of file bmm150.hpp.

Referenced by BMM150::set_presetmode().

◆ BMM150_ENHANCED_REPXY

#define BMM150_ENHANCED_REPXY   7

Definition at line 120 of file bmm150.hpp.

Referenced by BMM150::set_presetmode().

◆ BMM150_ENHANCED_REPZ

#define BMM150_ENHANCED_REPZ   26

Definition at line 126 of file bmm150.hpp.

Referenced by BMM150::set_presetmode().

◆ BMM150_FLIP_OVERFLOW_ADCVAL

#define BMM150_FLIP_OVERFLOW_ADCVAL   -4096

Definition at line 112 of file bmm150.hpp.

Referenced by BMM150::collect().

◆ BMM150_FORCED_MODE

#define BMM150_FORCED_MODE   0x02

Definition at line 137 of file bmm150.hpp.

Referenced by BMM150::measure(), and BMM150::set_power_mode().

◆ BMM150_HALL_OVERFLOW_ADCVAL

#define BMM150_HALL_OVERFLOW_ADCVAL   -16384

Definition at line 113 of file bmm150.hpp.

Referenced by BMM150::collect().

◆ BMM150_HIGH_THERS_SETT_REG

#define BMM150_HIGH_THERS_SETT_REG   0x50

Definition at line 73 of file bmm150.hpp.

◆ BMM150_HIGHACCURACY_DR

#define BMM150_HIGHACCURACY_DR   BMM150_DATA_RATE_20HZ

Definition at line 131 of file bmm150.hpp.

Referenced by BMM150::set_presetmode().

◆ BMM150_HIGHACCURACY_REPXY

#define BMM150_HIGHACCURACY_REPXY   23

Definition at line 119 of file bmm150.hpp.

Referenced by BMM150::set_presetmode().

◆ BMM150_HIGHACCURACY_REPZ

#define BMM150_HIGHACCURACY_REPZ   82

Definition at line 125 of file bmm150.hpp.

Referenced by BMM150::set_presetmode().

◆ BMM150_INT_SETT_CTRL_REG

#define BMM150_INT_SETT_CTRL_REG   0x4D

Definition at line 70 of file bmm150.hpp.

Referenced by BMM150::print_registers().

◆ BMM150_INT_STATUS_REG

#define BMM150_INT_STATUS_REG   0x4A

Definition at line 65 of file bmm150.hpp.

◆ BMM150_LOW_THRES_SETT_REG

#define BMM150_LOW_THRES_SETT_REG   0x4F

Definition at line 72 of file bmm150.hpp.

◆ BMM150_LOWPOWER_DR

#define BMM150_LOWPOWER_DR   BMM150_DATA_RATE_30HZ

Definition at line 129 of file bmm150.hpp.

Referenced by BMM150::set_presetmode().

◆ BMM150_LOWPOWER_REPXY

#define BMM150_LOWPOWER_REPXY   1

Definition at line 117 of file bmm150.hpp.

Referenced by BMM150::set_presetmode().

◆ BMM150_LOWPOWER_REPZ

#define BMM150_LOWPOWER_REPZ   2

Definition at line 123 of file bmm150.hpp.

Referenced by BMM150::set_presetmode().

◆ BMM150_MAX_DATA_RATE

#define BMM150_MAX_DATA_RATE   100

Definition at line 147 of file bmm150.hpp.

Referenced by BMM150::ioctl().

◆ BMM150_NORMAL_MODE

#define BMM150_NORMAL_MODE   0x00

Definition at line 136 of file bmm150.hpp.

Referenced by BMM150::set_power_mode().

◆ BMM150_OUTPUT_DATA_RATE_MASK

#define BMM150_OUTPUT_DATA_RATE_MASK   0x38

Definition at line 175 of file bmm150.hpp.

Referenced by BMM150::set_data_rate().

◆ BMM150_OVERFLOW_OUTPUT

#define BMM150_OVERFLOW_OUTPUT   -32768

Definition at line 109 of file bmm150.hpp.

◆ BMM150_OVERFLOW_OUTPUT_FLOAT

#define BMM150_OVERFLOW_OUTPUT_FLOAT   0.0f

Definition at line 111 of file bmm150.hpp.

Referenced by BMM150::collect().

◆ BMM150_OVERFLOW_OUTPUT_S32

#define BMM150_OVERFLOW_OUTPUT_S32   ((int32_t)(-2147483647-1))

Definition at line 110 of file bmm150.hpp.

◆ BMM150_POWER_CTRL_REG

#define BMM150_POWER_CTRL_REG   0x4B

Definition at line 68 of file bmm150.hpp.

Referenced by BMM150::init(), and BMM150::reset().

◆ BMM150_POWER_MASK

#define BMM150_POWER_MASK   0x06

Definition at line 172 of file bmm150.hpp.

Referenced by BMM150::set_power_mode().

◆ BMM150_PRESETMODE_ENHANCED

#define BMM150_PRESETMODE_ENHANCED   4

Definition at line 83 of file bmm150.hpp.

◆ BMM150_PRESETMODE_HIGHACCURACY

#define BMM150_PRESETMODE_HIGHACCURACY   3

Definition at line 82 of file bmm150.hpp.

◆ BMM150_PRESETMODE_LOWPOWER

#define BMM150_PRESETMODE_LOWPOWER   1

Definition at line 80 of file bmm150.hpp.

◆ BMM150_PRESETMODE_REGULAR

#define BMM150_PRESETMODE_REGULAR   2

Definition at line 81 of file bmm150.hpp.

Referenced by BMM150::reset().

◆ BMM150_R_LSB

#define BMM150_R_LSB   0x48

Definition at line 61 of file bmm150.hpp.

Referenced by BMM150::collect().

◆ BMM150_R_MSB

#define BMM150_R_MSB   0x49

Definition at line 62 of file bmm150.hpp.

◆ BMM150_REGULAR_DR

#define BMM150_REGULAR_DR   BMM150_DATA_RATE_30HZ

Definition at line 130 of file bmm150.hpp.

Referenced by BMM150::set_presetmode().

◆ BMM150_REGULAR_REPXY

#define BMM150_REGULAR_REPXY   4

Definition at line 118 of file bmm150.hpp.

Referenced by BMM150::set_presetmode().

◆ BMM150_REGULAR_REPZ

#define BMM150_REGULAR_REPZ   14

Definition at line 124 of file bmm150.hpp.

Referenced by BMM150::set_presetmode().

◆ BMM150_SLAVE_ADDRESS

#define BMM150_SLAVE_ADDRESS   0x10

Definition at line 44 of file bmm150.hpp.

◆ BMM150_SLEEP_MODE

#define BMM150_SLEEP_MODE   0x06

Definition at line 138 of file bmm150.hpp.

Referenced by BMM150::set_power_mode().

◆ BMM150_SOFT_RESET_MASK

#define BMM150_SOFT_RESET_MASK   0x82

Definition at line 180 of file bmm150.hpp.

Referenced by BMM150::reset().

◆ BMM150_SOFT_RESET_VALUE

#define BMM150_SOFT_RESET_VALUE   0x82

Definition at line 177 of file bmm150.hpp.

Referenced by BMM150::reset().

◆ BMM150_XY_REP_CTRL_REG

#define BMM150_XY_REP_CTRL_REG   0x51

Definition at line 76 of file bmm150.hpp.

Referenced by BMM150::set_rep_xy().

◆ BMM150_Z_REP_CTRL_REG

#define BMM150_Z_REP_CTRL_REG   0x52

Definition at line 77 of file bmm150.hpp.

Referenced by BMM150::set_rep_z().