24 #define LSM9DS0_DRY_X_PIN -1 25 #define LSM9DS0_DRY_G_PIN -1 27 #define LSM9DS0_G_WHOAMI 0xD4 // L3GD20 28 #define LSM9DS0_G_WHOAMI_H 0xD7 // L3GD20H 29 #define LSM9DS0_XM_WHOAMI 0x49 34 #define WHO_AM_I_G 0x0F 35 #define CTRL_REG1_G 0x20 36 # define CTRL_REG1_G_DR_95Hz_BW_12500mHz (0x0 << 4) 37 # define CTRL_REG1_G_DR_95Hz_BW_25Hz (0x1 << 4) 38 # define CTRL_REG1_G_DR_190Hz_BW_12500mHz (0x4 << 4) 39 # define CTRL_REG1_G_DR_190Hz_BW_25Hz (0x5 << 4) 40 # define CTRL_REG1_G_DR_190Hz_BW_50Hz (0x6 << 4) 41 # define CTRL_REG1_G_DR_190Hz_BW_70Hz (0x7 << 4) 42 # define CTRL_REG1_G_DR_380Hz_BW_20Hz (0x8 << 4) 43 # define CTRL_REG1_G_DR_380Hz_BW_25Hz (0x9 << 4) 44 # define CTRL_REG1_G_DR_380Hz_BW_50Hz (0xA << 4) 45 # define CTRL_REG1_G_DR_380Hz_BW_100Hz (0xB << 4) 46 # define CTRL_REG1_G_DR_760Hz_BW_30Hz (0xC << 4) 47 # define CTRL_REG1_G_DR_760Hz_BW_35Hz (0xD << 4) 48 # define CTRL_REG1_G_DR_760Hz_BW_50Hz (0xE << 4) 49 # define CTRL_REG1_G_DR_760Hz_BW_100Hz (0xF << 4) 50 # define CTRL_REG1_G_PD (0x1 << 3) 51 # define CTRL_REG1_G_ZEN (0x1 << 2) 52 # define CTRL_REG1_G_YEN (0x1 << 1) 53 # define CTRL_REG1_G_XEN (0x1 << 0) 54 #define CTRL_REG2_G 0x21 55 # define CTRL_REG2_G_HPM_NORMAL_RESET (0x0 << 4) 56 # define CTRL_REG2_G_HPM_REFERENCE (0x1 << 4) 57 # define CTRL_REG2_G_HPM_NORMAL (0x2 << 4) 58 # define CTRL_REG2_G_HPM_AUTORESET (0x3 << 4) 59 # define CTRL_REG2_G_HPCF_0 (0x0 << 0) 60 # define CTRL_REG2_G_HPCF_1 (0x1 << 0) 61 # define CTRL_REG2_G_HPCF_2 (0x2 << 0) 62 # define CTRL_REG2_G_HPCF_3 (0x3 << 0) 63 # define CTRL_REG2_G_HPCF_4 (0x4 << 0) 64 # define CTRL_REG2_G_HPCF_5 (0x5 << 0) 65 # define CTRL_REG2_G_HPCF_6 (0x6 << 0) 66 # define CTRL_REG2_G_HPCF_7 (0x7 << 0) 67 # define CTRL_REG2_G_HPCF_8 (0x8 << 0) 68 # define CTRL_REG2_G_HPCF_9 (0x9 << 0) 69 #define CTRL_REG3_G 0x22 70 # define CTRL_REG3_G_I1_INT1 (0x1 << 7) 71 # define CTRL_REG3_G_I1_BOOT (0x1 << 6) 72 # define CTRL_REG3_G_H_LACTIVE (0x1 << 5) 73 # define CTRL_REG3_G_PP_OD (0x1 << 4) 74 # define CTRL_REG3_G_I2_DRDY (0x1 << 3) 75 # define CTRL_REG3_G_I2_WTM (0x1 << 2) 76 # define CTRL_REG3_G_I2_ORUN (0x1 << 1) 77 # define CTRL_REG3_G_I2_EMPTY (0x1 << 0) 78 #define CTRL_REG4_G 0x23 79 # define CTRL_REG4_G_BDU (0x1 << 7) 80 # define CTRL_REG4_G_BLE (0x1 << 6) 81 # define CTRL_REG4_G_FS_245DPS (0x0 << 4) 82 # define CTRL_REG4_G_FS_500DPS (0x1 << 4) 83 # define CTRL_REG4_G_FS_2000DPS (0x2 << 4) 84 # define CTRL_REG4_G_ST_NORMAL (0x0 << 1) 85 # define CTRL_REG4_G_ST_0 (0x1 << 1) 86 # define CTRL_REG4_G_ST_1 (0x3 << 1) 87 # define CTRL_REG4_G_SIM_3WIRE (0x1 << 0) 88 #define CTRL_REG5_G 0x24 89 # define CTRL_REG5_G_BOOT (0x1 << 7) 90 # define CTRL_REG5_G_FIFO_EN (0x1 << 6) 91 # define CTRL_REG5_G_HPEN (0x1 << 4) 92 # define CTRL_REG5_G_INT1_SEL_00 (0x0 << 2) 93 # define CTRL_REG5_G_INT1_SEL_01 (0x1 << 2) 94 # define CTRL_REG5_G_INT1_SEL_10 (0x2 << 2) 95 # define CTRL_REG5_G_INT1_SEL_11 (0x3 << 2) 96 # define CTRL_REG5_G_OUT_SEL_00 (0x0 << 0) 97 # define CTRL_REG5_G_OUT_SEL_01 (0x1 << 0) 98 # define CTRL_REG5_G_OUT_SEL_10 (0x2 << 0) 99 # define CTRL_REG5_G_OUT_SEL_11 (0x3 << 0) 100 #define REFERENCE_G 0x25 101 #define STATUS_REG_G 0x27 102 # define STATUS_REG_G_ZYXOR (0x1 << 7) 103 # define STATUS_REG_G_ZOR (0x1 << 6) 104 # define STATUS_REG_G_YOR (0x1 << 5) 105 # define STATUS_REG_G_XOR (0x1 << 4) 106 # define STATUS_REG_G_ZYXDA (0x1 << 3) 107 # define STATUS_REG_G_ZDA (0x1 << 2) 108 # define STATUS_REG_G_YDA (0x1 << 1) 109 # define STATUS_REG_G_XDA (0x1 << 0) 110 #define OUT_X_L_G 0x28 111 #define OUT_X_H_G 0x29 112 #define OUT_Y_L_G 0x2A 113 #define OUT_Y_H_G 0x2B 114 #define OUT_Z_L_G 0x2C 115 #define OUT_Z_H_G 0x2D 116 #define FIFO_CTRL_REG_G 0x2E 117 # define FIFO_CTRL_REG_G_FM_BYPASS (0x0 << 5) 118 # define FIFO_CTRL_REG_G_FM_FIFO (0x1 << 5) 119 # define FIFO_CTRL_REG_G_FM_STREAM (0x2 << 5) 120 # define FIFO_CTRL_REG_G_FM_STREAM_TO_FIFO (0x3 << 5) 121 # define FIFO_CTRL_REG_G_FM_BYPASS_TO_STREAM (0x4 << 5) 122 # define FIFO_CTRL_REG_G_WTM_MASK 0x1F 123 #define FIFO_SRC_REG_G 0x2F 124 # define FIFO_SRC_REG_G_WTM (0x1 << 7) 125 # define FIFO_SRC_REG_G_OVRN (0x1 << 6) 126 # define FIFO_SRC_REG_G_EMPTY (0x1 << 5) 127 # define FIFO_SRC_REG_G_FSS_MASK 0x1F 128 #define INT1_CFG_G 0x30 129 # define INT1_CFG_G_AND_OR (0x1 << 7) 130 # define INT1_CFG_G_LIR (0x1 << 6) 131 # define INT1_CFG_G_ZHIE (0x1 << 5) 132 # define INT1_CFG_G_ZLIE (0x1 << 4) 133 # define INT1_CFG_G_YHIE (0x1 << 3) 134 # define INT1_CFG_G_YLIE (0x1 << 2) 135 # define INT1_CFG_G_XHIE (0x1 << 1) 136 # define INT1_CFG_G_XLIE (0x1 << 0) 137 #define INT1_SRC_G 0x31 138 # define INT1_SRC_G_IA (0x1 << 6) 139 # define INT1_SRC_G_ZH (0x1 << 5) 140 # define INT1_SRC_G_ZL (0x1 << 4) 141 # define INT1_SRC_G_YH (0x1 << 3) 142 # define INT1_SRC_G_YL (0x1 << 2) 143 # define INT1_SRC_G_XH (0x1 << 1) 144 # define INT1_SRC_G_XL (0x1 << 0) 145 #define INT1_THS_XH_G 0x32 146 #define INT1_THS_XL_G 0x33 147 #define INT1_THS_YH_G 0x34 148 #define INT1_THS_YL_G 0x35 149 #define INT1_THS_ZH_G 0x36 150 #define INT1_THS_ZL_G 0x37 151 #define INT1_DURATION_G 0x38 152 # define INT1_DURATION_G_WAIT (0x1 << 7) 153 # define INT1_DURATION_G_D_MASK 0x7F 158 #define OUT_TEMP_L_XM 0x05 159 #define OUT_TEMP_H_XM 0x06 160 #define STATUS_REG_M 0x07 161 # define STATUS_REG_M_ZYXMOR (0x1 << 7) 162 # define STATUS_REG_M_ZMOR (0x1 << 6) 163 # define STATUS_REG_M_YMOR (0x1 << 5) 164 # define STATUS_REG_M_XMOR (0x1 << 4) 165 # define STATUS_REG_M_ZYXMDA (0x1 << 3) 166 # define STATUS_REG_M_ZMDA (0x1 << 2) 167 # define STATUS_REG_M_YMDA (0x1 << 1) 168 # define STATUS_REG_M_XMDA (0x1 << 0) 169 #define OUT_X_L_M 0x08 170 #define OUT_X_H_M 0x09 171 #define OUT_Y_L_M 0x0A 172 #define OUT_Y_H_M 0x0B 173 #define OUT_Z_L_M 0x0C 174 #define OUT_Z_H_M 0x0D 175 #define WHO_AM_I_XM 0x0F 176 #define INT_CTRL_REG_M 0x12 177 # define INT_CTRL_REG_M_XMIEN (0x1 << 7) 178 # define INT_CTRL_REG_M_YMIEN (0x1 << 6) 179 # define INT_CTRL_REG_M_ZMIEN (0x1 << 5) 180 # define INT_CTRL_REG_M_PP_OD (0x1 << 4) 181 # define INT_CTRL_REG_M_IEA (0x1 << 3) 182 # define INT_CTRL_REG_M_IEL (0x1 << 2) 183 # define INT_CTRL_REG_M_4D (0x1 << 1) 184 # define INT_CTRL_REG_M_MIEN (0x1 << 0) 185 #define INT_SRC_REG_M 0x13 186 # define INT_SRC_REG_M_M_PTH_X (0x1 << 7) 187 # define INT_SRC_REG_M_M_PTH_Y (0x1 << 6) 188 # define INT_SRC_REG_M_M_PTH_Z (0x1 << 5) 189 # define INT_SRC_REG_M_M_NTH_X (0x1 << 4) 190 # define INT_SRC_REG_M_M_NTH_Y (0x1 << 3) 191 # define INT_SRC_REG_M_M_NTH_Z (0x1 << 2) 192 # define INT_SRC_REG_M_MROI (0x1 << 1) 193 # define INT_SRC_REG_M_MINT (0x1 << 0) 194 #define INT_THS_L_M 0x14 195 #define INT_THS_H_M 0x15 196 #define OFFSET_X_L_M 0x16 197 #define OFFSET_X_H_M 0x17 198 #define OFFSET_Y_L_M 0x18 199 #define OFFSET_Y_H_M 0x19 200 #define OFFSET_Z_L_M 0x1A 201 #define OFFSET_Z_H_M 0x1B 202 #define REFERENCE_X 0x1C 203 #define REFERENCE_Y 0x1D 204 #define REFERENCE_Z 0x1E 205 #define CTRL_REG0_XM 0x1F 206 # define CTRL_REG0_XM_B00T (0x1 << 7) 207 # define CTRL_REG0_XM_FIFO_EN (0x1 << 6) 208 # define CTRL_REG0_XM_WTM_EN (0x1 << 5) 209 # define CTRL_REG0_XM_HP_CLICK (0x1 << 2) 210 # define CTRL_REG0_XM_HPIS1 (0x1 << 1) 211 # define CTRL_REG0_XM_HPIS2 (0x1 << 0) 212 #define CTRL_REG1_XM 0x20 213 # define CTRL_REG1_XM_AODR_POWERDOWN (0x0 << 4) 214 # define CTRL_REG1_XM_AODR_3125mHz (0x1 << 4) 215 # define CTRL_REG1_XM_AODR_6250mHz (0x2 << 4) 216 # define CTRL_REG1_XM_AODR_12500mHz (0x3 << 4) 217 # define CTRL_REG1_XM_AODR_25Hz (0x4 << 4) 218 # define CTRL_REG1_XM_AODR_50Hz (0x5 << 4) 219 # define CTRL_REG1_XM_AODR_100Hz (0x6 << 4) 220 # define CTRL_REG1_XM_AODR_200Hz (0x7 << 4) 221 # define CTRL_REG1_XM_AODR_400Hz (0x8 << 4) 222 # define CTRL_REG1_XM_AODR_800Hz (0x9 << 4) 223 # define CTRL_REG1_XM_AODR_1600Hz (0xA << 4) 224 # define CTRL_REG1_XM_BDU (0x1 << 3) 225 # define CTRL_REG1_XM_AZEN (0x1 << 2) 226 # define CTRL_REG1_XM_AYEN (0x1 << 1) 227 # define CTRL_REG1_XM_AXEN (0x1 << 0) 228 #define CTRL_REG2_XM 0x21 229 # define CTRL_REG2_XM_ABW_773Hz (0x0 << 6) 230 # define CTRL_REG2_XM_ABW_194Hz (0x1 << 6) 231 # define CTRL_REG2_XM_ABW_362Hz (0x2 << 6) 232 # define CTRL_REG2_XM_ABW_50Hz (0x3 << 6) 233 # define CTRL_REG2_XM_AFS_2G (0x0 << 3) 234 # define CTRL_REG2_XM_AFS_4G (0x1 << 3) 235 # define CTRL_REG2_XM_AFS_6G (0x2 << 3) 236 # define CTRL_REG2_XM_AFS_8G (0x3 << 3) 237 # define CTRL_REG2_XM_AFS_16G (0x4 << 3) 238 # define CTRL_REG2_XM_AST_NORMAL (0x0 << 1) 239 # define CTRL_REG2_XM_AST_POSITIVE (0x1 << 1) 240 # define CTRL_REG2_XM_AST_NEGATIVE (0x2 << 1) 241 # define CTRL_REG2_XM_SIM_3WIRE (0x1 << 0) 242 #define CTRL_REG3_XM 0x22 243 # define CTRL_REG3_XM_P1_BOOT (0x1 << 7) 244 # define CTRL_REG3_XM_P1_TAP (0x1 << 6) 245 # define CTRL_REG3_XM_P1_INT1 (0x1 << 5) 246 # define CTRL_REG3_XM_P1_INT2 (0x1 << 4) 247 # define CTRL_REG3_XM_P1_INTM (0x1 << 3) 248 # define CTRL_REG3_XM_P1_DRDYA (0x1 << 2) 249 # define CTRL_REG3_XM_P1_DRDYM (0x1 << 1) 250 # define CTRL_REG3_XM_P1_EMPTY (0x1 << 0) 251 #define CTRL_REG4_XM 0x23 252 # define CTRL_REG4_XM_P2_TAP (0x1 << 7) 253 # define CTRL_REG4_XM_P2_INT1 (0x1 << 6) 254 # define CTRL_REG4_XM_P2_INT2 (0x1 << 5) 255 # define CTRL_REG4_XM_P2_INTM (0x1 << 4) 256 # define CTRL_REG4_XM_P2_DRDYA (0x1 << 3) 257 # define CTRL_REG4_XM_P2_DRDYM (0x1 << 2) 258 # define CTRL_REG4_XM_P2_OVERRUN (0x1 << 1) 259 # define CTRL_REG4_XM_P2_WTM (0x1 << 0) 260 #define CTRL_REG5_XM 0x24 261 # define CTRL_REG5_XM_TEMP_EN (0x1 << 7) 262 # define CTRL_REG5_XM_M_RES_LOW (0x0 << 5) 263 # define CTRL_REG5_XM_M_RES_HIGH (0x3 << 5) 264 # define CTRL_REG5_XM_ODR_3125mHz (0x0 << 2) 265 # define CTRL_REG5_XM_ODR_6250mHz (0x1 << 2) 266 # define CTRL_REG5_XM_ODR_12500mHz (0x2 << 2) 267 # define CTRL_REG5_XM_ODR_25Hz (0x3 << 2) 268 # define CTRL_REG5_XM_ODR_50Hz (0x4 << 2) 269 # define CTRL_REG5_XM_ODR_100Hz (0x5 << 2) 270 # define CTRL_REG5_XM_LIR2 (0x1 << 1) 271 # define CTRL_REG5_XM_LIR1 (0x1 << 0) 272 #define CTRL_REG6_XM 0x25 273 # define CTRL_REG6_XM_MFS_2Gs (0x0 << 5) 274 # define CTRL_REG6_XM_MFS_4Gs (0x1 << 5) 275 # define CTRL_REG6_XM_MFS_8Gs (0x2 << 5) 276 # define CTRL_REG6_XM_MFS_12Gs (0x3 << 5) 277 #define CTRL_REG7_XM 0x26 278 # define CTRL_REG7_XM_AHPM_NORMAL_RESET (0x0 << 6) 279 # define CTRL_REG7_XM_AHPM_REFERENCE (0x1 << 6) 280 # define CTRL_REG7_XM_AHPM_NORMAL (0x2 << 6) 281 # define CTRL_REG7_XM_AHPM_AUTORESET (0x3 << 6) 282 # define CTRL_REG7_XM_AFDS (0x1 << 5) 283 # define CTRL_REG7_XM_MLP (0x1 << 2) 284 # define CTRL_REG7_XM_MD_CONTINUOUS (0x0 << 0) 285 # define CTRL_REG7_XM_MD_SINGLE (0x1 << 0) 286 # define CTRL_REG7_XM_MD_POWERDOWN (0x2 << 0) 287 #define STATUS_REG_A 0x27 288 # define STATUS_REG_A_ZYXAOR (0x1 << 7) 289 # define STATUS_REG_A_ZAOR (0x1 << 6) 290 # define STATUS_REG_A_YAOR (0x1 << 5) 291 # define STATUS_REG_A_XAOR (0x1 << 4) 292 # define STATUS_REG_A_ZYXADA (0x1 << 3) 293 # define STATUS_REG_A_ZADA (0x1 << 2) 294 # define STATUS_REG_A_YADA (0x1 << 1) 295 # define STATUS_REG_A_XADA (0x1 << 0) 296 #define OUT_X_L_A 0x28 297 #define OUT_X_H_A 0x29 298 #define OUT_Y_L_A 0x2A 299 #define OUT_Y_H_A 0x2B 300 #define OUT_Z_L_A 0x2C 301 #define OUT_Z_H_A 0x2D 302 #define FIFO_CTRL_REG 0x2E 303 # define FIFO_CTRL_REG_FM_BYPASS (0x0 << 5) 304 # define FIFO_CTRL_REG_FM_FIFO (0x1 << 5) 305 # define FIFO_CTRL_REG_FM_STREAM (0x2 << 5) 306 # define FIFO_CTRL_REG_FM_STREAM_TO_FIFO (0x3 << 5) 307 # define FIFO_CTRL_REG_FM_BYPASS_TO_STREAM (0x4 << 5) 308 # define FIFO_CTRL_REG_FTH_MASK 0x1F 309 #define FIFO_SRC_REG 0x2F 310 # define FIFO_SRC_REG_WTM (0x1 << 7) 311 # define FIFO_SRC_REG_OVRN (0x1 << 6) 312 # define FIFO_SRC_REG_EMPTY (0x1 << 5) 313 # define FIFO_SRC_REG_FSS_MASK 0x1F 314 #define INT_GEN_1_REG 0x30 315 # define INT_GEN_1_REG_AOI (0x1 << 7) 316 # define INT_GEN_1_REG_6D (0x1 << 6) 317 # define INT_GEN_1_REG_ZHIE_ZUPE (0x1 << 5) 318 # define INT_GEN_1_REG_ZLIE_ZDOWNE (0x1 << 4) 319 # define INT_GEN_1_REG_YHIE_YUPE (0x1 << 3) 320 # define INT_GEN_1_REG_YLIE_YDOWNE (0x1 << 2) 321 # define INT_GEN_1_REG_XHIE_XUPE (0x1 << 1) 322 # define INT_GEN_1_REG_XLIE_XDOWNE (0x1 << 0) 323 #define INT_GEN_1_SRC 0x31 324 # define INT_GEN_1_SRC_IA (0x1 << 6) 325 # define INT_GEN_1_SRC_ZH (0x1 << 5) 326 # define INT_GEN_1_SRC_ZL (0x1 << 4) 327 # define INT_GEN_1_SRC_YH (0x1 << 3) 328 # define INT_GEN_1_SRC_YL (0x1 << 2) 329 # define INT_GEN_1_SRC_XH (0x1 << 1) 330 # define INT_GEN_1_SRC_XL (0x1 << 0) 331 #define INT_GEN_1_THS 0x32 332 #define INT_GEN_1_DURATION 0x33 333 #define INT_GEN_2_REG 0x34 334 # define INT_GEN_2_REG_AOI (0x1 << 7) 335 # define INT_GEN_2_REG_6D (0x1 << 6) 336 # define INT_GEN_2_REG_ZHIE_ZUPE (0x1 << 5) 337 # define INT_GEN_2_REG_ZLIE_ZDOWNE (0x1 << 4) 338 # define INT_GEN_2_REG_YHIE_YUPE (0x1 << 3) 339 # define INT_GEN_2_REG_YLIE_YDOWNE (0x1 << 2) 340 # define INT_GEN_2_REG_XHIE_XUPE (0x1 << 1) 341 # define INT_GEN_2_REG_XLIE_XDOWNE (0x1 << 0) 342 #define INT_GEN_2_SRC 0x35 343 # define INT_GEN_2_SRC_IA (0x1 << 6) 344 # define INT_GEN_2_SRC_ZH (0x1 << 5) 345 # define INT_GEN_2_SRC_ZL (0x1 << 4) 346 # define INT_GEN_2_SRC_YH (0x1 << 3) 347 # define INT_GEN_2_SRC_YL (0x1 << 2) 348 # define INT_GEN_2_SRC_XH (0x1 << 1) 349 # define INT_GEN_2_SRC_XL (0x1 << 0) 350 #define INT_GEN_2_THS 0x36 351 #define INT_GEN_2_DURATION 0x37 352 #define CLICK_CFG 0x38 353 # define CLICK_CFG_ZD (0x1 << 5) 354 # define CLICK_CFG_ZS (0x1 << 4) 355 # define CLICK_CFG_YD (0x1 << 3) 356 # define CLICK_CFG_YS (0x1 << 2) 357 # define CLICK_CFG_XD (0x1 << 1) 358 # define CLICK_CFG_XS (0x1 << 0) 359 #define CLICK_SRC 0x39 360 # define CLICK_SRC_IA (0x1 << 6) 361 # define CLICK_SRC_DCLICK (0x1 << 5) 362 # define CLICK_SRC_SCLICK (0x1 << 4) 363 # define CLICK_SRC_SIGN (0x1 << 3) 364 # define CLICK_SRC_Z (0x1 << 2) 365 # define CLICK_SRC_Y (0x1 << 1) 366 # define CLICK_SRC_X (0x1 << 0) 367 #define CLICK_THS 0x3A 368 #define TIME_LIMIT 0x3B 369 #define TIME_LATENCY 0x3C 370 #define TIME_WINDOW 0x3D 383 , _dev_gyro(
std::move(dev_gyro))
384 , _dev_accel(
std::move(dev_accel))
385 , _drdy_pin_num_a(drdy_pin_num_a)
386 , _drdy_pin_num_g(drdy_pin_num_g)
387 , _rotation_a(rotation_a)
388 , _rotation_g(rotation_g)
389 , _rotation_gH(rotation_gH)
400 if (!dev_gyro || !dev_accel) {
406 rotation_a, rotation_g, rotation_gH);
426 AP_HAL::panic(
"LSM9DS0: null accel data-ready GPIO channel\n");
435 AP_HAL::panic(
"LSM9DS0: null gyro data-ready GPIO channel\n");
456 uint8_t tries, whoami;
470 hal.
console->
printf(
"LSM9DS0: unexpected acc/mag WHOAMI 0x%x\n", (
unsigned)whoami);
478 for (tries = 0; tries < 5; tries++) {
565 uint8_t retries = 10;
732 hal.
console->
printf(
"LSM9DS0: error reading accelerometer\n");
736 Vector3f accel_data(raw_data.x, -raw_data.y, -raw_data.z);
756 Vector3f gyro_data(raw_data.x, -raw_data.y, -raw_data.z);
774 void AP_InertialSensor_LSM9DS0::_dump_registers(
void)
780 for (uint8_t reg=first; reg<=last; reg++) {
782 hal.
console->
printf(
"%02x:%02x ", (
unsigned)reg, (
unsigned)v);
783 if ((reg - (first-1)) % 16 == 0) {
789 hal.
console->
printf(
"Accelerometer and Magnetometers registers:\n");
790 for (uint8_t reg=first; reg<=last; reg++) {
792 hal.
console->
printf(
"%02x:%02x ", (
unsigned)reg, (
unsigned)v);
793 if ((reg - (first-1)) % 16 == 0) {
void _accel_disable_i2c()
void set_gyro_orientation(uint8_t instance, enum Rotation rotation)
#define CTRL_REG1_XM_AODR_1600Hz
void _inc_accel_error_count(uint8_t instance)
AP_HAL::UARTDriver * console
#define CTRL_REG4_G_FS_2000DPS
#define CTRL_REG2_XM_ABW_194Hz
virtual Device::PeriodicHandle register_periodic_callback(uint32_t period_usec, Device::PeriodicCb) override=0
uint8_t register_gyro(uint16_t raw_sample_rate_hz, uint32_t id)
#define CTRL_REG2_XM_AFS_16G
#define HAL_SEMAPHORE_BLOCK_FOREVER
virtual bool take(uint32_t timeout_ms) WARN_IF_UNUSED=0
AP_HAL::OwnPtr< AP_HAL::SPIDevice > _dev_accel
void _set_accel_scale(accel_scale scale)
void start(void) override
#define LSM9DS0_XM_WHOAMI
#define LSM9DS0_DRY_G_PIN
static AP_InertialSensor_Backend * probe(AP_InertialSensor &imu, AP_HAL::OwnPtr< AP_HAL::SPIDevice > dev_gyro, AP_HAL::OwnPtr< AP_HAL::SPIDevice > dev_accel, enum Rotation rotation_a=ROTATION_NONE, enum Rotation rotation_g=ROTATION_NONE, enum Rotation rotation_gH=ROTATION_NONE)
const AP_HAL::HAL & hal
-*- tab-width: 4; Mode: C++; c-basic-offset: 4; indent-tabs-mode: nil -*-
uint32_t get_bus_id_devtype(uint8_t devtype)
void _read_data_transaction_g()
bool setup_checked_registers(uint8_t num_regs, uint8_t frequency=10)
virtual void mode(uint8_t output)=0
#define STATUS_REG_A_ZYXADA
AP_HAL::OwnPtr< AP_HAL::SPIDevice > _dev_gyro
virtual void delay(uint16_t ms)=0
#define LSM9DS0_DRY_X_PIN
virtual void printf(const char *,...) FMT_PRINTF(2
uint8_t register_accel(uint16_t raw_sample_rate_hz, uint32_t id)
void _set_accel_max_abs_offset(uint8_t instance, float offset)
AP_InertialSensor_LSM9DS0(AP_InertialSensor &imu, AP_HAL::OwnPtr< AP_HAL::SPIDevice > dev_gyro, AP_HAL::OwnPtr< AP_HAL::SPIDevice > dev_accel, int drdy_pin_num_a, int drdy_pin_num_b, enum Rotation rotation_a, enum Rotation rotation_g, enum Rotation rotation_gH)
enum Rotation _rotation_a
virtual Semaphore * get_semaphore() override=0
#define CTRL_REG3_XM_P1_DRDYA
uint8_t _register_read_g(uint8_t reg)
AP_HAL::Semaphore * _spi_sem
void _set_gyro_scale(gyro_scale scale)
virtual AP_HAL::DigitalSource * channel(uint16_t n)=0
void _notify_new_gyro_raw_sample(uint8_t instance, const Vector3f &accel, uint64_t sample_us=0)
#define STATUS_REG_G_ZYXDA
void _rotate_and_correct_gyro(uint8_t instance, Vector3f &gyro)
#define CTRL_REG3_G_I2_DRDY
#define CTRL_REG1_G_DR_760Hz_BW_50Hz
void _read_data_transaction_a()
#define CTRL_REG1_XM_AZEN
void _notify_new_accel_raw_sample(uint8_t instance, const Vector3f &accel, uint64_t sample_us=0, bool fsync_set=false)
virtual bool set_speed(Device::Speed speed) override=0
virtual bool transfer(const uint8_t *send, uint32_t send_len, uint8_t *recv, uint32_t recv_len) override=0
AP_HAL::DigitalSource * _drdy_pin_a
void set_read_flag(uint8_t flag)
void set_accel_orientation(uint8_t instance, enum Rotation rotation)
AP_HAL::DigitalSource * _drdy_pin_g
void update_gyro(uint8_t instance)
uint8_t _register_read_xm(uint8_t reg)
bool check_next_register(void)
bool read_registers(uint8_t first_reg, uint8_t *recv, uint32_t recv_len)
#define FUNCTOR_BIND_MEMBER(func, rettype,...)
void panic(const char *errormsg,...) FMT_PRINTF(1
void _inc_gyro_error_count(uint8_t instance)
enum Rotation _rotation_gH
bool write_register(uint8_t reg, uint8_t val, bool checked=false)
#define CTRL_REG1_XM_AYEN
void _rotate_and_correct_accel(uint8_t instance, Vector3f &accel)
void update_accel(uint8_t instance)
#define LSM9DS0_G_WHOAMI_H
AP_HAL::Scheduler * scheduler
#define CTRL_REG1_XM_AXEN
void _register_write_g(uint8_t reg, uint8_t val, bool checked=false)
enum Rotation _rotation_g
void _register_write_xm(uint8_t reg, uint8_t val, bool checked=false)