Christian Dupaty 03/2021 Library and demo for BMM150 see datasheet here : https://www.bosch-sensortec.com/products/motion-sensors/magnetometers-bmm150/ Adaptation of BOSCH driver https://github.com/BoschSensortec/BMM150-Sensor-API for ARM MBED and tested on NUCLEO-L073RZ and GEOMAGNETIC CLICK https://www.mikroe.com/geomagnetic-click
Dependents: BMM150_HelloWorld2
bmm150_defs.h@1:9651fd7ee8f6, 2021-03-25 (annotated)
- Committer:
- cdupaty
- Date:
- Thu Mar 25 13:08:05 2021 +0000
- Revision:
- 1:9651fd7ee8f6
- Parent:
- 0:ef20a9039c0c
New I2C functions
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
cdupaty | 0:ef20a9039c0c | 1 | /* |
cdupaty | 0:ef20a9039c0c | 2 | Christian Dupaty 03/2021 |
cdupaty | 0:ef20a9039c0c | 3 | Library and demo for BMM150 see datasheet here : https://www.bosch-sensortec.com/products/motion-sensors/magnetometers-bmm150/ |
cdupaty | 0:ef20a9039c0c | 4 | Adaptation of BOSCH driver https://github.com/BoschSensortec/BMM150-Sensor-API |
cdupaty | 0:ef20a9039c0c | 5 | for ARM MBED and tested on NUCLEO-L073RZ and GEOMAGNETIC CLICK |
cdupaty | 0:ef20a9039c0c | 6 | https://www.mikroe.com/geomagnetic-click |
cdupaty | 0:ef20a9039c0c | 7 | */ |
cdupaty | 0:ef20a9039c0c | 8 | |
cdupaty | 0:ef20a9039c0c | 9 | #ifndef _BMM150_DEFS_H_ |
cdupaty | 0:ef20a9039c0c | 10 | #define _BMM150_DEFS_H_ |
cdupaty | 0:ef20a9039c0c | 11 | |
cdupaty | 0:ef20a9039c0c | 12 | /**\name Macro definitions */ |
cdupaty | 0:ef20a9039c0c | 13 | /* |
cdupaty | 0:ef20a9039c0c | 14 | typedef unsigned int unsigned int; |
cdupaty | 0:ef20a9039c0c | 15 | typedef int int; |
cdupaty | 0:ef20a9039c0c | 16 | typedef unsigned char unsigned char; |
cdupaty | 0:ef20a9039c0c | 17 | typedef char char; |
cdupaty | 0:ef20a9039c0c | 18 | */ |
cdupaty | 0:ef20a9039c0c | 19 | /**\name API success code */ |
cdupaty | 0:ef20a9039c0c | 20 | #define BMM150_OK (0) |
cdupaty | 0:ef20a9039c0c | 21 | |
cdupaty | 0:ef20a9039c0c | 22 | /**\name API error codes */ |
cdupaty | 0:ef20a9039c0c | 23 | #define BMM150_E_ID_NOT_CONFORM (-1) |
cdupaty | 0:ef20a9039c0c | 24 | #define BMM150_E_INVALID_CONFIG (-2) |
cdupaty | 0:ef20a9039c0c | 25 | // #define BMM150_E_ID_WRONG (-3) |
cdupaty | 0:ef20a9039c0c | 26 | |
cdupaty | 0:ef20a9039c0c | 27 | /**\name API warning codes */ |
cdupaty | 0:ef20a9039c0c | 28 | #define BMM150_W_NORMAL_SELF_TEST_YZ_FAIL INT8_C(1) |
cdupaty | 0:ef20a9039c0c | 29 | #define BMM150_W_NORMAL_SELF_TEST_XZ_FAIL INT8_C(2) |
cdupaty | 0:ef20a9039c0c | 30 | #define BMM150_W_NORMAL_SELF_TEST_Z_FAIL INT8_C(3) |
cdupaty | 0:ef20a9039c0c | 31 | #define BMM150_W_NORMAL_SELF_TEST_XY_FAIL INT8_C(4) |
cdupaty | 0:ef20a9039c0c | 32 | #define BMM150_W_NORMAL_SELF_TEST_Y_FAIL INT8_C(5) |
cdupaty | 0:ef20a9039c0c | 33 | #define BMM150_W_NORMAL_SELF_TEST_X_FAIL INT8_C(6) |
cdupaty | 0:ef20a9039c0c | 34 | #define BMM150_W_NORMAL_SELF_TEST_XYZ_FAIL INT8_C(7) |
cdupaty | 0:ef20a9039c0c | 35 | #define BMM150_W_ADV_SELF_TEST_FAIL INT8_C(8) |
cdupaty | 0:ef20a9039c0c | 36 | |
cdupaty | 0:ef20a9039c0c | 37 | #define BMM150_I2C_Address (0x13 << 1) |
cdupaty | 0:ef20a9039c0c | 38 | #define i2cWadr (BMM150_I2C_Address<<1) |
cdupaty | 0:ef20a9039c0c | 39 | #define i2cRadr (BMM150_I2C_Address<<1)+1 |
cdupaty | 0:ef20a9039c0c | 40 | #define ACK 1 |
cdupaty | 0:ef20a9039c0c | 41 | #define NACK 0 |
cdupaty | 0:ef20a9039c0c | 42 | |
cdupaty | 0:ef20a9039c0c | 43 | /**\name CHIP ID & SOFT RESET VALUES */ |
cdupaty | 0:ef20a9039c0c | 44 | #define BMM150_CHIP_ID 0x32 |
cdupaty | 0:ef20a9039c0c | 45 | #define BMM150_SET_SOFT_RESET 0x82 |
cdupaty | 0:ef20a9039c0c | 46 | |
cdupaty | 0:ef20a9039c0c | 47 | /**\name POWER MODE DEFINTIONS */ |
cdupaty | 0:ef20a9039c0c | 48 | #define BMM150_NORMAL_MODE 0x00 |
cdupaty | 0:ef20a9039c0c | 49 | #define BMM150_FORCED_MODE 0x01 |
cdupaty | 0:ef20a9039c0c | 50 | #define BMM150_SLEEP_MODE 0x03 |
cdupaty | 0:ef20a9039c0c | 51 | #define BMM150_SUSPEND_MODE 0x04 |
cdupaty | 0:ef20a9039c0c | 52 | |
cdupaty | 0:ef20a9039c0c | 53 | /**\name PRESET MODE DEFINITIONS */ |
cdupaty | 0:ef20a9039c0c | 54 | #define BMM150_PRESETMODE_LOWPOWER 0x01 |
cdupaty | 0:ef20a9039c0c | 55 | #define BMM150_PRESETMODE_REGULAR 0x02 |
cdupaty | 0:ef20a9039c0c | 56 | #define BMM150_PRESETMODE_HIGHACCURACY 0x03 |
cdupaty | 0:ef20a9039c0c | 57 | #define BMM150_PRESETMODE_ENHANCED 0x04 |
cdupaty | 0:ef20a9039c0c | 58 | |
cdupaty | 0:ef20a9039c0c | 59 | /**\name Power mode settings */ |
cdupaty | 0:ef20a9039c0c | 60 | #define BMM150_POWER_CNTRL_DISABLE 0x00 |
cdupaty | 0:ef20a9039c0c | 61 | #define BMM150_POWER_CNTRL_ENABLE 0x01 |
cdupaty | 0:ef20a9039c0c | 62 | |
cdupaty | 0:ef20a9039c0c | 63 | /**\name Sensor delay time settings */ |
cdupaty | 0:ef20a9039c0c | 64 | #define BMM150_SOFT_RESET_wait_ms (1) |
cdupaty | 0:ef20a9039c0c | 65 | #define BMM150_SOFT_RESET_DELAY (1) |
cdupaty | 0:ef20a9039c0c | 66 | #define BMM150_NORMAL_SELF_TEST_DELAY (2) |
cdupaty | 0:ef20a9039c0c | 67 | #define BMM150_START_UP_TIME (3) |
cdupaty | 0:ef20a9039c0c | 68 | #define BMM150_ADV_SELF_TEST_DELAY (4) |
cdupaty | 0:ef20a9039c0c | 69 | |
cdupaty | 0:ef20a9039c0c | 70 | /**\name ENABLE/DISABLE DEFINITIONS */ |
cdupaty | 0:ef20a9039c0c | 71 | #define BMM150_XY_CHANNEL_ENABLE 0x00 |
cdupaty | 0:ef20a9039c0c | 72 | #define BMM150_XY_CHANNEL_DISABLE 0x03 |
cdupaty | 0:ef20a9039c0c | 73 | |
cdupaty | 0:ef20a9039c0c | 74 | /**\name Register Address */ |
cdupaty | 0:ef20a9039c0c | 75 | #define BMM150_CHIP_ID_ADDR 0x40 |
cdupaty | 0:ef20a9039c0c | 76 | #define BMM150_DATA_X_LSB 0x42 |
cdupaty | 0:ef20a9039c0c | 77 | #define BMM150_DATA_X_MSB 0x43 |
cdupaty | 0:ef20a9039c0c | 78 | #define BMM150_DATA_Y_LSB 0x44 |
cdupaty | 0:ef20a9039c0c | 79 | #define BMM150_DATA_Y_MSB 0x45 |
cdupaty | 0:ef20a9039c0c | 80 | #define BMM150_DATA_Z_LSB 0x46 |
cdupaty | 0:ef20a9039c0c | 81 | #define BMM150_DATA_Z_MSB 0x47 |
cdupaty | 0:ef20a9039c0c | 82 | #define BMM150_DATA_READY_STATUS 0x48 |
cdupaty | 0:ef20a9039c0c | 83 | #define BMM150_INTERRUPT_STATUS 0x4A |
cdupaty | 0:ef20a9039c0c | 84 | #define BMM150_POWER_CONTROL_ADDR 0x4B |
cdupaty | 0:ef20a9039c0c | 85 | #define BMM150_OP_MODE_ADDR 0x4C |
cdupaty | 0:ef20a9039c0c | 86 | #define BMM150_INT_CONFIG_ADDR 0x4D |
cdupaty | 0:ef20a9039c0c | 87 | #define BMM150_AXES_ENABLE_ADDR 0x4E |
cdupaty | 0:ef20a9039c0c | 88 | #define BMM150_LOW_THRESHOLD_ADDR 0x4F |
cdupaty | 0:ef20a9039c0c | 89 | #define BMM150_HIGH_THRESHOLD_ADDR 0x50 |
cdupaty | 0:ef20a9039c0c | 90 | #define BMM150_REP_XY_ADDR 0x51 |
cdupaty | 0:ef20a9039c0c | 91 | #define BMM150_REP_Z_ADDR 0x52 |
cdupaty | 0:ef20a9039c0c | 92 | |
cdupaty | 0:ef20a9039c0c | 93 | /**\name DATA RATE DEFINITIONS */ |
cdupaty | 0:ef20a9039c0c | 94 | #define BMM150_DATA_RATE_10HZ (0x00) |
cdupaty | 0:ef20a9039c0c | 95 | #define BMM150_DATA_RATE_02HZ (0x01) |
cdupaty | 0:ef20a9039c0c | 96 | #define BMM150_DATA_RATE_06HZ (0x02) |
cdupaty | 0:ef20a9039c0c | 97 | #define BMM150_DATA_RATE_08HZ (0x03) |
cdupaty | 0:ef20a9039c0c | 98 | #define BMM150_DATA_RATE_15HZ (0x04) |
cdupaty | 0:ef20a9039c0c | 99 | #define BMM150_DATA_RATE_20HZ (0x05) |
cdupaty | 0:ef20a9039c0c | 100 | #define BMM150_DATA_RATE_25HZ (0x06) |
cdupaty | 0:ef20a9039c0c | 101 | #define BMM150_DATA_RATE_30HZ (0x07) |
cdupaty | 0:ef20a9039c0c | 102 | |
cdupaty | 0:ef20a9039c0c | 103 | /**\name TRIM REGISTERS */ |
cdupaty | 0:ef20a9039c0c | 104 | /* Trim Extended Registers */ |
cdupaty | 0:ef20a9039c0c | 105 | #define BMM150_DIG_X1 uint8_t(0x5D) |
cdupaty | 0:ef20a9039c0c | 106 | #define BMM150_DIG_Y1 uint8_t(0x5E) |
cdupaty | 0:ef20a9039c0c | 107 | #define BMM150_DIG_Z4_LSB uint8_t(0x62) |
cdupaty | 0:ef20a9039c0c | 108 | #define BMM150_DIG_Z4_MSB uint8_t(0x63) |
cdupaty | 0:ef20a9039c0c | 109 | #define BMM150_DIG_X2 uint8_t(0x64) |
cdupaty | 0:ef20a9039c0c | 110 | #define BMM150_DIG_Y2 uint8_t(0x65) |
cdupaty | 0:ef20a9039c0c | 111 | #define BMM150_DIG_Z2_LSB uint8_t(0x68) |
cdupaty | 0:ef20a9039c0c | 112 | #define BMM150_DIG_Z2_MSB uint8_t(0x69) |
cdupaty | 0:ef20a9039c0c | 113 | #define BMM150_DIG_Z1_LSB uint8_t(0x6A) |
cdupaty | 0:ef20a9039c0c | 114 | #define BMM150_DIG_Z1_MSB uint8_t(0x6B) |
cdupaty | 0:ef20a9039c0c | 115 | #define BMM150_DIG_XYZ1_LSB uint8_t(0x6C) |
cdupaty | 0:ef20a9039c0c | 116 | #define BMM150_DIG_XYZ1_MSB uint8_t(0x6D) |
cdupaty | 0:ef20a9039c0c | 117 | #define BMM150_DIG_Z3_LSB uint8_t(0x6E) |
cdupaty | 0:ef20a9039c0c | 118 | #define BMM150_DIG_Z3_MSB uint8_t(0x6F) |
cdupaty | 0:ef20a9039c0c | 119 | #define BMM150_DIG_XY2 uint8_t(0x70) |
cdupaty | 0:ef20a9039c0c | 120 | #define BMM150_DIG_XY1 uint8_t(0x71) |
cdupaty | 0:ef20a9039c0c | 121 | |
cdupaty | 0:ef20a9039c0c | 122 | /**\name PRESET MODES - REPETITIONS-XY RATES */ |
cdupaty | 0:ef20a9039c0c | 123 | #define BMM150_LOWPOWER_REPXY (1) |
cdupaty | 0:ef20a9039c0c | 124 | #define BMM150_REGULAR_REPXY (4) |
cdupaty | 0:ef20a9039c0c | 125 | #define BMM150_ENHANCED_REPXY (7) |
cdupaty | 0:ef20a9039c0c | 126 | #define BMM150_HIGHACCURACY_REPXY (23) |
cdupaty | 0:ef20a9039c0c | 127 | |
cdupaty | 0:ef20a9039c0c | 128 | /**\name PRESET MODES - REPETITIONS-Z RATES */ |
cdupaty | 0:ef20a9039c0c | 129 | #define BMM150_LOWPOWER_REPZ (2) |
cdupaty | 0:ef20a9039c0c | 130 | #define BMM150_REGULAR_REPZ (14) |
cdupaty | 0:ef20a9039c0c | 131 | #define BMM150_ENHANCED_REPZ (26) |
cdupaty | 0:ef20a9039c0c | 132 | #define BMM150_HIGHACCURACY_REPZ (82) |
cdupaty | 0:ef20a9039c0c | 133 | |
cdupaty | 0:ef20a9039c0c | 134 | /**\name Macros for bit masking */ |
cdupaty | 0:ef20a9039c0c | 135 | #define BMM150_PWR_CNTRL_MSK (0x01) |
cdupaty | 0:ef20a9039c0c | 136 | |
cdupaty | 0:ef20a9039c0c | 137 | #define BMM150_CONTROL_MEASURE_MSK (0x38) |
cdupaty | 0:ef20a9039c0c | 138 | #define BMM150_CONTROL_MEASURE_POS (0x03) |
cdupaty | 0:ef20a9039c0c | 139 | |
cdupaty | 0:ef20a9039c0c | 140 | #define BMM150_POWER_CONTROL_BIT_MSK (0x01) |
cdupaty | 0:ef20a9039c0c | 141 | #define BMM150_POWER_CONTROL_BIT_POS (0x00) |
cdupaty | 0:ef20a9039c0c | 142 | |
cdupaty | 0:ef20a9039c0c | 143 | #define BMM150_OP_MODE_MSK (0x06) |
cdupaty | 0:ef20a9039c0c | 144 | #define BMM150_OP_MODE_POS (0x01) |
cdupaty | 0:ef20a9039c0c | 145 | |
cdupaty | 0:ef20a9039c0c | 146 | #define BMM150_ODR_MSK (0x38) |
cdupaty | 0:ef20a9039c0c | 147 | #define BMM150_ODR_POS (0x03) |
cdupaty | 0:ef20a9039c0c | 148 | |
cdupaty | 0:ef20a9039c0c | 149 | #define BMM150_DATA_X_MSK (0xF8) |
cdupaty | 0:ef20a9039c0c | 150 | #define BMM150_DATA_X_POS (0x03) |
cdupaty | 0:ef20a9039c0c | 151 | |
cdupaty | 0:ef20a9039c0c | 152 | #define BMM150_DATA_Y_MSK (0xF8) |
cdupaty | 0:ef20a9039c0c | 153 | #define BMM150_DATA_Y_POS (0x03) |
cdupaty | 0:ef20a9039c0c | 154 | |
cdupaty | 0:ef20a9039c0c | 155 | #define BMM150_DATA_Z_MSK (0xFE) |
cdupaty | 0:ef20a9039c0c | 156 | #define BMM150_DATA_Z_POS (0x01) |
cdupaty | 0:ef20a9039c0c | 157 | |
cdupaty | 0:ef20a9039c0c | 158 | #define BMM150_DATA_RHALL_MSK (0xFC) |
cdupaty | 0:ef20a9039c0c | 159 | #define BMM150_DATA_RHALL_POS (0x02) |
cdupaty | 0:ef20a9039c0c | 160 | |
cdupaty | 0:ef20a9039c0c | 161 | #define BMM150_SELF_TEST_MSK (0x01) |
cdupaty | 0:ef20a9039c0c | 162 | |
cdupaty | 0:ef20a9039c0c | 163 | #define BMM150_ADV_SELF_TEST_MSK (0xC0) |
cdupaty | 0:ef20a9039c0c | 164 | #define BMM150_ADV_SELF_TEST_POS (0x06) |
cdupaty | 0:ef20a9039c0c | 165 | |
cdupaty | 0:ef20a9039c0c | 166 | #define BMM150_DRDY_EN_MSK (0x80) |
cdupaty | 0:ef20a9039c0c | 167 | #define BMM150_DRDY_EN_POS (0x07) |
cdupaty | 0:ef20a9039c0c | 168 | |
cdupaty | 0:ef20a9039c0c | 169 | #define BMM150_INT_PIN_EN_MSK (0x40) |
cdupaty | 0:ef20a9039c0c | 170 | #define BMM150_INT_PIN_EN_POS (0x06) |
cdupaty | 0:ef20a9039c0c | 171 | |
cdupaty | 0:ef20a9039c0c | 172 | #define BMM150_DRDY_POLARITY_MSK (0x04) |
cdupaty | 0:ef20a9039c0c | 173 | #define BMM150_DRDY_POLARITY_POS (0x02) |
cdupaty | 0:ef20a9039c0c | 174 | |
cdupaty | 0:ef20a9039c0c | 175 | #define BMM150_INT_LATCH_MSK (0x02) |
cdupaty | 0:ef20a9039c0c | 176 | #define BMM150_INT_LATCH_POS (0x01) |
cdupaty | 0:ef20a9039c0c | 177 | |
cdupaty | 0:ef20a9039c0c | 178 | #define BMM150_INT_POLARITY_MSK (0x01) |
cdupaty | 0:ef20a9039c0c | 179 | |
cdupaty | 0:ef20a9039c0c | 180 | #define BMM150_DATA_OVERRUN_INT_MSK (0x80) |
cdupaty | 0:ef20a9039c0c | 181 | #define BMM150_DATA_OVERRUN_INT_POS (0x07) |
cdupaty | 0:ef20a9039c0c | 182 | |
cdupaty | 0:ef20a9039c0c | 183 | #define BMM150_OVERFLOW_INT_MSK (0x40) |
cdupaty | 0:ef20a9039c0c | 184 | #define BMM150_OVERFLOW_INT_POS (0x06) |
cdupaty | 0:ef20a9039c0c | 185 | |
cdupaty | 0:ef20a9039c0c | 186 | #define BMM150_HIGH_THRESHOLD_INT_MSK (0x38) |
cdupaty | 0:ef20a9039c0c | 187 | #define BMM150_HIGH_THRESHOLD_INT_POS (0x03) |
cdupaty | 0:ef20a9039c0c | 188 | |
cdupaty | 0:ef20a9039c0c | 189 | #define BMM150_LOW_THRESHOLD_INT_MSK (0x07) |
cdupaty | 0:ef20a9039c0c | 190 | |
cdupaty | 0:ef20a9039c0c | 191 | #define BMM150_DRDY_STATUS_MSK (0x01) |
cdupaty | 0:ef20a9039c0c | 192 | |
cdupaty | 0:ef20a9039c0c | 193 | /**\name OVERFLOW DEFINITIONS */ |
cdupaty | 0:ef20a9039c0c | 194 | #define BMM150_XYAXES_FLIP_OVERFLOW_ADCVAL (-4096) |
cdupaty | 0:ef20a9039c0c | 195 | #define BMM150_ZAXIS_HALL_OVERFLOW_ADCVAL (-16384) |
cdupaty | 0:ef20a9039c0c | 196 | #define BMM150_OVERFLOW_OUTPUT (-32768) |
cdupaty | 0:ef20a9039c0c | 197 | #define BMM150_NEGATIVE_SATURATION_Z (-32767) |
cdupaty | 0:ef20a9039c0c | 198 | #define BMM150_POSITIVE_SATURATION_Z (32767) |
cdupaty | 0:ef20a9039c0c | 199 | #ifdef BMM150_USE_FLOATING_POINT |
cdupaty | 0:ef20a9039c0c | 200 | #define BMM150_OVERFLOW_OUTPUT_FLOAT 0.0f |
cdupaty | 0:ef20a9039c0c | 201 | #endif |
cdupaty | 0:ef20a9039c0c | 202 | |
cdupaty | 0:ef20a9039c0c | 203 | /**\name Register read lengths */ |
cdupaty | 0:ef20a9039c0c | 204 | #define BMM150_SELF_TEST_LEN (5) |
cdupaty | 0:ef20a9039c0c | 205 | #define BMM150_SETTING_DATA_LEN (8) |
cdupaty | 0:ef20a9039c0c | 206 | #define BMM150_XYZR_DATA_LEN (8) |
cdupaty | 0:ef20a9039c0c | 207 | |
cdupaty | 0:ef20a9039c0c | 208 | /**\name Self test selection macros */ |
cdupaty | 0:ef20a9039c0c | 209 | #define BMM150_NORMAL_SELF_TEST (0) |
cdupaty | 0:ef20a9039c0c | 210 | #define BMM150_ADVANCED_SELF_TEST (1) |
cdupaty | 0:ef20a9039c0c | 211 | |
cdupaty | 0:ef20a9039c0c | 212 | /**\name Self test settings */ |
cdupaty | 0:ef20a9039c0c | 213 | #define BMM150_DISABLE_XY_AXIS (0x03) |
cdupaty | 0:ef20a9039c0c | 214 | #define BMM150_SELF_TEST_REP_Z (0x04) |
cdupaty | 0:ef20a9039c0c | 215 | |
cdupaty | 0:ef20a9039c0c | 216 | /**\name Advanced self-test current settings */ |
cdupaty | 0:ef20a9039c0c | 217 | #define BMM150_DISABLE_SELF_TEST_CURRENT (0x00) |
cdupaty | 0:ef20a9039c0c | 218 | #define BMM150_ENABLE_NEGATIVE_CURRENT (0x02) |
cdupaty | 0:ef20a9039c0c | 219 | #define BMM150_ENABLE_POSITIVE_CURRENT (0x03) |
cdupaty | 0:ef20a9039c0c | 220 | |
cdupaty | 0:ef20a9039c0c | 221 | /**\name Normal self-test status */ |
cdupaty | 0:ef20a9039c0c | 222 | #define BMM150_SELF_TEST_STATUS_XYZ_FAIL (0x00) |
cdupaty | 0:ef20a9039c0c | 223 | #define BMM150_SELF_TEST_STATUS_SUCCESS (0x07) |
cdupaty | 0:ef20a9039c0c | 224 | |
cdupaty | 0:ef20a9039c0c | 225 | /**\name Macro to SET and GET BITS of a register*/ |
cdupaty | 0:ef20a9039c0c | 226 | #define BMM150_SET_BITS(reg_data, bitname, data) \ |
cdupaty | 0:ef20a9039c0c | 227 | ((reg_data & ~(bitname##_MSK)) | \ |
cdupaty | 0:ef20a9039c0c | 228 | ((data << bitname##_POS) & bitname##_MSK)) |
cdupaty | 0:ef20a9039c0c | 229 | |
cdupaty | 0:ef20a9039c0c | 230 | #define BMM150_GET_BITS(reg_data, bitname) ((reg_data & (bitname##_MSK)) >> \ |
cdupaty | 0:ef20a9039c0c | 231 | (bitname##_POS)) |
cdupaty | 0:ef20a9039c0c | 232 | |
cdupaty | 0:ef20a9039c0c | 233 | #define BMM150_SET_BITS_POS_0(reg_data, bitname, data) \ |
cdupaty | 0:ef20a9039c0c | 234 | ((reg_data & ~(bitname##_MSK)) | \ |
cdupaty | 0:ef20a9039c0c | 235 | (data & bitname##_MSK)) |
cdupaty | 0:ef20a9039c0c | 236 | |
cdupaty | 0:ef20a9039c0c | 237 | #define BMM150_GET_BITS_POS_0(reg_data, bitname) (reg_data & (bitname##_MSK)) |
cdupaty | 0:ef20a9039c0c | 238 | |
cdupaty | 0:ef20a9039c0c | 239 | |
cdupaty | 0:ef20a9039c0c | 240 | struct bmm150_mag_data { |
cdupaty | 0:ef20a9039c0c | 241 | int x; |
cdupaty | 0:ef20a9039c0c | 242 | int y; |
cdupaty | 0:ef20a9039c0c | 243 | int z; |
cdupaty | 0:ef20a9039c0c | 244 | }; |
cdupaty | 0:ef20a9039c0c | 245 | |
cdupaty | 0:ef20a9039c0c | 246 | /* |
cdupaty | 0:ef20a9039c0c | 247 | @brief bmm150 un-compensated (raw) magnetometer data |
cdupaty | 0:ef20a9039c0c | 248 | */ |
cdupaty | 0:ef20a9039c0c | 249 | struct bmm150_raw_mag_data { |
cdupaty | 0:ef20a9039c0c | 250 | /*! Raw mag X data */ |
cdupaty | 0:ef20a9039c0c | 251 | int raw_datax; |
cdupaty | 0:ef20a9039c0c | 252 | /*! Raw mag Y data */ |
cdupaty | 0:ef20a9039c0c | 253 | int raw_datay; |
cdupaty | 0:ef20a9039c0c | 254 | /*! Raw mag Z data */ |
cdupaty | 0:ef20a9039c0c | 255 | int raw_dataz; |
cdupaty | 0:ef20a9039c0c | 256 | /*! Raw mag resistance value */ |
cdupaty | 0:ef20a9039c0c | 257 | unsigned int raw_data_r; |
cdupaty | 0:ef20a9039c0c | 258 | }; |
cdupaty | 0:ef20a9039c0c | 259 | |
cdupaty | 0:ef20a9039c0c | 260 | /*! |
cdupaty | 0:ef20a9039c0c | 261 | @brief bmm150 trim data structure |
cdupaty | 0:ef20a9039c0c | 262 | */ |
cdupaty | 0:ef20a9039c0c | 263 | struct bmm150_trim_registers { |
cdupaty | 0:ef20a9039c0c | 264 | /*! trim x1 data */ |
cdupaty | 0:ef20a9039c0c | 265 | char dig_x1; |
cdupaty | 0:ef20a9039c0c | 266 | /*! trim y1 data */ |
cdupaty | 0:ef20a9039c0c | 267 | char dig_y1; |
cdupaty | 0:ef20a9039c0c | 268 | /*! trim x2 data */ |
cdupaty | 0:ef20a9039c0c | 269 | char dig_x2; |
cdupaty | 0:ef20a9039c0c | 270 | /*! trim y2 data */ |
cdupaty | 0:ef20a9039c0c | 271 | char dig_y2; |
cdupaty | 0:ef20a9039c0c | 272 | /*! trim z1 data */ |
cdupaty | 0:ef20a9039c0c | 273 | unsigned int dig_z1; |
cdupaty | 0:ef20a9039c0c | 274 | /*! trim z2 data */ |
cdupaty | 0:ef20a9039c0c | 275 | int dig_z2; |
cdupaty | 0:ef20a9039c0c | 276 | /*! trim z3 data */ |
cdupaty | 0:ef20a9039c0c | 277 | int dig_z3; |
cdupaty | 0:ef20a9039c0c | 278 | /*! trim z4 data */ |
cdupaty | 0:ef20a9039c0c | 279 | int dig_z4; |
cdupaty | 0:ef20a9039c0c | 280 | /*! trim xy1 data */ |
cdupaty | 0:ef20a9039c0c | 281 | unsigned char dig_xy1; |
cdupaty | 0:ef20a9039c0c | 282 | /*! trim xy2 data */ |
cdupaty | 0:ef20a9039c0c | 283 | char dig_xy2; |
cdupaty | 0:ef20a9039c0c | 284 | /*! trim xyz1 data */ |
cdupaty | 0:ef20a9039c0c | 285 | unsigned int dig_xyz1; |
cdupaty | 0:ef20a9039c0c | 286 | }; |
cdupaty | 0:ef20a9039c0c | 287 | |
cdupaty | 0:ef20a9039c0c | 288 | /** |
cdupaty | 0:ef20a9039c0c | 289 | @brief bmm150 sensor settings |
cdupaty | 0:ef20a9039c0c | 290 | */ |
cdupaty | 0:ef20a9039c0c | 291 | struct bmm150_settings { |
cdupaty | 0:ef20a9039c0c | 292 | /*! Control measurement of XYZ axes */ |
cdupaty | 0:ef20a9039c0c | 293 | unsigned char xyz_axes_control; |
cdupaty | 0:ef20a9039c0c | 294 | /*! Power control bit value */ |
cdupaty | 0:ef20a9039c0c | 295 | unsigned char pwr_cntrl_bit; |
cdupaty | 0:ef20a9039c0c | 296 | /*! Power control bit value */ |
cdupaty | 0:ef20a9039c0c | 297 | unsigned char pwr_mode; |
cdupaty | 0:ef20a9039c0c | 298 | /*! Data rate value (ODR) */ |
cdupaty | 0:ef20a9039c0c | 299 | unsigned char data_rate; |
cdupaty | 0:ef20a9039c0c | 300 | /*! XY Repetitions */ |
cdupaty | 0:ef20a9039c0c | 301 | unsigned char xy_rep; |
cdupaty | 0:ef20a9039c0c | 302 | /*! Z Repetitions */ |
cdupaty | 0:ef20a9039c0c | 303 | unsigned char z_rep; |
cdupaty | 0:ef20a9039c0c | 304 | /*! Preset mode of sensor */ |
cdupaty | 0:ef20a9039c0c | 305 | unsigned char preset_mode; |
cdupaty | 0:ef20a9039c0c | 306 | /*! Interrupt configuration settings */ |
cdupaty | 0:ef20a9039c0c | 307 | // struct bmm150_int_ctrl_settings int_settings; |
cdupaty | 0:ef20a9039c0c | 308 | }; |
cdupaty | 0:ef20a9039c0c | 309 | |
cdupaty | 0:ef20a9039c0c | 310 | #endif |