1 /** 2 ****************************************************************************** 3 * @file ais2ih_reg.h 4 * @author Sensors Software Solution Team 5 * @brief This file contains all the functions prototypes for the 6 * ais2ih_reg.c driver. 7 ****************************************************************************** 8 * @attention 9 * 10 * <h2><center>© Copyright (c) 2021 STMicroelectronics. 11 * All rights reserved.</center></h2> 12 * 13 * This software component is licensed by ST under BSD 3-Clause license, 14 * the "License"; You may not use this file except in compliance with the 15 * License. You may obtain a copy of the License at: 16 * opensource.org/licenses/BSD-3-Clause 17 * 18 ****************************************************************************** 19 */ 20 21 /* Define to prevent recursive inclusion -------------------------------------*/ 22 #ifndef AIS2IH_REGS_H 23 #define AIS2IH_REGS_H 24 25 #ifdef __cplusplus 26 extern "C" { 27 #endif 28 29 /* Includes ------------------------------------------------------------------*/ 30 #include <stdint.h> 31 #include <stddef.h> 32 #include <math.h> 33 34 /** @addtogroup AIS2IH 35 * @{ 36 * 37 */ 38 39 /** @defgroup Endianness definitions 40 * @{ 41 * 42 */ 43 44 #ifndef DRV_BYTE_ORDER 45 #ifndef __BYTE_ORDER__ 46 47 #define DRV_LITTLE_ENDIAN 1234 48 #define DRV_BIG_ENDIAN 4321 49 50 /** if _BYTE_ORDER is not defined, choose the endianness of your architecture 51 * by uncommenting the define which fits your platform endianness 52 */ 53 //#define DRV_BYTE_ORDER DRV_BIG_ENDIAN 54 #define DRV_BYTE_ORDER DRV_LITTLE_ENDIAN 55 56 #else /* defined __BYTE_ORDER__ */ 57 58 #define DRV_LITTLE_ENDIAN __ORDER_LITTLE_ENDIAN__ 59 #define DRV_BIG_ENDIAN __ORDER_BIG_ENDIAN__ 60 #define DRV_BYTE_ORDER __BYTE_ORDER__ 61 62 #endif /* __BYTE_ORDER__*/ 63 #endif /* DRV_BYTE_ORDER */ 64 65 /** 66 * @} 67 * 68 */ 69 70 /** @defgroup STMicroelectronics sensors common types 71 * @{ 72 * 73 */ 74 75 #ifndef MEMS_SHARED_TYPES 76 #define MEMS_SHARED_TYPES 77 78 typedef struct 79 { 80 #if DRV_BYTE_ORDER == DRV_LITTLE_ENDIAN 81 uint8_t bit0 : 1; 82 uint8_t bit1 : 1; 83 uint8_t bit2 : 1; 84 uint8_t bit3 : 1; 85 uint8_t bit4 : 1; 86 uint8_t bit5 : 1; 87 uint8_t bit6 : 1; 88 uint8_t bit7 : 1; 89 #elif DRV_BYTE_ORDER == DRV_BIG_ENDIAN 90 uint8_t bit7 : 1; 91 uint8_t bit6 : 1; 92 uint8_t bit5 : 1; 93 uint8_t bit4 : 1; 94 uint8_t bit3 : 1; 95 uint8_t bit2 : 1; 96 uint8_t bit1 : 1; 97 uint8_t bit0 : 1; 98 #endif /* DRV_BYTE_ORDER */ 99 } bitwise_t; 100 101 #define PROPERTY_DISABLE (0U) 102 #define PROPERTY_ENABLE (1U) 103 104 /** @addtogroup Interfaces_Functions 105 * @brief This section provide a set of functions used to read and 106 * write a generic register of the device. 107 * MANDATORY: return 0 -> no Error. 108 * @{ 109 * 110 */ 111 112 typedef int32_t (*stmdev_write_ptr)(void *, uint8_t, const uint8_t *, uint16_t); 113 typedef int32_t (*stmdev_read_ptr)(void *, uint8_t, uint8_t *, uint16_t); 114 typedef void (*stmdev_mdelay_ptr)(uint32_t millisec); 115 116 typedef struct 117 { 118 /** Component mandatory fields **/ 119 stmdev_write_ptr write_reg; 120 stmdev_read_ptr read_reg; 121 /** Component optional fields **/ 122 stmdev_mdelay_ptr mdelay; 123 /** Customizable optional pointer **/ 124 void *handle; 125 } stmdev_ctx_t; 126 127 /** 128 * @} 129 * 130 */ 131 132 #endif /* MEMS_SHARED_TYPES */ 133 134 #ifndef MEMS_UCF_SHARED_TYPES 135 #define MEMS_UCF_SHARED_TYPES 136 137 /** @defgroup Generic address-data structure definition 138 * @brief This structure is useful to load a predefined configuration 139 * of a sensor. 140 * You can create a sensor configuration by your own or using 141 * Unico / Unicleo tools available on STMicroelectronics 142 * web site. 143 * 144 * @{ 145 * 146 */ 147 148 typedef struct 149 { 150 uint8_t address; 151 uint8_t data; 152 } ucf_line_t; 153 154 /** 155 * @} 156 * 157 */ 158 159 #endif /* MEMS_UCF_SHARED_TYPES */ 160 161 /** 162 * @} 163 * 164 */ 165 166 /** @defgroup AIS2IH_Infos 167 * @{ 168 * 169 */ 170 171 /** I2C Device Address 8 bit format if SA0=0 -> 31 if SA0=1 -> 33 **/ 172 #define AIS2IH_I2C_ADD_L 0x31U 173 #define AIS2IH_I2C_ADD_H 0x33U 174 175 /** Device Identification (Who am I) **/ 176 #define AIS2IH_ID 0x44U 177 178 /** 179 * @} 180 * 181 */ 182 183 #define AIS2IH_OUT_T_L 0x0DU 184 #define AIS2IH_OUT_T_H 0x0EU 185 #define AIS2IH_WHO_AM_I 0x0FU 186 #define AIS2IH_CTRL1 0x20U 187 typedef struct 188 { 189 #if DRV_BYTE_ORDER == DRV_LITTLE_ENDIAN 190 uint8_t lp_mode : 2; 191 uint8_t mode : 2; 192 uint8_t odr : 4; 193 #elif DRV_BYTE_ORDER == DRV_BIG_ENDIAN 194 uint8_t odr : 4; 195 uint8_t mode : 2; 196 uint8_t lp_mode : 2; 197 #endif /* DRV_BYTE_ORDER */ 198 } ais2ih_ctrl1_t; 199 200 #define AIS2IH_CTRL2 0x21U 201 typedef struct 202 { 203 #if DRV_BYTE_ORDER == DRV_LITTLE_ENDIAN 204 uint8_t sim : 1; 205 uint8_t i2c_disable : 1; 206 uint8_t if_add_inc : 1; 207 uint8_t bdu : 1; 208 uint8_t cs_pu_disc : 1; 209 uint8_t not_used_01 : 1; 210 uint8_t soft_reset : 1; 211 uint8_t boot : 1; 212 #elif DRV_BYTE_ORDER == DRV_BIG_ENDIAN 213 uint8_t boot : 1; 214 uint8_t soft_reset : 1; 215 uint8_t not_used_01 : 1; 216 uint8_t cs_pu_disc : 1; 217 uint8_t bdu : 1; 218 uint8_t if_add_inc : 1; 219 uint8_t i2c_disable : 1; 220 uint8_t sim : 1; 221 #endif /* DRV_BYTE_ORDER */ 222 } ais2ih_ctrl2_t; 223 224 #define AIS2IH_CTRL3 0x22U 225 typedef struct 226 { 227 #if DRV_BYTE_ORDER == DRV_LITTLE_ENDIAN 228 uint8_t slp_mode : 229 2; /* slp_mode_sel + slp_mode_1 */ 230 uint8_t not_used_01 : 1; 231 uint8_t h_lactive : 1; 232 uint8_t lir : 1; 233 uint8_t pp_od : 1; 234 uint8_t st : 2; 235 #elif DRV_BYTE_ORDER == DRV_BIG_ENDIAN 236 uint8_t st : 2; 237 uint8_t pp_od : 1; 238 uint8_t lir : 1; 239 uint8_t h_lactive : 1; 240 uint8_t not_used_01 : 1; 241 uint8_t slp_mode : 242 2; /* slp_mode_sel + slp_mode_1 */ 243 #endif /* DRV_BYTE_ORDER */ 244 } ais2ih_ctrl3_t; 245 246 #define AIS2IH_CTRL4_INT1_PAD_CTRL 0x23U 247 typedef struct 248 { 249 #if DRV_BYTE_ORDER == DRV_LITTLE_ENDIAN 250 uint8_t int1_drdy : 1; 251 uint8_t int1_fth : 1; 252 uint8_t int1_diff5 : 1; 253 uint8_t int1_tap : 1; 254 uint8_t int1_ff : 1; 255 uint8_t int1_wu : 1; 256 uint8_t int1_single_tap : 1; 257 uint8_t int1_6d : 1; 258 #elif DRV_BYTE_ORDER == DRV_BIG_ENDIAN 259 uint8_t int1_6d : 1; 260 uint8_t int1_single_tap : 1; 261 uint8_t int1_wu : 1; 262 uint8_t int1_ff : 1; 263 uint8_t int1_tap : 1; 264 uint8_t int1_diff5 : 1; 265 uint8_t int1_fth : 1; 266 uint8_t int1_drdy : 1; 267 #endif /* DRV_BYTE_ORDER */ 268 } ais2ih_ctrl4_int1_pad_ctrl_t; 269 270 #define AIS2IH_CTRL5_INT2_PAD_CTRL 0x24U 271 typedef struct 272 { 273 #if DRV_BYTE_ORDER == DRV_LITTLE_ENDIAN 274 uint8_t int2_drdy : 1; 275 uint8_t int2_fth : 1; 276 uint8_t int2_diff5 : 1; 277 uint8_t int2_ovr : 1; 278 uint8_t int2_drdy_t : 1; 279 uint8_t int2_boot : 1; 280 uint8_t int2_sleep_chg : 1; 281 uint8_t int2_sleep_state : 1; 282 #elif DRV_BYTE_ORDER == DRV_BIG_ENDIAN 283 uint8_t int2_sleep_state : 1; 284 uint8_t int2_sleep_chg : 1; 285 uint8_t int2_boot : 1; 286 uint8_t int2_drdy_t : 1; 287 uint8_t int2_ovr : 1; 288 uint8_t int2_diff5 : 1; 289 uint8_t int2_fth : 1; 290 uint8_t int2_drdy : 1; 291 #endif /* DRV_BYTE_ORDER */ 292 } ais2ih_ctrl5_int2_pad_ctrl_t; 293 294 #define AIS2IH_CTRL6 0x25U 295 typedef struct 296 { 297 #if DRV_BYTE_ORDER == DRV_LITTLE_ENDIAN 298 uint8_t not_used_01 : 2; 299 uint8_t low_noise : 1; 300 uint8_t fds : 1; 301 uint8_t fs : 2; 302 uint8_t bw_filt : 2; 303 #elif DRV_BYTE_ORDER == DRV_BIG_ENDIAN 304 uint8_t bw_filt : 2; 305 uint8_t fs : 2; 306 uint8_t fds : 1; 307 uint8_t low_noise : 1; 308 uint8_t not_used_01 : 2; 309 #endif /* DRV_BYTE_ORDER */ 310 } ais2ih_ctrl6_t; 311 312 #define AIS2IH_OUT_T 0x26U 313 #define AIS2IH_STATUS 0x27U 314 typedef struct 315 { 316 #if DRV_BYTE_ORDER == DRV_LITTLE_ENDIAN 317 uint8_t drdy : 1; 318 uint8_t ff_ia : 1; 319 uint8_t _6d_ia : 1; 320 uint8_t single_tap : 1; 321 uint8_t double_tap : 1; 322 uint8_t sleep_state : 1; 323 uint8_t wu_ia : 1; 324 uint8_t fifo_ths : 1; 325 #elif DRV_BYTE_ORDER == DRV_BIG_ENDIAN 326 uint8_t fifo_ths : 1; 327 uint8_t wu_ia : 1; 328 uint8_t sleep_state : 1; 329 uint8_t double_tap : 1; 330 uint8_t single_tap : 1; 331 uint8_t _6d_ia : 1; 332 uint8_t ff_ia : 1; 333 uint8_t drdy : 1; 334 #endif /* DRV_BYTE_ORDER */ 335 } ais2ih_status_t; 336 337 #define AIS2IH_OUT_X_L 0x28U 338 #define AIS2IH_OUT_X_H 0x29U 339 #define AIS2IH_OUT_Y_L 0x2AU 340 #define AIS2IH_OUT_Y_H 0x2BU 341 #define AIS2IH_OUT_Z_L 0x2CU 342 #define AIS2IH_OUT_Z_H 0x2DU 343 #define AIS2IH_FIFO_CTRL 0x2EU 344 typedef struct 345 { 346 #if DRV_BYTE_ORDER == DRV_LITTLE_ENDIAN 347 uint8_t fth : 5; 348 uint8_t fmode : 3; 349 #elif DRV_BYTE_ORDER == DRV_BIG_ENDIAN 350 uint8_t fmode : 3; 351 uint8_t fth : 5; 352 #endif /* DRV_BYTE_ORDER */ 353 } ais2ih_fifo_ctrl_t; 354 355 #define AIS2IH_FIFO_SAMPLES 0x2FU 356 typedef struct 357 { 358 #if DRV_BYTE_ORDER == DRV_LITTLE_ENDIAN 359 uint8_t diff : 6; 360 uint8_t fifo_ovr : 1; 361 uint8_t fifo_fth : 1; 362 #elif DRV_BYTE_ORDER == DRV_BIG_ENDIAN 363 uint8_t fifo_fth : 1; 364 uint8_t fifo_ovr : 1; 365 uint8_t diff : 6; 366 #endif /* DRV_BYTE_ORDER */ 367 } ais2ih_fifo_samples_t; 368 369 #define AIS2IH_TAP_THS_X 0x30U 370 typedef struct 371 { 372 #if DRV_BYTE_ORDER == DRV_LITTLE_ENDIAN 373 uint8_t tap_thsx : 5; 374 uint8_t _6d_ths : 2; 375 uint8_t _4d_en : 1; 376 #elif DRV_BYTE_ORDER == DRV_BIG_ENDIAN 377 uint8_t _4d_en : 1; 378 uint8_t _6d_ths : 2; 379 uint8_t tap_thsx : 5; 380 #endif /* DRV_BYTE_ORDER */ 381 } ais2ih_tap_ths_x_t; 382 383 #define AIS2IH_TAP_THS_Y 0x31U 384 typedef struct 385 { 386 #if DRV_BYTE_ORDER == DRV_LITTLE_ENDIAN 387 uint8_t tap_thsy : 5; 388 uint8_t tap_prior : 3; 389 #elif DRV_BYTE_ORDER == DRV_BIG_ENDIAN 390 uint8_t tap_prior : 3; 391 uint8_t tap_thsy : 5; 392 #endif /* DRV_BYTE_ORDER */ 393 } ais2ih_tap_ths_y_t; 394 395 #define AIS2IH_TAP_THS_Z 0x32U 396 typedef struct 397 { 398 #if DRV_BYTE_ORDER == DRV_LITTLE_ENDIAN 399 uint8_t tap_thsz : 5; 400 uint8_t tap_z_en : 1; 401 uint8_t tap_y_en : 1; 402 uint8_t tap_x_en : 1; 403 #elif DRV_BYTE_ORDER == DRV_BIG_ENDIAN 404 uint8_t tap_x_en : 1; 405 uint8_t tap_y_en : 1; 406 uint8_t tap_z_en : 1; 407 uint8_t tap_thsz : 5; 408 #endif /* DRV_BYTE_ORDER */ 409 } ais2ih_tap_ths_z_t; 410 411 #define AIS2IH_INT_DUR 0x33U 412 typedef struct 413 { 414 #if DRV_BYTE_ORDER == DRV_LITTLE_ENDIAN 415 uint8_t shock : 2; 416 uint8_t quiet : 2; 417 uint8_t latency : 4; 418 #elif DRV_BYTE_ORDER == DRV_BIG_ENDIAN 419 uint8_t latency : 4; 420 uint8_t quiet : 2; 421 uint8_t shock : 2; 422 #endif /* DRV_BYTE_ORDER */ 423 } ais2ih_int_dur_t; 424 425 #define AIS2IH_WAKE_UP_THS 0x34U 426 typedef struct 427 { 428 #if DRV_BYTE_ORDER == DRV_LITTLE_ENDIAN 429 uint8_t wk_ths : 6; 430 uint8_t sleep_on : 1; 431 uint8_t single_double_tap : 1; 432 #elif DRV_BYTE_ORDER == DRV_BIG_ENDIAN 433 uint8_t single_double_tap : 1; 434 uint8_t sleep_on : 1; 435 uint8_t wk_ths : 6; 436 #endif /* DRV_BYTE_ORDER */ 437 } ais2ih_wake_up_ths_t; 438 439 #define AIS2IH_WAKE_UP_DUR 0x35U 440 typedef struct 441 { 442 #if DRV_BYTE_ORDER == DRV_LITTLE_ENDIAN 443 uint8_t sleep_dur : 4; 444 uint8_t stationary : 1; 445 uint8_t wake_dur : 2; 446 uint8_t ff_dur : 1; 447 #elif DRV_BYTE_ORDER == DRV_BIG_ENDIAN 448 uint8_t ff_dur : 1; 449 uint8_t wake_dur : 2; 450 uint8_t stationary : 1; 451 uint8_t sleep_dur : 4; 452 #endif /* DRV_BYTE_ORDER */ 453 } ais2ih_wake_up_dur_t; 454 455 #define AIS2IH_FREE_FALL 0x36U 456 typedef struct 457 { 458 #if DRV_BYTE_ORDER == DRV_LITTLE_ENDIAN 459 uint8_t ff_ths : 3; 460 uint8_t ff_dur : 5; 461 #elif DRV_BYTE_ORDER == DRV_BIG_ENDIAN 462 uint8_t ff_dur : 5; 463 uint8_t ff_ths : 3; 464 #endif /* DRV_BYTE_ORDER */ 465 } ais2ih_free_fall_t; 466 467 #define AIS2IH_STATUS_DUP 0x37U 468 typedef struct 469 { 470 #if DRV_BYTE_ORDER == DRV_LITTLE_ENDIAN 471 uint8_t drdy : 1; 472 uint8_t ff_ia : 1; 473 uint8_t _6d_ia : 1; 474 uint8_t single_tap : 1; 475 uint8_t double_tap : 1; 476 uint8_t sleep_state_ia : 1; 477 uint8_t drdy_t : 1; 478 uint8_t ovr : 1; 479 #elif DRV_BYTE_ORDER == DRV_BIG_ENDIAN 480 uint8_t ovr : 1; 481 uint8_t drdy_t : 1; 482 uint8_t sleep_state_ia : 1; 483 uint8_t double_tap : 1; 484 uint8_t single_tap : 1; 485 uint8_t _6d_ia : 1; 486 uint8_t ff_ia : 1; 487 uint8_t drdy : 1; 488 #endif /* DRV_BYTE_ORDER */ 489 } ais2ih_status_dup_t; 490 491 #define AIS2IH_WAKE_UP_SRC 0x38U 492 typedef struct 493 { 494 #if DRV_BYTE_ORDER == DRV_LITTLE_ENDIAN 495 uint8_t z_wu : 1; 496 uint8_t y_wu : 1; 497 uint8_t x_wu : 1; 498 uint8_t wu_ia : 1; 499 uint8_t sleep_state_ia : 1; 500 uint8_t ff_ia : 1; 501 uint8_t not_used_01 : 2; 502 #elif DRV_BYTE_ORDER == DRV_BIG_ENDIAN 503 uint8_t not_used_01 : 2; 504 uint8_t ff_ia : 1; 505 uint8_t sleep_state_ia : 1; 506 uint8_t wu_ia : 1; 507 uint8_t x_wu : 1; 508 uint8_t y_wu : 1; 509 uint8_t z_wu : 1; 510 #endif /* DRV_BYTE_ORDER */ 511 } ais2ih_wake_up_src_t; 512 513 #define AIS2IH_TAP_SRC 0x39U 514 typedef struct 515 { 516 #if DRV_BYTE_ORDER == DRV_LITTLE_ENDIAN 517 uint8_t z_tap : 1; 518 uint8_t y_tap : 1; 519 uint8_t x_tap : 1; 520 uint8_t tap_sign : 1; 521 uint8_t double_tap : 1; 522 uint8_t single_tap : 1; 523 uint8_t tap_ia : 1; 524 uint8_t not_used_01 : 1; 525 #elif DRV_BYTE_ORDER == DRV_BIG_ENDIAN 526 uint8_t not_used_01 : 1; 527 uint8_t tap_ia : 1; 528 uint8_t single_tap : 1; 529 uint8_t double_tap : 1; 530 uint8_t tap_sign : 1; 531 uint8_t x_tap : 1; 532 uint8_t y_tap : 1; 533 uint8_t z_tap : 1; 534 #endif /* DRV_BYTE_ORDER */ 535 } ais2ih_tap_src_t; 536 537 #define AIS2IH_SIXD_SRC 0x3AU 538 typedef struct 539 { 540 #if DRV_BYTE_ORDER == DRV_LITTLE_ENDIAN 541 uint8_t xl : 1; 542 uint8_t xh : 1; 543 uint8_t yl : 1; 544 uint8_t yh : 1; 545 uint8_t zl : 1; 546 uint8_t zh : 1; 547 uint8_t _6d_ia : 1; 548 uint8_t not_used_01 : 1; 549 #elif DRV_BYTE_ORDER == DRV_BIG_ENDIAN 550 uint8_t not_used_01 : 1; 551 uint8_t _6d_ia : 1; 552 uint8_t zh : 1; 553 uint8_t zl : 1; 554 uint8_t yh : 1; 555 uint8_t yl : 1; 556 uint8_t xh : 1; 557 uint8_t xl : 1; 558 #endif /* DRV_BYTE_ORDER */ 559 } ais2ih_sixd_src_t; 560 561 #define AIS2IH_ALL_INT_SRC 0x3BU 562 typedef struct 563 { 564 #if DRV_BYTE_ORDER == DRV_LITTLE_ENDIAN 565 uint8_t ff_ia : 1; 566 uint8_t wu_ia : 1; 567 uint8_t single_tap : 1; 568 uint8_t double_tap : 1; 569 uint8_t _6d_ia : 1; 570 uint8_t sleep_change_ia : 1; 571 uint8_t not_used_01 : 2; 572 #elif DRV_BYTE_ORDER == DRV_BIG_ENDIAN 573 uint8_t not_used_01 : 2; 574 uint8_t sleep_change_ia : 1; 575 uint8_t _6d_ia : 1; 576 uint8_t double_tap : 1; 577 uint8_t single_tap : 1; 578 uint8_t wu_ia : 1; 579 uint8_t ff_ia : 1; 580 #endif /* DRV_BYTE_ORDER */ 581 } ais2ih_all_int_src_t; 582 583 #define AIS2IH_X_OFS_USR 0x3CU 584 #define AIS2IH_Y_OFS_USR 0x3DU 585 #define AIS2IH_Z_OFS_USR 0x3EU 586 #define AIS2IH_CTRL_REG7 0x3FU 587 typedef struct 588 { 589 #if DRV_BYTE_ORDER == DRV_LITTLE_ENDIAN 590 uint8_t lpass_on6d : 1; 591 uint8_t hp_ref_mode : 1; 592 uint8_t usr_off_w : 1; 593 uint8_t usr_off_on_wu : 1; 594 uint8_t usr_off_on_out : 1; 595 uint8_t interrupts_enable : 1; 596 uint8_t int2_on_int1 : 1; 597 uint8_t drdy_pulsed : 1; 598 #elif DRV_BYTE_ORDER == DRV_BIG_ENDIAN 599 uint8_t drdy_pulsed : 1; 600 uint8_t int2_on_int1 : 1; 601 uint8_t interrupts_enable : 1; 602 uint8_t usr_off_on_out : 1; 603 uint8_t usr_off_on_wu : 1; 604 uint8_t usr_off_w : 1; 605 uint8_t hp_ref_mode : 1; 606 uint8_t lpass_on6d : 1; 607 #endif /* DRV_BYTE_ORDER */ 608 } ais2ih_ctrl_reg7_t; 609 610 /** 611 * @defgroup AIS2IH_Register_Union 612 * @brief This union group all the registers having a bit-field 613 * description. 614 * This union is useful but it's not needed by the driver. 615 * 616 * REMOVING this union you are compliant with: 617 * MISRA-C 2012 [Rule 19.2] -> " Union are not allowed " 618 * 619 * @{ 620 * 621 */ 622 typedef union 623 { 624 ais2ih_ctrl1_t ctrl1; 625 ais2ih_ctrl2_t ctrl2; 626 ais2ih_ctrl3_t ctrl3; 627 ais2ih_ctrl4_int1_pad_ctrl_t ctrl4_int1_pad_ctrl; 628 ais2ih_ctrl5_int2_pad_ctrl_t ctrl5_int2_pad_ctrl; 629 ais2ih_ctrl6_t ctrl6; 630 ais2ih_status_t status; 631 ais2ih_fifo_ctrl_t fifo_ctrl; 632 ais2ih_fifo_samples_t fifo_samples; 633 ais2ih_tap_ths_x_t tap_ths_x; 634 ais2ih_tap_ths_y_t tap_ths_y; 635 ais2ih_tap_ths_z_t tap_ths_z; 636 ais2ih_int_dur_t int_dur; 637 ais2ih_wake_up_ths_t wake_up_ths; 638 ais2ih_wake_up_dur_t wake_up_dur; 639 ais2ih_free_fall_t free_fall; 640 ais2ih_status_dup_t status_dup; 641 ais2ih_wake_up_src_t wake_up_src; 642 ais2ih_tap_src_t tap_src; 643 ais2ih_sixd_src_t sixd_src; 644 ais2ih_all_int_src_t all_int_src; 645 ais2ih_ctrl_reg7_t ctrl_reg7; 646 bitwise_t bitwise; 647 uint8_t byte; 648 } ais2ih_reg_t; 649 650 /** 651 * @} 652 * 653 */ 654 655 #ifndef __weak 656 #define __weak __attribute__((weak)) 657 #endif /* __weak */ 658 659 /* 660 * These are the basic platform dependent I/O routines to read 661 * and write device registers connected on a standard bus. 662 * The driver keeps offering a default implementation based on function 663 * pointers to read/write routines for backward compatibility. 664 * The __weak directive allows the final application to overwrite 665 * them with a custom implementation. 666 */ 667 668 int32_t ais2ih_read_reg(const stmdev_ctx_t *ctx, uint8_t reg, uint8_t *data, 669 uint16_t len); 670 int32_t ais2ih_write_reg(const stmdev_ctx_t *ctx, uint8_t reg, 671 uint8_t *data, 672 uint16_t len); 673 674 float_t ais2ih_from_fs2_to_mg(int16_t lsb); 675 float_t ais2ih_from_fs4_to_mg(int16_t lsb); 676 float_t ais2ih_from_fs8_to_mg(int16_t lsb); 677 float_t ais2ih_from_fs16_to_mg(int16_t lsb); 678 float_t ais2ih_from_fs2_lp1_to_mg(int16_t lsb); 679 float_t ais2ih_from_fs4_lp1_to_mg(int16_t lsb); 680 float_t ais2ih_from_fs8_lp1_to_mg(int16_t lsb); 681 float_t ais2ih_from_fs16_lp1_to_mg(int16_t lsb); 682 float_t ais2ih_from_lsb_to_celsius(int16_t lsb); 683 684 typedef enum 685 { 686 AIS2IH_HIGH_PERFORMANCE = 0x04, 687 AIS2IH_CONT_LOW_PWR_4 = 0x03, 688 AIS2IH_CONT_LOW_PWR_3 = 0x02, 689 AIS2IH_CONT_LOW_PWR_2 = 0x01, 690 AIS2IH_CONT_LOW_PWR_12bit = 0x00, 691 AIS2IH_SINGLE_LOW_PWR_4 = 0x0B, 692 AIS2IH_SINGLE_LOW_PWR_3 = 0x0A, 693 AIS2IH_SINGLE_LOW_PWR_2 = 0x09, 694 AIS2IH_SINGLE_LOW_PWR_12bit = 0x08, 695 AIS2IH_HIGH_PERFORMANCE_LOW_NOISE = 0x14, 696 AIS2IH_CONT_LOW_PWR_LOW_NOISE_4 = 0x13, 697 AIS2IH_CONT_LOW_PWR_LOW_NOISE_3 = 0x12, 698 AIS2IH_CONT_LOW_PWR_LOW_NOISE_2 = 0x11, 699 AIS2IH_CONT_LOW_PWR_LOW_NOISE_12bit = 0x10, 700 AIS2IH_SINGLE_LOW_PWR_LOW_NOISE_4 = 0x1B, 701 AIS2IH_SINGLE_LOW_PWR_LOW_NOISE_3 = 0x1A, 702 AIS2IH_SINGLE_LOW_PWR_LOW_NOISE_2 = 0x19, 703 AIS2IH_SINGLE_LOW_LOW_NOISE_PWR_12bit = 0x18, 704 } ais2ih_mode_t; 705 int32_t ais2ih_power_mode_set(const stmdev_ctx_t *ctx, ais2ih_mode_t val); 706 int32_t ais2ih_power_mode_get(const stmdev_ctx_t *ctx, ais2ih_mode_t *val); 707 708 typedef enum 709 { 710 AIS2IH_XL_ODR_OFF = 0x00, 711 AIS2IH_XL_ODR_1Hz6_LP_ONLY = 0x01, 712 AIS2IH_XL_ODR_12Hz5 = 0x02, 713 AIS2IH_XL_ODR_25Hz = 0x03, 714 AIS2IH_XL_ODR_50Hz = 0x04, 715 AIS2IH_XL_ODR_100Hz = 0x05, 716 AIS2IH_XL_ODR_200Hz = 0x06, 717 AIS2IH_XL_ODR_400Hz = 0x07, 718 AIS2IH_XL_ODR_800Hz = 0x08, 719 AIS2IH_XL_ODR_1k6Hz = 0x09, 720 AIS2IH_XL_SET_SW_TRIG = 0x32, /* Use this only in SINGLE mode */ 721 AIS2IH_XL_SET_PIN_TRIG = 0x12, /* Use this only in SINGLE mode */ 722 } ais2ih_odr_t; 723 int32_t ais2ih_data_rate_set(const stmdev_ctx_t *ctx, ais2ih_odr_t val); 724 int32_t ais2ih_data_rate_get(const stmdev_ctx_t *ctx, ais2ih_odr_t *val); 725 726 int32_t ais2ih_block_data_update_set(const stmdev_ctx_t *ctx, uint8_t val); 727 int32_t ais2ih_block_data_update_get(const stmdev_ctx_t *ctx, uint8_t *val); 728 729 typedef enum 730 { 731 AIS2IH_2g = 0, 732 AIS2IH_4g = 1, 733 AIS2IH_8g = 2, 734 AIS2IH_16g = 3, 735 } ais2ih_fs_t; 736 int32_t ais2ih_full_scale_set(const stmdev_ctx_t *ctx, ais2ih_fs_t val); 737 int32_t ais2ih_full_scale_get(const stmdev_ctx_t *ctx, ais2ih_fs_t *val); 738 739 int32_t ais2ih_status_reg_get(const stmdev_ctx_t *ctx, 740 ais2ih_status_t *val); 741 742 int32_t ais2ih_flag_data_ready_get(const stmdev_ctx_t *ctx, uint8_t *val); 743 744 typedef struct 745 { 746 ais2ih_status_dup_t status_dup; 747 ais2ih_wake_up_src_t wake_up_src; 748 ais2ih_tap_src_t tap_src; 749 ais2ih_sixd_src_t sixd_src; 750 ais2ih_all_int_src_t all_int_src; 751 } ais2ih_all_sources_t; 752 int32_t ais2ih_all_sources_get(const stmdev_ctx_t *ctx, 753 ais2ih_all_sources_t *val); 754 755 int32_t ais2ih_usr_offset_x_set(const stmdev_ctx_t *ctx, uint8_t *buff); 756 int32_t ais2ih_usr_offset_x_get(const stmdev_ctx_t *ctx, uint8_t *buff); 757 758 int32_t ais2ih_usr_offset_y_set(const stmdev_ctx_t *ctx, uint8_t *buff); 759 int32_t ais2ih_usr_offset_y_get(const stmdev_ctx_t *ctx, uint8_t *buff); 760 761 int32_t ais2ih_usr_offset_z_set(const stmdev_ctx_t *ctx, uint8_t *buff); 762 int32_t ais2ih_usr_offset_z_get(const stmdev_ctx_t *ctx, uint8_t *buff); 763 764 typedef enum 765 { 766 AIS2IH_LSb_977ug = 0, 767 AIS2IH_LSb_15mg6 = 1, 768 } ais2ih_usr_off_w_t; 769 int32_t ais2ih_offset_weight_set(const stmdev_ctx_t *ctx, 770 ais2ih_usr_off_w_t val); 771 int32_t ais2ih_offset_weight_get(const stmdev_ctx_t *ctx, 772 ais2ih_usr_off_w_t *val); 773 774 int32_t ais2ih_temperature_raw_get(const stmdev_ctx_t *ctx, int16_t *val); 775 776 int32_t ais2ih_acceleration_raw_get(const stmdev_ctx_t *ctx, int16_t *val); 777 778 int32_t ais2ih_device_id_get(const stmdev_ctx_t *ctx, uint8_t *buff); 779 780 int32_t ais2ih_auto_increment_set(const stmdev_ctx_t *ctx, uint8_t val); 781 int32_t ais2ih_auto_increment_get(const stmdev_ctx_t *ctx, uint8_t *val); 782 783 int32_t ais2ih_reset_set(const stmdev_ctx_t *ctx, uint8_t val); 784 int32_t ais2ih_reset_get(const stmdev_ctx_t *ctx, uint8_t *val); 785 786 int32_t ais2ih_boot_set(const stmdev_ctx_t *ctx, uint8_t val); 787 int32_t ais2ih_boot_get(const stmdev_ctx_t *ctx, uint8_t *val); 788 789 typedef enum 790 { 791 AIS2IH_XL_ST_DISABLE = 0, 792 AIS2IH_XL_ST_POSITIVE = 1, 793 AIS2IH_XL_ST_NEGATIVE = 2, 794 } ais2ih_st_t; 795 int32_t ais2ih_self_test_set(const stmdev_ctx_t *ctx, ais2ih_st_t val); 796 int32_t ais2ih_self_test_get(const stmdev_ctx_t *ctx, ais2ih_st_t *val); 797 798 typedef enum 799 { 800 AIS2IH_DRDY_LATCHED = 0, 801 AIS2IH_DRDY_PULSED = 1, 802 } ais2ih_drdy_pulsed_t; 803 int32_t ais2ih_data_ready_mode_set(const stmdev_ctx_t *ctx, 804 ais2ih_drdy_pulsed_t val); 805 int32_t ais2ih_data_ready_mode_get(const stmdev_ctx_t *ctx, 806 ais2ih_drdy_pulsed_t *val); 807 808 typedef enum 809 { 810 AIS2IH_LPF_ON_OUT = 0x00, 811 AIS2IH_USER_OFFSET_ON_OUT = 0x01, 812 AIS2IH_HIGH_PASS_ON_OUT = 0x10, 813 } ais2ih_fds_t; 814 int32_t ais2ih_filter_path_set(const stmdev_ctx_t *ctx, ais2ih_fds_t val); 815 int32_t ais2ih_filter_path_get(const stmdev_ctx_t *ctx, ais2ih_fds_t *val); 816 817 typedef enum 818 { 819 AIS2IH_ODR_DIV_2 = 0, 820 AIS2IH_ODR_DIV_4 = 1, 821 AIS2IH_ODR_DIV_10 = 2, 822 AIS2IH_ODR_DIV_20 = 3, 823 } ais2ih_bw_filt_t; 824 int32_t ais2ih_filter_bandwidth_set(const stmdev_ctx_t *ctx, 825 ais2ih_bw_filt_t val); 826 int32_t ais2ih_filter_bandwidth_get(const stmdev_ctx_t *ctx, 827 ais2ih_bw_filt_t *val); 828 829 int32_t ais2ih_reference_mode_set(const stmdev_ctx_t *ctx, uint8_t val); 830 int32_t ais2ih_reference_mode_get(const stmdev_ctx_t *ctx, uint8_t *val); 831 832 typedef enum 833 { 834 AIS2IH_SPI_4_WIRE = 0, 835 AIS2IH_SPI_3_WIRE = 1, 836 } ais2ih_sim_t; 837 int32_t ais2ih_spi_mode_set(const stmdev_ctx_t *ctx, ais2ih_sim_t val); 838 int32_t ais2ih_spi_mode_get(const stmdev_ctx_t *ctx, ais2ih_sim_t *val); 839 840 typedef enum 841 { 842 AIS2IH_I2C_ENABLE = 0, 843 AIS2IH_I2C_DISABLE = 1, 844 } ais2ih_i2c_disable_t; 845 int32_t ais2ih_i2c_interface_set(const stmdev_ctx_t *ctx, 846 ais2ih_i2c_disable_t val); 847 int32_t ais2ih_i2c_interface_get(const stmdev_ctx_t *ctx, 848 ais2ih_i2c_disable_t *val); 849 850 typedef enum 851 { 852 AIS2IH_PULL_UP_CONNECT = 0, 853 AIS2IH_PULL_UP_DISCONNECT = 1, 854 } ais2ih_cs_pu_disc_t; 855 int32_t ais2ih_cs_mode_set(const stmdev_ctx_t *ctx, 856 ais2ih_cs_pu_disc_t val); 857 int32_t ais2ih_cs_mode_get(const stmdev_ctx_t *ctx, 858 ais2ih_cs_pu_disc_t *val); 859 860 typedef enum 861 { 862 AIS2IH_ACTIVE_HIGH = 0, 863 AIS2IH_ACTIVE_LOW = 1, 864 } ais2ih_h_lactive_t; 865 int32_t ais2ih_pin_polarity_set(const stmdev_ctx_t *ctx, 866 ais2ih_h_lactive_t val); 867 int32_t ais2ih_pin_polarity_get(const stmdev_ctx_t *ctx, 868 ais2ih_h_lactive_t *val); 869 870 typedef enum 871 { 872 AIS2IH_INT_PULSED = 0, 873 AIS2IH_INT_LATCHED = 1, 874 } ais2ih_lir_t; 875 int32_t ais2ih_int_notification_set(const stmdev_ctx_t *ctx, 876 ais2ih_lir_t val); 877 int32_t ais2ih_int_notification_get(const stmdev_ctx_t *ctx, 878 ais2ih_lir_t *val); 879 880 typedef enum 881 { 882 AIS2IH_PUSH_PULL = 0, 883 AIS2IH_OPEN_DRAIN = 1, 884 } ais2ih_pp_od_t; 885 int32_t ais2ih_pin_mode_set(const stmdev_ctx_t *ctx, ais2ih_pp_od_t val); 886 int32_t ais2ih_pin_mode_get(const stmdev_ctx_t *ctx, ais2ih_pp_od_t *val); 887 888 int32_t ais2ih_pin_int1_route_set(const stmdev_ctx_t *ctx, 889 ais2ih_ctrl4_int1_pad_ctrl_t *val); 890 int32_t ais2ih_pin_int1_route_get(const stmdev_ctx_t *ctx, 891 ais2ih_ctrl4_int1_pad_ctrl_t *val); 892 893 int32_t ais2ih_pin_int2_route_set(const stmdev_ctx_t *ctx, 894 ais2ih_ctrl5_int2_pad_ctrl_t *val); 895 int32_t ais2ih_pin_int2_route_get(const stmdev_ctx_t *ctx, 896 ais2ih_ctrl5_int2_pad_ctrl_t *val); 897 898 int32_t ais2ih_all_on_int1_set(const stmdev_ctx_t *ctx, uint8_t val); 899 int32_t ais2ih_all_on_int1_get(const stmdev_ctx_t *ctx, uint8_t *val); 900 901 int32_t ais2ih_wkup_threshold_set(const stmdev_ctx_t *ctx, uint8_t val); 902 int32_t ais2ih_wkup_threshold_get(const stmdev_ctx_t *ctx, uint8_t *val); 903 904 int32_t ais2ih_wkup_dur_set(const stmdev_ctx_t *ctx, uint8_t val); 905 int32_t ais2ih_wkup_dur_get(const stmdev_ctx_t *ctx, uint8_t *val); 906 907 typedef enum 908 { 909 AIS2IH_HP_FEED = 0, 910 AIS2IH_USER_OFFSET_FEED = 1, 911 } ais2ih_usr_off_on_wu_t; 912 int32_t ais2ih_wkup_feed_data_set(const stmdev_ctx_t *ctx, 913 ais2ih_usr_off_on_wu_t val); 914 int32_t ais2ih_wkup_feed_data_get(const stmdev_ctx_t *ctx, 915 ais2ih_usr_off_on_wu_t *val); 916 917 typedef enum 918 { 919 AIS2IH_NO_DETECTION = 0, 920 AIS2IH_DETECT_ACT_INACT = 1, 921 AIS2IH_DETECT_STAT_MOTION = 3, 922 } ais2ih_sleep_on_t; 923 int32_t ais2ih_act_mode_set(const stmdev_ctx_t *ctx, ais2ih_sleep_on_t val); 924 int32_t ais2ih_act_mode_get(const stmdev_ctx_t *ctx, 925 ais2ih_sleep_on_t *val); 926 927 int32_t ais2ih_act_sleep_dur_set(const stmdev_ctx_t *ctx, uint8_t val); 928 int32_t ais2ih_act_sleep_dur_get(const stmdev_ctx_t *ctx, uint8_t *val); 929 930 int32_t ais2ih_tap_threshold_x_set(const stmdev_ctx_t *ctx, uint8_t val); 931 int32_t ais2ih_tap_threshold_x_get(const stmdev_ctx_t *ctx, uint8_t *val); 932 933 int32_t ais2ih_tap_threshold_y_set(const stmdev_ctx_t *ctx, uint8_t val); 934 int32_t ais2ih_tap_threshold_y_get(const stmdev_ctx_t *ctx, uint8_t *val); 935 936 typedef enum 937 { 938 AIS2IH_XYZ = 0, 939 AIS2IH_YXZ = 1, 940 AIS2IH_XZY = 2, 941 AIS2IH_ZYX = 3, 942 AIS2IH_YZX = 5, 943 AIS2IH_ZXY = 6, 944 } ais2ih_tap_prior_t; 945 int32_t ais2ih_tap_axis_priority_set(const stmdev_ctx_t *ctx, 946 ais2ih_tap_prior_t val); 947 int32_t ais2ih_tap_axis_priority_get(const stmdev_ctx_t *ctx, 948 ais2ih_tap_prior_t *val); 949 950 int32_t ais2ih_tap_threshold_z_set(const stmdev_ctx_t *ctx, uint8_t val); 951 int32_t ais2ih_tap_threshold_z_get(const stmdev_ctx_t *ctx, uint8_t *val); 952 953 int32_t ais2ih_tap_detection_on_z_set(const stmdev_ctx_t *ctx, uint8_t val); 954 int32_t ais2ih_tap_detection_on_z_get(const stmdev_ctx_t *ctx, 955 uint8_t *val); 956 957 int32_t ais2ih_tap_detection_on_y_set(const stmdev_ctx_t *ctx, uint8_t val); 958 int32_t ais2ih_tap_detection_on_y_get(const stmdev_ctx_t *ctx, 959 uint8_t *val); 960 961 int32_t ais2ih_tap_detection_on_x_set(const stmdev_ctx_t *ctx, uint8_t val); 962 int32_t ais2ih_tap_detection_on_x_get(const stmdev_ctx_t *ctx, 963 uint8_t *val); 964 965 int32_t ais2ih_tap_shock_set(const stmdev_ctx_t *ctx, uint8_t val); 966 int32_t ais2ih_tap_shock_get(const stmdev_ctx_t *ctx, uint8_t *val); 967 968 int32_t ais2ih_tap_quiet_set(const stmdev_ctx_t *ctx, uint8_t val); 969 int32_t ais2ih_tap_quiet_get(const stmdev_ctx_t *ctx, uint8_t *val); 970 971 int32_t ais2ih_tap_dur_set(const stmdev_ctx_t *ctx, uint8_t val); 972 int32_t ais2ih_tap_dur_get(const stmdev_ctx_t *ctx, uint8_t *val); 973 974 typedef enum 975 { 976 AIS2IH_ONLY_SINGLE = 0, 977 AIS2IH_BOTH_SINGLE_DOUBLE = 1, 978 } ais2ih_single_double_tap_t; 979 int32_t ais2ih_tap_mode_set(const stmdev_ctx_t *ctx, 980 ais2ih_single_double_tap_t val); 981 int32_t ais2ih_tap_mode_get(const stmdev_ctx_t *ctx, 982 ais2ih_single_double_tap_t *val); 983 984 int32_t ais2ih_tap_src_get(const stmdev_ctx_t *ctx, ais2ih_tap_src_t *val); 985 986 int32_t ais2ih_6d_threshold_set(const stmdev_ctx_t *ctx, uint8_t val); 987 int32_t ais2ih_6d_threshold_get(const stmdev_ctx_t *ctx, uint8_t *val); 988 989 int32_t ais2ih_4d_mode_set(const stmdev_ctx_t *ctx, uint8_t val); 990 int32_t ais2ih_4d_mode_get(const stmdev_ctx_t *ctx, uint8_t *val); 991 992 int32_t ais2ih_6d_src_get(const stmdev_ctx_t *ctx, ais2ih_sixd_src_t *val); 993 994 typedef enum 995 { 996 AIS2IH_ODR_DIV_2_FEED = 0, 997 AIS2IH_LPF2_FEED = 1, 998 } ais2ih_lpass_on6d_t; 999 int32_t ais2ih_6d_feed_data_set(const stmdev_ctx_t *ctx, 1000 ais2ih_lpass_on6d_t val); 1001 int32_t ais2ih_6d_feed_data_get(const stmdev_ctx_t *ctx, 1002 ais2ih_lpass_on6d_t *val); 1003 1004 int32_t ais2ih_ff_dur_set(const stmdev_ctx_t *ctx, uint8_t val); 1005 int32_t ais2ih_ff_dur_get(const stmdev_ctx_t *ctx, uint8_t *val); 1006 1007 typedef enum 1008 { 1009 AIS2IH_FF_TSH_5LSb_FS2g = 0, 1010 AIS2IH_FF_TSH_7LSb_FS2g = 1, 1011 AIS2IH_FF_TSH_8LSb_FS2g = 2, 1012 AIS2IH_FF_TSH_10LSb_FS2g = 3, 1013 AIS2IH_FF_TSH_11LSb_FS2g = 4, 1014 AIS2IH_FF_TSH_13LSb_FS2g = 5, 1015 AIS2IH_FF_TSH_15LSb_FS2g = 6, 1016 AIS2IH_FF_TSH_16LSb_FS2g = 7, 1017 } ais2ih_ff_ths_t; 1018 int32_t ais2ih_ff_threshold_set(const stmdev_ctx_t *ctx, 1019 ais2ih_ff_ths_t val); 1020 int32_t ais2ih_ff_threshold_get(const stmdev_ctx_t *ctx, 1021 ais2ih_ff_ths_t *val); 1022 1023 int32_t ais2ih_fifo_watermark_set(const stmdev_ctx_t *ctx, uint8_t val); 1024 int32_t ais2ih_fifo_watermark_get(const stmdev_ctx_t *ctx, uint8_t *val); 1025 1026 typedef enum 1027 { 1028 AIS2IH_BYPASS_MODE = 0, 1029 AIS2IH_FIFO_MODE = 1, 1030 AIS2IH_STREAM_TO_FIFO_MODE = 3, 1031 AIS2IH_BYPASS_TO_STREAM_MODE = 4, 1032 AIS2IH_STREAM_MODE = 6, 1033 } ais2ih_fmode_t; 1034 int32_t ais2ih_fifo_mode_set(const stmdev_ctx_t *ctx, ais2ih_fmode_t val); 1035 int32_t ais2ih_fifo_mode_get(const stmdev_ctx_t *ctx, ais2ih_fmode_t *val); 1036 1037 int32_t ais2ih_fifo_data_level_get(const stmdev_ctx_t *ctx, uint8_t *val); 1038 1039 int32_t ais2ih_fifo_ovr_flag_get(const stmdev_ctx_t *ctx, uint8_t *val); 1040 1041 int32_t ais2ih_fifo_wtm_flag_get(const stmdev_ctx_t *ctx, uint8_t *val); 1042 1043 /** 1044 * @} 1045 * 1046 */ 1047 1048 #ifdef __cplusplus 1049 } 1050 #endif 1051 1052 #endif /*AIS2IH_REGS_H */ 1053 1054 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 1055