4 #include <px4_platform_common/px4_config.h> 11 #include <semaphore.h> 19 #include <px4_platform_common/log.h> 23 #include <px4_platform_common/px4_work_queue/ScheduledWorkItem.hpp> 26 #include <nuttx/arch.h> 27 #include <nuttx/clock.h> 29 #include <board_config.h> 40 #define BMM150_DEVICE_PATH_MAG "/dev/bmm150_i2c_int" 42 #define BMM150_DEVICE_PATH_MAG_EXT "/dev/bmm150_i2c_ext" 44 #define BMM150_SLAVE_ADDRESS 0x10 46 #define BMM150_BUS_SPEED 1000*100 49 #define BMM150_CHIP_ID 0x32 52 #define BMM150_CHIP_ID_REG 0x40 55 #define BMM150_DATA_X_LSB_REG 0x42 56 #define BMM150_DATA_X_MSB_REG 0x43 57 #define BMM150_DATA_Y_LSB_REG 0x44 58 #define BMM150_DATA_Y_MSB_REG 0x45 59 #define BMM150_DATA_Z_LSB_REG 0x46 60 #define BMM150_DATA_Z_MSB_REG 0x47 61 #define BMM150_R_LSB 0x48 62 #define BMM150_R_MSB 0x49 65 #define BMM150_INT_STATUS_REG 0x4A 68 #define BMM150_POWER_CTRL_REG 0x4B 69 #define BMM150_CTRL_REG 0x4C 70 #define BMM150_INT_SETT_CTRL_REG 0x4D 71 #define BMM150_AXES_EN_CTRL_REG 0x4E 72 #define BMM150_LOW_THRES_SETT_REG 0x4F 73 #define BMM150_HIGH_THERS_SETT_REG 0x50 76 #define BMM150_XY_REP_CTRL_REG 0x51 77 #define BMM150_Z_REP_CTRL_REG 0x52 80 #define BMM150_PRESETMODE_LOWPOWER 1 81 #define BMM150_PRESETMODE_REGULAR 2 82 #define BMM150_PRESETMODE_HIGHACCURACY 3 83 #define BMM150_PRESETMODE_ENHANCED 4 87 #define BMM150_DATA_RATE_10HZ 0x00 88 #define BMM150_DATA_RATE_02HZ 0x08 89 #define BMM150_DATA_RATE_06HZ 0x10 90 #define BMM150_DATA_RATE_08HZ 0x18 91 #define BMM150_DATA_RATE_15HZ 0x20 92 #define BMM150_DATA_RATE_20HZ 0x28 93 #define BMM150_DATA_RATE_25HZ 0x30 94 #define BMM150_DATA_RATE_30HZ 0x38 97 #define BMM150_ADV_ST_OFF 0x00 98 #define BMM150_ADV_ST_NEG 0x80 99 #define BMM150_ADV_ST_POS 0xC0 103 #define BMM150_CHANNEL_X_ENABLE 0x08 104 #define BMM150_CHANNEL_Y_ENABLE 0x10 109 #define BMM150_OVERFLOW_OUTPUT -32768 110 #define BMM150_OVERFLOW_OUTPUT_S32 ((int32_t)(-2147483647-1)) 111 #define BMM150_OVERFLOW_OUTPUT_FLOAT 0.0f 112 #define BMM150_FLIP_OVERFLOW_ADCVAL -4096 113 #define BMM150_HALL_OVERFLOW_ADCVAL -16384 117 #define BMM150_LOWPOWER_REPXY 1 118 #define BMM150_REGULAR_REPXY 4 119 #define BMM150_HIGHACCURACY_REPXY 23 120 #define BMM150_ENHANCED_REPXY 7 123 #define BMM150_LOWPOWER_REPZ 2 124 #define BMM150_REGULAR_REPZ 14 125 #define BMM150_HIGHACCURACY_REPZ 82 126 #define BMM150_ENHANCED_REPZ 26 129 #define BMM150_LOWPOWER_DR BMM150_DATA_RATE_30HZ 130 #define BMM150_REGULAR_DR BMM150_DATA_RATE_30HZ 131 #define BMM150_HIGHACCURACY_DR BMM150_DATA_RATE_20HZ 132 #define BMM150_ENHANCED_DR BMM150_DATA_RATE_10HZ 136 #define BMM150_NORMAL_MODE 0x00 137 #define BMM150_FORCED_MODE 0x02 138 #define BMM150_SLEEP_MODE 0x06 141 #define BMM150_DEFAULT_POWER_MODE BMM150_NORMAL_MODE 144 #define BMM150_DEFAULT_ODR BMM150_DATA_RATE_30HZ 147 #define BMM150_MAX_DATA_RATE 100 150 #define BMM150_DEFAULT_INT_SETT 0x3F 153 #define BMM150_DIG_X1 0x5D 154 #define BMM150_DIG_Y1 0x5E 155 #define BMM150_DIG_Z4_LSB 0x62 156 #define BMM150_DIG_Z4_MSB 0x63 157 #define BMM150_DIG_X2 0x64 158 #define BMM150_DIG_Y2 0x65 159 #define BMM150_DIG_Z2_LSB 0x68 160 #define BMM150_DIG_Z2_MSB 0x69 161 #define BMM150_DIG_Z1_LSB 0x6A 162 #define BMM150_DIG_Z1_MSB 0x6B 163 #define BMM150_DIG_XYZ1_LSB 0x6C 164 #define BMM150_DIG_XYZ1_MSB 0x6D 165 #define BMM150_DIG_Z3_LSB 0x6E 166 #define BMM150_DIG_Z3_MSB 0x6F 167 #define BMM150_DIG_XY2 0x70 168 #define BMM150_DIG_XY1 0x71 172 #define BMM150_POWER_MASK 0x06 175 #define BMM150_OUTPUT_DATA_RATE_MASK 0x38 177 #define BMM150_SOFT_RESET_VALUE 0x82 180 #define BMM150_SOFT_RESET_MASK 0x82 183 #define BMM150_CONVERSION_INTERVAL (1000000 / 100) 194 class BMM150 :
public device::I2C,
public px4::ScheduledWorkItem
201 virtual ssize_t
read(
struct file *filp,
char *buffer,
size_t buflen);
202 virtual int ioctl(
struct file *filp,
int cmd,
unsigned long arg);
214 void print_registers();
270 int init_trim_registers(
void);
290 int get_data(uint8_t reg, uint8_t *
data,
unsigned len);
310 uint8_t read_reg(uint8_t reg);
319 int write_reg(uint8_t reg, uint8_t value);
330 void modify_reg(
unsigned reg, uint8_t clearbits, uint8_t setbits);
335 int set_power_mode(uint8_t power);
340 int set_data_rate(uint8_t data_rate);
345 int set_rep_xy(uint8_t rep_xy);
350 int set_rep_z(uint8_t rep_z);
356 int set_presetmode(uint8_t presetmode);
int8_t dig_x2
trim x2 data
uint16_t dig_xyz1
trim xyz1 data
perf_counter_t _comms_errors
mag scaling factors; Vout = (Vin * Vscale) + Voffset
int reset(enum LPS22HB_BUS busid)
Reset the driver.
int8_t dig_y2
trim y2 data
High-resolution timer with callouts and timekeeping.
perf_counter_t _duplicates
ringbuffer::RingBuffer * _reports
int8_t dig_y1
trim y1 data
static void read(bootloader_app_shared_t *pshared)
uint16_t dig_z1
trim z1 data
uint8_t dig_xy1
trim xy1 data
int8_t dig_x1
trim x1 data
void init()
Activates/configures the hardware registers.
Definition of commonly used conversions.
Rotation
Enum for board and external compass rotations.
perf_counter_t _good_transfers
int16_t dig_z4
trim z4 data
Simple error/warning functions, heavily inspired by the BSD functions of the same names...
perf_counter_t _measure_perf
__BEGIN_DECLS typedef void * orb_advert_t
ORB topic advertiser handle.
perf_counter_t _bad_transfers
int16_t dig_z2
trim z2 data
uint8_t _output_data_rate
struct @83::@85::@87 file
int16_t dig_z3
trim z3 data
perf_counter_t _sample_perf
bool _calibrated
the calibration is valid
int8_t dig_xy2
trim xy2 data
Performance measuring tools.
Base class for devices connected via I2C.