1 /* sensor_lsm6ds0.h - header file for LSM6DS0 accelerometer, gyroscope and 2 * temperature sensor driver 3 */ 4 5 /* 6 * Copyright (c) 2016 Intel Corporation 7 * 8 * SPDX-License-Identifier: Apache-2.0 9 */ 10 11 #ifndef ZEPHYR_DRIVERS_SENSOR_LSM6DS0_LSM6DS0_H_ 12 #define ZEPHYR_DRIVERS_SENSOR_LSM6DS0_LSM6DS0_H_ 13 14 #include <zephyr/types.h> 15 #include <zephyr/drivers/i2c.h> 16 #include <zephyr/sys/util.h> 17 18 #define LSM6DS0_REG_ACT_THS 0x04 19 #define LSM6DS0_MASK_ACT_THS_SLEEP_ON_INACT_EN BIT(7) 20 #define LSM6DS0_SHIFT_ACT_THS_SLEEP_ON_INACT_EN 7 21 #define LSM6DS0_MASK_ACT_THS_ACT_THS (BIT(6) | BIT(5) | BIT(4) | \ 22 BIT(3) | BIT(2) | BIT(1) | \ 23 BIT(0)) 24 #define LSM6DS0_SHIFT_ACT_THS_ACT_THS 0 25 26 #define LSM6DS0_REG_ACT_DUR 0x05 27 28 #define LSM6DS0_REG_INT_GEN_CFG_XL 0x06 29 #define LSM6DS0_MASK_INT_GEN_CFG_XL_AOI_XL BIT(7) 30 #define LSM6DS0_SHIFT_INT_GEN_CFG_XL_AOI_XL 7 31 #define LSM6DSO_MASK_INT_GEN_CFG_XL_6D BIT(6) 32 #define LSM6DS0_SHIFT_INT_GEN_CFG_XL_6D 6 33 #define LSM6DS0_MASK_INT_GEN_CFG_XL_ZHIE_XL BIT(5) 34 #define LSM6DS0_SHIFT_INT_GEN_CFG_XL_ZHIE_XL 5 35 #define LSM6DS0_MASK_INT_GEN_CFG_XL_ZLIE_XL BIT(4) 36 #define LSM6DS0_SHIFT_INT_GEN_CFG_XL_ZLIE_XL 4 37 #define LSM6DS0_MASK_INT_GEN_CFG_XL_YHIE_XL BIT(3) 38 #define LSM6DS0_SHIFT_INT_GEN_CFG_XL_YHIE_XL 3 39 #define LSM6DS0_MASK_INT_GEN_CFG_XL_YLIE_XL BIT(2) 40 #define LSM6DS0_SHIFT_INT_GEN_CFG_XL_YLIE_XL 2 41 #define LSM6DS0_MASK_INT_GEN_CFG_XL_XHIE_XL BIT(1) 42 #define LSM6DS0_SHIFT_INT_GEN_CFG_XL_XHIE_XL 1 43 #define LSM6DS0_MASK_INT_GEN_CFG_XL_XLIE_XL BIT(0) 44 #define LSM6DS0_SHIFT_INT_GEN_CFG_XL_XLIE_XL 0 45 46 #define LSM6DS0_REG_INT_GEN_THS_X_XL 0x07 47 #define LSM6DS0_REG_INT_GEN_THS_Y_XL 0x08 48 #define LSM6DS0_REG_INT_GEN_THS_Z_XL 0x09 49 #define LSM6DS0_REG_INT_GEN_DUR_XL 0x0A 50 #define LSM6DS0_REG_REFERENCE_G 0x0B 51 52 #define LSM6DS0_REG_INT_CTRL 0x0C 53 #define LSM6DS0_MASK_INT_CTRL_INT_IG_G BIT(7) 54 #define LSM6DS0_SHIFT_INT_CTRL_INT_IG_G 7 55 #define LSM6DS0_MASK_INT_CTRL_INT_IG_XL BIT(6) 56 #define LSM6DS0_SHIFT_INT_CTRL_INT_IG_XL 6 57 #define LSM6DS0_MASK_INT_CTRL_INT_FSS5 BIT(5) 58 #define LSM6DS0_SHIFT_INT_CTRL_INT_FSS5 5 59 #define LSM6DS0_MASK_INT_CTRL_INT_OVR BIT(4) 60 #define LSM6DS0_SHIFT_INT_CTRL_INT_OVR 4 61 #define LSM6DS0_MASK_INT_CTRL_INT_FTH BIT(3) 62 #define LSM6DS0_SHIFT_INT_CTRL_INT_FTH 3 63 #define LSM6DS0_MASK_INT_CTRL_INT_BOOT BIT(2) 64 #define LSM6DS0_SHIFT_INT_CTRL_INT_BOOT 2 65 #define LSM6DS0_MASK_INT_CTRL_INT_DRDY_G BIT(1) 66 #define LSM6DS0_SHIFT_INT_CTRL_INT_DRDY_G 1 67 #define LSM6DS0_MASK_INT_CTRL_INT_DRDY_XL BIT(0) 68 #define LSM6DS0_SHIFT_INT_CTRL_INT_DRDY_XL 0 69 70 #define LSM6DS0_REG_WHO_AM_I 0x0F 71 #define LSM6DS0_VAL_WHO_AM_I 0x68 72 73 #define LSM6DS0_REG_CTRL_REG1_G 0x10 74 #define LSM6DS0_MASK_CTRL_REG1_G_ODR_G (BIT(7) | BIT(6) | BIT(5)) 75 #define LSM6DS0_SHIFT_CTRL_REG1_G_ODR_G 5 76 #define LSM6DS0_MASK_CTRL_REG1_G_FS_G (BIT(4) | BIT(3)) 77 #define LSM6DS0_SHIFT_CTRL_REG1_G_FS_G 3 78 #define LSM6DS0_MASK_CTRL_REG1_G_BW_G (BIT(1) | BIT(0)) 79 #define LSM6DS0_SHIFT_CTRL_REG1_G_BW_G 0 80 81 #define LSM6DS0_REG_CTRL_REG2_G 0x11 82 #define LSM6DS0_MASK_CTRL_REG2_G_INT_SEL (BIT(3) | BIT(2)) 83 #define LSM6DS0_SHIFT_CTRL_REG2_G_INT_SEL 2 84 #define LSM6DS0_MASK_CTRL_REG2_G_OUT_SEL (BIT(1) | BIT(0)) 85 #define LSM6DS0_SHIFT_CTRL_REG2_G_OUT_SEL 0 86 87 #define LSM6DS0_REG_CTRL_REG3_G 0x12 88 #define LSM6DS0_MASK_CTRL_REG3_G_LP_MODE BIT(7) 89 #define LSM6DS0_SHIFT_CTRL_REG3_G_LP_MODE 7 90 #define LSM6DS0_MASK_CTRL_REG3_G_HP_EN BIT(6) 91 #define LSM6DS0_SHIFT_CTRL_REG3_G_HP_EN 6 92 #define LSM6DS0_MASK_CTRL_REG3_G_HPCF_G (BIT(3) | BIT(2) | BIT(1) | \ 93 BIT(0)) 94 #define LSM6DS0_SHIFT_CTRL_REG3_G_HPCF_G 0 95 96 #define LSM6DS0_REG_ORIENT_CFG_G 0x13 97 #define LSM6DS0_MASK_ORIENT_CFG_G_SIGNX_G BIT(5) 98 #define LSM6DS0_SHIFT_ORIENT_CFG_G_SIGNX_G 5 99 #define LSM6DS0_MASK_ORIENT_CFG_G_SIGNY_G BIT(4) 100 #define LSM6DS0_SHIFT_ORIENT_CFG_G_SIGNY_G 4 101 #define LSM6DS0_MASK_ORIENT_CFG_G_SIGNZ_G BIT(3) 102 #define LSM6DS0_SHIFT_ORIENT_CFG_G_SIGNZ_G 3 103 #define LSM6DS0_MASK_ORIENT_CFG_ORIENT (BIT(2) | BIT(1) | BIT(0)) 104 #define LSM6DS0_SHIFT_ORIENT_CFG_ORIENT 0 105 106 #define LSM6DS0_REG_INT_GEN_SRC_G 0x14 107 #define LSM6DS0_MASK_INT_GEN_SRC_G_IA_G BIT(6) 108 #define LSM6DS0_SHIFT_INT_GEN_SRC_G_IA_G 6 109 #define LSM6DS0_MASK_INT_GEN_SRC_G_ZH_G BIT(5) 110 #define LSM6DS0_SHIFT_INT_GEN_SRC_G_ZH_G 5 111 #define LSM6DS0_MASK_INT_GEN_SRC_G_ZL_G BIT(4) 112 #define LSM6DS0_SHIFT_INT_GEN_SRC_G_ZL_G 4 113 #define LSM6DS0_MASK_INT_GEN_SRC_G_YH_G BIT(3) 114 #define LSM6DS0_SHIFT_INT_GEN_SRC_G_YH_G 3 115 #define LSM6DS0_MASK_INT_GEN_SRC_G_YL_G BIT(2) 116 #define LSM6DS0_SHIFT_INT_GEN_SRC_G_YL_G 2 117 #define LSM6DS0_MASK_INT_GEN_SRC_G_XH_G BIT(1) 118 #define LSM6DS0_SHIFT_INT_GEN_SRC_G_XH_G 1 119 #define LSM6DS0_MASK_INT_GEN_SRC_G_XL_G BIT(0) 120 #define LSM6DS0_SHIFT_INT_GEN_SRC_G_XL_G 0 121 122 #define LSM6DS0_REG_OUT_TEMP_L 0x15 123 #define LSM6DS0_REG_OUT_TEMP_H 0x16 124 125 #define LSM6DS0_REG_STATUS_REG_G 0x17 126 #define LSM6DS0_MASK_STATUS_REG_G_IG_XL BIT(6) 127 #define LSM6DS0_SHIFT_STATUS_REG_G_IG_XL 6 128 #define LSM6DS0_MASK_STATUS_REG_G_IG_G BIT(5) 129 #define LSM6DS0_SHIFT_STATUS_REG_G_IG_G 5 130 #define LSM6DS0_MASK_STATUS_REG_G_INACT BIT(4) 131 #define LSM6DS0_SHIFT_STATUS_REG_G_INACT 4 132 #define LSM6DS0_MASK_STATUS_REG_G_BOOT_STATUS BIT(3) 133 #define LSM6DS0_SHIFT_STATUS_REG_G_BOOT_STATUS 3 134 #define LSM6DS0_MASK_STATUS_REG_G_TDA BIT(2) 135 #define LSM6DS0_SHIFT_STATUS_REG_G_TDA 2 136 #define LSM6DS0_MASK_STATUS_REG_G_GDA BIT(1) 137 #define LSM6DS0_SHIFT_STATUS_REG_G_GDA 1 138 #define LSM6DS0_MASK_STATUS_REG_G_XLDA BIT(0) 139 #define LSM6DS0_SHIFT_STATUS_REG_G_XLDA 0 140 141 #define LSM6DS0_REG_OUT_X_L_G 0x18 142 #define LSM6DS0_REG_OUT_X_H_G 0x19 143 #define LSM6DS0_REG_OUT_Y_L_G 0x1A 144 #define LSM6DS0_REG_OUT_Y_H_G 0x1B 145 #define LSM6DS0_REG_OUT_Z_L_G 0x1C 146 #define LSM6DS0_REG_OUT_Z_H_G 0x1D 147 148 #define LSM6DS0_REG_CTRL_REG4 0x1E 149 #define LSM6DS0_MASK_CTRL_REG4_ZEN_G BIT(5) 150 #define LSM6DS0_SHIFT_CTRL_REG4_ZEN_G 5 151 #define LSM6DS0_MASK_CTRL_REG4_YEN_G BIT(4) 152 #define LSM6DS0_SHIFT_CTRL_REG4_YEN_G 4 153 #define LSM6DS0_MASK_CTRL_REG4_XEN_G BIT(3) 154 #define LSM6DS0_SHIFT_CTRL_REG4_XEN_G 3 155 #define LSM6DS0_MASK_CTRL_REG4_LIR_XL1 BIT(1) 156 #define LSM6DS0_SHIFT_CTRL_REG4_LIR_XL1 1 157 #define LSM6DS0_MASK_CTRL_REG4_4D_XL1 BIT(0) 158 #define LSM6DS0_SHIFT_CTRL_REG4_4D_XL1 0 159 160 #define LSM6DS0_REG_CTRL_REG5_XL 0x1F 161 #define LSM6DS0_MASK_CTRL_REG5_XL_DEC (BIT(7) | BIT(6)) 162 #define LSM6DS0_SHIFT_CTRL_REG5_XL_DEC 6 163 #define LSM6DS0_MASK_CTRL_REG5_XL_ZEN_XL BIT(5) 164 #define LSM6DS0_SHIFT_CTRL_REG5_XL_ZEN_XL 5 165 #define LSM6DS0_MASK_CTRL_REG5_XL_YEN_XL BIT(4) 166 #define LSM6DS0_SHIFT_CTRL_REG5_XL_YEN_XL 4 167 #define LSM6DS0_MASK_CTRL_REG5_XL_XEN_XL BIT(3) 168 #define LSM6DS0_SHIFT_CTRL_REG5_XL_XEN_XL 3 169 170 #define LSM6DS0_REG_CTRL_REG6_XL 0x20 171 #define LSM6DS0_MASK_CTRL_REG6_XL_ODR_XL (BIT(7) | BIT(6) | BIT(5)) 172 #define LSM6DS0_SHIFT_CTRL_REG6_XL_ODR_XL 5 173 #define LSM6DS0_MASK_CTRL_REG6_XL_FS_XL (BIT(4) | BIT(3)) 174 #define LSM6DS0_SHIFT_CTRL_REG6_XL_FS_XL 3 175 #define LSM6DS0_MASK_CTRL_REG6_XL_BW_SCAL_ODR BIT(2) 176 #define LSM6DS0_SHIFT_CTRL_REG6_XL_BW_SCAL_ODR 2 177 #define LSM6DS0_MASK_CTRL_REG6_XL_BW_XL (BIT(1) | BIT(0)) 178 #define LSM6DS0_SHIFT_CTRL_REG6_XL_BW_XL 0 179 180 #define LSM6DS0_REG_CTRL_REG7_XL 0x21 181 #define LSM6DS0_MASK_CTRL_REG7_XL_HR BIT(7) 182 #define LSM6DS0_SHIFT_CTRL_REG7_XL_HR 7 183 #define LSM6DS0_MASK_CTRL_REG7_XL_DCF (BIT(6) | BIT(5)) 184 #define LSM6DS0_SHIFT_CTRL_REG7_XL_DCF 5 185 #define LSM6DS0_MASK_CTRL_REG7_XL_FDS BIT(2) 186 #define LSM6DS0_SHIFT_CTRL_REG7_XL_FDS 2 187 #define LSM6DS0_MASK_CTRL_REG7_XL_HPIS1 BIT(0) 188 #define LSM6DS0_SHIFT_CTRL_REG7_XL_HPIS 0 189 190 #define LSM6DS0_REG_CTRL_REG8 0x22 191 #define LSM6DS0_MASK_CTRL_REG8_BOOT BIT(7) 192 #define LSM6DS0_SHIFT_CTRL_REG8_BOOT 7 193 #define LSM6DS0_MASK_CTRL_REG8_BDU BIT(6) 194 #define LSM6DS0_SHIFT_CTRL_REG8_BDU 6 195 #define LSM6DS0_MASK_CTRL_REG8_H_LACTIVE BIT(5) 196 #define LSM6DS0_SHIFT_CTRL_REG8_H_LACTIVE 5 197 #define LSM6DS0_MASK_CTRL_REG8_PP_OD BIT(4) 198 #define LSM6DS0_SHIFT_CTRL_REG8_PP_OD 4 199 #define LSM6DS0_MASK_CTRL_REG8_SIM BIT(3) 200 #define LSM6DS0_SHIFT_CTRL_REG8_SIM 3 201 #define LSM6DS0_MASK_CTRL_REG8_IF_ADD_INC BIT(2) 202 #define LSM6DS0_SHIFT_CTRL_REG8_IF_ADD_INC 2 203 #define LSM6DS0_MASK_CTRL_REG8_BLE BIT(1) 204 #define LSM6DS0_SHIFT_CTRL_REG8_BLE 1 205 #define LSM6DS0_MASK_CTRL_REG8_SW_RESET BIT(0) 206 #define LSM6DS0_SHIFT_CTRL_REG8_SW_RESET 0 207 208 #define LSM6DS0_REG_CTRL_REG9 0x23 209 #define LSM6DS0_MASK_CTRL_REG9_SLEEP_G BIT(6) 210 #define LSM6DS0_SHIFT_CTRL_REG9_SLEEP_G 6 211 #define LSM6DS0_MASK_CTRL_REG9_FIFO_TEMP_EN BIT(4) 212 #define LSM6DS0_SHIFT_CTRL_REG9_FIFO_TEMP_EN 4 213 #define LSM6DS0_MASK_CTRL_REG9_DRDY_MASK_BIT BIT(3) 214 #define LSM6DS0_SHIFT_CTRL_REG9_DRDY_MASK_BIT 3 215 #define LSM6DS0_MASK_CTRL_REG9_DRDY_I2C_DIS BIT(2) 216 #define LSM6DS0_SHIFT_CTRL_REG9_DRDY_I2C_DIS 2 217 #define LSM6DS0_MASK_CTRL_REG9_FIFO_EN BIT(1) 218 #define LSM6DS0_SHIFT_CTRL_REG9_FIFO_EN 1 219 #define LSM6DS0_MASK_CTRL_REG9_STOP_ON_FTH BIT(0) 220 #define LSM6DS0_SHIFT_CTRL_REG9_STOP_ON_FTH 0 221 222 #define LSM6DS0_REG_CTRL_REG10 0x24 223 #define LSM6DS0_MASK_CTRL_REG10_ST_G BIT(2) 224 #define LSM6DS0_SHIFT_CTRL_REG10_ST_G 2 225 #define LSM6DS0_MASK_CTRL_REG10_ST_XL BIT(0) 226 #define LSM6DS0_SHIFT_CTRL_REG10_ST_XL 0 227 228 #define LSM6DS0_REG_INT_GEN_SRC_XL 0x26 229 #define LSM6DS0_MASK_INT_GEN_SRC_XL_IA_XL BIT(6) 230 #define LSM6DS0_SHIFT_INT_GEN_SRC_XL_IA_XL 6 231 #define LSM6DS0_MASK_INT_GEN_SRC_XL_ZH_XL BIT(5) 232 #define LSM6DS0_SHIFT_INT_GEN_SRC_XL_ZH_XL 5 233 #define LSM6DS0_MASK_INT_GEN_SRC_XL_ZL_XL BIT(4) 234 #define LSM6DS0_SHIFT_INT_GEN_SRC_XL_ZL_XL 4 235 #define LSM6DS0_MASK_INT_GEN_SRC_XL_YH_XL BIT(3) 236 #define LSM6DS0_SHIFT_INT_GEN_SRC_XL_YH_XL 3 237 #define LSM6DS0_MASK_INT_GEN_SRC_XL_YL_XL BIT(2) 238 #define LSM6DS0_SHIFT_INT_GEN_SRC_XL_YL_XL 2 239 #define LSM6DS0_MASK_INT_GEN_SRC_XL_XH_XL BIT(1) 240 #define LSM6DS0_SHIFT_INT_GEN_SRC_XL_XH_XL 1 241 #define LSM6DS0_MASK_INT_GEN_SRC_XL_XL_XL BIT(0) 242 #define LSM6DS0_SHIFT_INT_GEN_SRC_XL_XL_XL 0 243 244 #define LSM6DS0_REG_STATUS_REG_XL 0x27 245 #define LSM6DS0_MASK_STATUS_REG_XL_IG_XL BIT(6) 246 #define LSM6DS0_SHIFT_STATUS_REG_XL_IG_XL 6 247 #define LSM6DS0_MASK_STATUS_REG_XL_IG_G BIT(5) 248 #define LSM6DS0_SHIFT_STATUS_REG_XL_IG_G 5 249 #define LSM6DS0_MASK_STATUS_REG_XL_INACT BIT(4) 250 #define LSM6DS0_SHIFT_STATUS_REG_XL_INACT 4 251 #define LSM6DS0_MASK_STATUS_REG_XL_BOOT_STATUS BIT(3) 252 #define LSM6DS0_SHIFT_STATUS_REG_XL_BOOT_STATUS 3 253 #define LSM6DS0_MASK_STATUS_REG_XL_TDA BIT(2) 254 #define LSM6DS0_SHIFT_STATUS_REG_XL_TDA 2 255 #define LSM6DS0_MASK_STATUS_REG_XL_GDA BIT(1) 256 #define LSM6DS0_SHIFT_STATUS_REG_XL_GDA 1 257 #define LSM6DS0_MASK_STATUS_REG_XL_XLDA BIT(0) 258 #define LSM6DS0_SHIFT_STATUS_REG_XL_XLDA 0 259 260 #define LSM6DS0_REG_OUT_X_L_XL 0x28 261 #define LSM6DS0_REG_OUT_X_H_XL 0x29 262 #define LSM6DS0_REG_OUT_Y_L_XL 0x2A 263 #define LSM6DS0_REG_OUT_Y_H_XL 0x2B 264 #define LSM6DS0_REG_OUT_Z_L_XL 0x2C 265 #define LSM6DS0_REG_OUT_Z_H_XL 0x2D 266 267 #define LSM6DS0_REG_FIFO_CTRL 0x2E 268 #define LSM6DS0_MASK_FIFO_CTRL_FMODE (BIT(7) | BIT(6) | BIT(5)) 269 #define LSM6DS0_SHIFT_FIFO_CTRL_FMODE 5 270 #define LSM6DS0_MASK_FIFO_CTRL_FTH (BIT(4) | BIT(3) | BIT(2) | \ 271 BIT(1) | BIT(0)) 272 #define LSM6DS0_SHIFT_FIFO_CTRL_FTH 0 273 274 #define LSM6DS0_REG_FIFO_SRC 0x2F 275 #define LSM6DS0_MASK_FIFO_SRC_FTH BIT(7) 276 #define LSM6DS0_SHIFT_FIFO_SRC_FTH 7 277 #define LSM6DS0_MASK_FIFO_SRC_OVRN BIT(6) 278 #define LSM6DS0_SHIFT_FIFO_SRC_OVRN 6 279 #define LSM6DS0_MASK_FIFO_SRC_FSS (BIT(5) | BIT(4) | BIT(3) | \ 280 BIT(2) | BIT(1) | BIT(0)) 281 #define LSM6DS0_SHIFT_FIFO_SRC_FSS 0 282 283 #define LSM6DS0_REG_INT_GEN_CFG_G 0x30 284 #define LSM6DS0_MASK_INT_GEN_CFG_G_AOI_G BIT(7) 285 #define LSM6DS0_SHIFT_INT_GEN_CFG_G_AOI_G 7 286 #define LSM6DS0_MASK_INT_GEN_CFG_G_LIR_G BIT(6) 287 #define LSM6DS0_SHIFT_INT_GEN_CFG_G_LIR_G 6 288 #define LSM6DS0_MASK_INT_GEN_CFG_G_ZHIE_G BIT(5) 289 #define LSM6DS0_SHIFT_INT_GEN_CFG_G_ZHIE_G 5 290 #define LSM6DS0_MASK_INT_GEN_CFG_G_ZLIE_G BIT(4) 291 #define LSM6DS0_SHIFT_INT_GEN_CFG_G_ZLIE_G 4 292 #define LSM6DS0_MASK_INT_GEN_CFG_G_YHIE_G BIT(3) 293 #define LSM6DS0_SHIFT_INT_GEN_CFG_G_YHIE_G 3 294 #define LSM6DS0_MASK_INT_GEN_CFG_G_YLIE_G BIT(2) 295 #define LSM6DS0_SHIFT_INT_GEN_CFG_G_YLIE_G 2 296 #define LSM6DS0_MASK_INT_GEN_CFG_G_XHIE_G BIT(1) 297 #define LSM6DS0_SHIFT_INT_GEN_CFG_G_XHIE_G 1 298 #define LSM6DS0_MASK_INT_GEN_CFG_G_XLIE_G BIT(0) 299 #define LSM6DS0_SHIFT_INT_GEN_CFG_G_XLIE_G 0 300 301 #define LSM6DS0_REG_INT_GEN_THS_XH_G 0x31 302 #define LSM6DS0_MASK_INT_GEN_THS_XH_G_DCRM_G BIT(7) 303 #define LSM6DS0_SHIFT_INT_GEN_THS_XH_G_DCRM_G 7 304 305 #define LSM6DS0_REG_INT_GEN_THS_XL_G 0x32 306 #define LSM6DS0_REG_INT_GEN_THS_YH_G 0x33 307 #define LSM6DS0_REG_INT_GEN_THS_YL_G 0x34 308 #define LSM6DS0_REG_INT_GEN_THS_ZH_G 0x35 309 #define LSM6DS0_REG_INT_GEN_THS_ZL_G 0x36 310 311 #define LSM6DS0_REG_INT_GEN_DUR_G 0x37 312 #define LSM6DS0_MASK_INT_GEN_DUR_G_WAIT_G BIT(7) 313 #define LSM6DS0_SHIFT_INT_GEN_DUR_G_WAIT_G 7 314 315 #define SENSOR_G_DOUBLE (SENSOR_G / 1000000.0) 316 #define SENSOR_PI_DOUBLE (SENSOR_PI / 1000000.0) 317 #define SENSOR_DEG2RAD_DOUBLE (SENSOR_PI_DOUBLE / 180) 318 319 #if defined(CONFIG_LSM6DS0_ACCEL_ENABLE_X_AXIS) 320 #define LSM6DS0_ACCEL_ENABLE_X_AXIS 1 321 #else 322 #define LSM6DS0_ACCEL_ENABLE_X_AXIS 0 323 #endif 324 325 #if defined(CONFIG_LSM6DS0_ACCEL_ENABLE_Y_AXIS) 326 #define LSM6DS0_ACCEL_ENABLE_Y_AXIS 1 327 #else 328 #define LSM6DS0_ACCEL_ENABLE_Y_AXIS 0 329 #endif 330 331 #if defined(CONFIG_LSM6DS0_ACCEL_ENABLE_Z_AXIS) 332 #define LSM6DS0_ACCEL_ENABLE_Z_AXIS 1 333 #else 334 #define LSM6DS0_ACCEL_ENABLE_Z_AXIS 0 335 #endif 336 337 #if defined(CONFIG_LSM6DS0_GYRO_ENABLE_X_AXIS) 338 #define LSM6DS0_GYRO_ENABLE_X_AXIS 1 339 #else 340 #define LSM6DS0_GYRO_ENABLE_X_AXIS 0 341 #endif 342 343 #if defined(CONFIG_LSM6DS0_GYRO_ENABLE_Y_AXIS) 344 #define LSM6DS0_GYRO_ENABLE_Y_AXIS 1 345 #else 346 #define LSM6DS0_GYRO_ENABLE_Y_AXIS 0 347 #endif 348 349 #if defined(CONFIG_LSM6DS0_GYRO_ENABLE_Z_AXIS) 350 #define LSM6DS0_GYRO_ENABLE_Z_AXIS 1 351 #else 352 #define LSM6DS0_GYRO_ENABLE_Z_AXIS 0 353 #endif 354 355 #if CONFIG_LSM6DS0_ACCEL_FULLSCALE == 2 356 #define LSM6DS0_ACCEL_FULLSCALE_2G 357 #elif CONFIG_LSM6DS0_ACCEL_FULLSCALE == 4 358 #define LSM6DS0_ACCEL_FULLSCALE_4G 359 #elif CONFIG_LSM6DS0_ACCEL_FULLSCALE == 8 360 #define LSM6DS0_ACCEL_FULLSCALE_8G 361 #elif CONFIG_LSM6DS0_ACCEL_FULLSCALE == 16 362 #define LSM6DS0_ACCEL_FULLSCALE_16G 363 #endif 364 365 #if defined(LSM6DS0_ACCEL_FULLSCALE_2G) 366 #define LSM6DS0_DEFAULT_ACCEL_FULLSCALE 0 367 #define LSM6DS0_DEFAULT_ACCEL_FULLSCALE_FACTOR (2.0 * SENSOR_G_DOUBLE) 368 #elif defined(LSM6DS0_ACCEL_FULLSCALE_4G) 369 #define LSM6DS0_DEFAULT_ACCEL_FULLSCALE 2 370 #define LSM6DS0_DEFAULT_ACCEL_FULLSCALE_FACTOR (4.0 * SENSOR_G_DOUBLE) 371 #elif defined(LSM6DS0_ACCEL_FULLSCALE_8G) 372 #define LSM6DS0_DEFAULT_ACCEL_FULLSCALE 3 373 #define LSM6DS0_DEFAULT_ACCEL_FULLSCALE_FACTOR (8.0 * SENSOR_G_DOUBLE) 374 #elif defined(LSM6DS0_ACCEL_FULLSCALE_16G) 375 #define LSM6DS0_DEFAULT_ACCEL_FULLSCALE 1 376 #define LSM6DS0_DEFAULT_ACCEL_FULLSCALE_FACTOR (16.0 * SENSOR_G_DOUBLE) 377 #endif 378 379 #if CONFIG_LSM6DS0_ACCEL_SAMPLING_RATE == 0 380 #define LSM6DS0_ACCEL_SAMPLING_RATE_0 381 #elif CONFIG_LSM6DS0_ACCEL_SAMPLING_RATE == 10 382 #define LSM6DS0_ACCEL_SAMPLING_RATE_10 383 #elif CONFIG_LSM6DS0_ACCEL_SAMPLING_RATE == 50 384 #define LSM6DS0_ACCEL_SAMPLING_RATE_50 385 #elif CONFIG_LSM6DS0_ACCEL_SAMPLING_RATE == 119 386 #define LSM6DS0_ACCEL_SAMPLING_RATE_119 387 #elif CONFIG_LSM6DS0_ACCEL_SAMPLING_RATE == 238 388 #define LSM6DS0_ACCEL_SAMPLING_RATE_238 389 #elif CONFIG_LSM6DS0_ACCEL_SAMPLING_RATE == 476 390 #define LSM6DS0_ACCEL_SAMPLING_RATE_476 391 #elif CONFIG_LSM6DS0_ACCEL_SAMPLING_RATE == 952 392 #define LSM6DS0_ACCEL_SAMPLING_RATE_952 393 #endif 394 395 #if defined(LSM6DS0_ACCEL_SAMPLING_RATE_0) 396 #define LSM6DS0_DEFAULT_ACCEL_SAMPLING_RATE 0 397 #elif defined(LSM6DS0_ACCEL_SAMPLING_RATE_10) 398 #define LSM6DS0_DEFAULT_ACCEL_SAMPLING_RATE 1 399 #elif defined(LSM6DS0_ACCEL_SAMPLING_RATE_50) 400 #define LSM6DS0_DEFAULT_ACCEL_SAMPLING_RATE 2 401 #elif defined(LSM6DS0_ACCEL_SAMPLING_RATE_119) 402 #define LSM6DS0_DEFAULT_ACCEL_SAMPLING_RATE 3 403 #elif defined(LSM6DS0_ACCEL_SAMPLING_RATE_238) 404 #define LSM6DS0_DEFAULT_ACCEL_SAMPLING_RATE 4 405 #elif defined(LSM6DS0_ACCEL_SAMPLING_RATE_476) 406 #define LSM6DS0_DEFAULT_ACCEL_SAMPLING_RATE 5 407 #elif defined(LSM6DS0_ACCEL_SAMPLING_RATE_952) 408 #define LSM6DS0_DEFAULT_ACCEL_SAMPLING_RATE 6 409 #endif 410 411 #if CONFIG_LSM6DS0_GYRO_FULLSCALE == 245 412 #define LSM6DS0_GYRO_FULLSCALE_245 413 #elif CONFIG_LSM6DS0_GYRO_FULLSCALE == 500 414 #define LSM6DS0_GYRO_FULLSCALE_500 415 #elif CONFIG_LSM6DS0_GYRO_FULLSCALE == 2000 416 #define LSM6DS0_GYRO_FULLSCALE_2000 417 #endif 418 419 #if defined(LSM6DS0_GYRO_FULLSCALE_245) 420 #define LSM6DS0_DEFAULT_GYRO_FULLSCALE 0 421 #define LSM6DS0_DEFAULT_GYRO_FULLSCALE_FACTOR 8.75 422 #elif defined(LSM6DS0_GYRO_FULLSCALE_500) 423 #define LSM6DS0_DEFAULT_GYRO_FULLSCALE 1 424 #define LSM6DS0_DEFAULT_GYRO_FULLSCALE_FACTOR 17.50 425 #elif defined(LSM6DS0_GYRO_FULLSCALE_2000) 426 #define LSM6DS0_DEFAULT_GYRO_FULLSCALE 3 427 #define LSM6DS0_DEFAULT_GYRO_FULLSCALE_FACTOR 70.0 428 #endif 429 430 #if CONFIG_LSM6DS0_GYRO_SAMPLING_RATE == 0 431 #define LSM6DS0_GYRO_SAMPLING_RATE_0 432 #elif CONFIG_LSM6DS0_GYRO_SAMPLING_RATE == 15 433 #define LSM6DS0_GYRO_SAMPLING_RATE_14_9 434 #elif CONFIG_LSM6DS0_GYRO_SAMPLING_RATE == 60 435 #define LSM6DS0_GYRO_SAMPLING_RATE_59_5 436 #elif CONFIG_LSM6DS0_GYRO_SAMPLING_RATE == 119 437 #define LSM6DS0_GYRO_SAMPLING_RATE_119 438 #elif CONFIG_LSM6DS0_GYRO_SAMPLING_RATE == 238 439 #define LSM6DS0_GYRO_SAMPLING_RATE_238 440 #elif CONFIG_LSM6DS0_GYRO_SAMPLING_RATE == 476 441 #define LSM6DS0_GYRO_SAMPLING_RATE_476 442 #elif CONFIG_LSM6DS0_GYRO_SAMPLING_RATE == 952 443 #define LSM6DS0_GYRO_SAMPLING_RATE_952 444 #endif 445 446 #if defined(LSM6DS0_GYRO_SAMPLING_RATE_0) 447 #define LSM6DS0_DEFAULT_GYRO_SAMPLING_RATE 0 448 #elif defined(LSM6DS0_GYRO_SAMPLING_RATE_14_9) 449 #define LSM6DS0_DEFAULT_GYRO_SAMPLING_RATE 1 450 #elif defined(LSM6DS0_GYRO_SAMPLING_RATE_59_5) 451 #define LSM6DS0_DEFAULT_GYRO_SAMPLING_RATE 2 452 #elif defined(LSM6DS0_GYRO_SAMPLING_RATE_119) 453 #define LSM6DS0_DEFAULT_GYRO_SAMPLING_RATE 3 454 #elif defined(LSM6DS0_GYRO_SAMPLING_RATE_238) 455 #define LSM6DS0_DEFAULT_GYRO_SAMPLING_RATE 4 456 #elif defined(LSM6DS0_GYRO_SAMPLING_RATE_476) 457 #define LSM6DS0_DEFAULT_GYRO_SAMPLING_RATE 5 458 #elif defined(LSM6DS0_GYRO_SAMPLING_RATE_952) 459 #define LSM6DS0_DEFAULT_GYRO_SAMPLING_RATE 6 460 #endif 461 462 struct lsm6ds0_config { 463 struct i2c_dt_spec i2c; 464 }; 465 466 struct lsm6ds0_data { 467 #if defined(CONFIG_LSM6DS0_ACCEL_ENABLE_X_AXIS) 468 int accel_sample_x; 469 #endif 470 #if defined(CONFIG_LSM6DS0_ACCEL_ENABLE_Y_AXIS) 471 int accel_sample_y; 472 #endif 473 #if defined(CONFIG_LSM6DS0_ACCEL_ENABLE_Z_AXIS) 474 int accel_sample_z; 475 #endif 476 477 #if defined(CONFIG_LSM6DS0_GYRO_ENABLE_X_AXIS) 478 int gyro_sample_x; 479 #endif 480 #if defined(CONFIG_LSM6DS0_GYRO_ENABLE_Y_AXIS) 481 int gyro_sample_y; 482 #endif 483 #if defined(CONFIG_LSM6DS0_GYRO_ENABLE_Z_AXIS) 484 int gyro_sample_z; 485 #endif 486 487 #if defined(CONFIG_LSM6DS0_ENABLE_TEMP) 488 int temp_sample; 489 #endif 490 }; 491 492 #endif /* ZEPHYR_DRIVERS_SENSOR_LSM6DS0_LSM6DS0_H_ */ 493