1094332d3Sopenharmony_ci/**
2094332d3Sopenharmony_ci* Copyright (c) 2024 Bosch Sensortec GmbH. All rights reserved.
3094332d3Sopenharmony_ci*
4094332d3Sopenharmony_ci* gyro_bmi270.h as part of the * /chipsets subdirectory
5094332d3Sopenharmony_ci* is dual licensed: you can use it either under the terms of
6094332d3Sopenharmony_ci* the GPL, or the BSD license, at your option.
7094332d3Sopenharmony_ci* See the LICENSE file in the root of this repository for complete details.
8094332d3Sopenharmony_ci*/
9094332d3Sopenharmony_ci
10094332d3Sopenharmony_ci#ifndef GYRO_BMI270_H
11094332d3Sopenharmony_ci#define GYRO_BMI270_H
12094332d3Sopenharmony_ci
13094332d3Sopenharmony_ci#include "sensor_gyro_driver.h"
14094332d3Sopenharmony_ci#include "sensor_config_parser.h"
15094332d3Sopenharmony_ci
16094332d3Sopenharmony_ci#define BMI270_GYR_DATA_FRAME_SIZE      6
17094332d3Sopenharmony_ci#define BMI270_ONE_BYTE                 sizeof(uint8_t)
18094332d3Sopenharmony_ci#define BMI270_TWO_BYTE                 sizeof(uint16_t)
19094332d3Sopenharmony_ci
20094332d3Sopenharmony_ci// bus operation delay
21094332d3Sopenharmony_ci#define BMI270_NORMAL_MODE_WRITE_DELAY_IN_US   4
22094332d3Sopenharmony_ci#define BMI270_LP_MODE_WRITE_DELAY_IN_US       460
23094332d3Sopenharmony_ci
24094332d3Sopenharmony_ci// feature operation delay
25094332d3Sopenharmony_ci#define BMI270_RESET_DELAY_IN_MS               5
26094332d3Sopenharmony_ci#define BMI270_LOAD_RAM_PATCH_DELAY_IN_MS      10
27094332d3Sopenharmony_ci
28094332d3Sopenharmony_ci// bit definition
29094332d3Sopenharmony_ci#define BMI270_GYR_POWER_BIT_POS_IN_PWR_CTRL_REG    1
30094332d3Sopenharmony_ci
31094332d3Sopenharmony_ci
32094332d3Sopenharmony_ci#define BST_GET_VAL_BIT(val, bit)      (((val)>>(bit)) & 0x01)
33094332d3Sopenharmony_ci#define BST_SET_VAL_BIT(val, bit)      ((val) | (1 << (bit)))
34094332d3Sopenharmony_ci#define BST_CLR_VAL_BIT(val, bit)      ((val) & (~(1 << (bit))))
35094332d3Sopenharmony_ci
36094332d3Sopenharmony_ci#define BMI270_GYRO_REGA_STATUS             0x03
37094332d3Sopenharmony_ci/* GYRO DATA REGISTERS ADDR */
38094332d3Sopenharmony_ci#define BMI270_GYRO_REGA_X_LSB_ADDR         0X12
39094332d3Sopenharmony_ci#define BMI270_GYRO_REGA_X_MSB_ADDR         0X13
40094332d3Sopenharmony_ci#define BMI270_GYRO_REGA_Y_LSB_ADDR         0X14
41094332d3Sopenharmony_ci#define BMI270_GYRO_REGA_Y_MSB_ADDR         0X15
42094332d3Sopenharmony_ci#define BMI270_GYRO_REGA_Z_LSB_ADDR         0X16
43094332d3Sopenharmony_ci#define BMI270_GYRO_REGA_Z_MSB_ADDR         0X17
44094332d3Sopenharmony_ci#define BMI270_STATUS_ADDR                  0x1B
45094332d3Sopenharmony_ci
46094332d3Sopenharmony_ci/* GYRO ODR */
47094332d3Sopenharmony_ci#define BMI270_GYRO_ODR_RESERVED            0x00
48094332d3Sopenharmony_ci#define BMI270_GYRO_ODR_25HZ                0x06
49094332d3Sopenharmony_ci#define BMI270_GYRO_ODR_50HZ                0x07
50094332d3Sopenharmony_ci#define BMI270_GYRO_ODR_100HZ               0x08
51094332d3Sopenharmony_ci#define BMI270_GYRO_ODR_200HZ               0x09
52094332d3Sopenharmony_ci#define BMI270_GYRO_ODR_400HZ               0x0A
53094332d3Sopenharmony_ci#define BMI270_GYRO_ODR_800HZ               0x0B
54094332d3Sopenharmony_ci#define BMI270_GYRO_ODR_1600HZ              0x0C
55094332d3Sopenharmony_ci#define BMI270_GYRO_ODR_3200HZ              0x0D
56094332d3Sopenharmony_ci
57094332d3Sopenharmony_ci/* default HZ */
58094332d3Sopenharmony_ci#define BMI270_GYRO_DEFAULT_ODR_100HZ       100
59094332d3Sopenharmony_ci#define BMI270_GYRO_DEFAULT_ODR_25HZ        25
60094332d3Sopenharmony_ci
61094332d3Sopenharmony_ci/* GYRO RANGE */
62094332d3Sopenharmony_ci#define BMI270_GYRO_RANGE_2000DPS           0X00
63094332d3Sopenharmony_ci#define BMI270_GYRO_RANGE_1000DPS           0X01
64094332d3Sopenharmony_ci#define BMI270_GYRO_RANGE_500DPS            0X02
65094332d3Sopenharmony_ci#define BMI270_GYRO_RANGE_250DPS            0X03
66094332d3Sopenharmony_ci#define BMI270_GYRO_RANGE_125DPS            0X04
67094332d3Sopenharmony_ci
68094332d3Sopenharmony_ci/* GYRO sensitivity */
69094332d3Sopenharmony_ci#define BMI270_GYRO_SENSITIVITY_2000DPS     61
70094332d3Sopenharmony_ci
71094332d3Sopenharmony_ci/* GYRO DATA READY */
72094332d3Sopenharmony_ci#define BMI270_GYRO_DATA_READY_MASK         0x40
73094332d3Sopenharmony_ci#define BMI26X_REGV_WHOAMI                  0x24
74094332d3Sopenharmony_ci#define BMI270_REGA_INTERNAL_STATUS         0x21
75094332d3Sopenharmony_ci
76094332d3Sopenharmony_ci#define BMI26X_REGA_GYRO_ODR                0x42
77094332d3Sopenharmony_ci#define BMI26X_REGA_GYRO_RANGE              0x43
78094332d3Sopenharmony_ci
79094332d3Sopenharmony_ci#define BMI26X_REGA_USR_TITAN_CTRL          0x59
80094332d3Sopenharmony_ci#define BMI26X_REGA_USR_CONF_STREAM_IDX_LSB 0x5b
81094332d3Sopenharmony_ci#define BMI26X_REGA_USR_CONF_STREAM_IN      0x5e
82094332d3Sopenharmony_ci
83094332d3Sopenharmony_ci#define BMI270_REGA_PWR_CFG                 0x7C
84094332d3Sopenharmony_ci#define BMI270_REGA_PWR_CTRL                0x7D
85094332d3Sopenharmony_ci#define BMI26X_REGA_USR_CMD                 0x7E
86094332d3Sopenharmony_ci
87094332d3Sopenharmony_ci#define BMI26X_CHECK_CONFIGURE_STATUS_TIMES 15
88094332d3Sopenharmony_ci
89094332d3Sopenharmony_ci#define BMI26X_REGV_CMD_SOFT_RESET          0xB6
90094332d3Sopenharmony_ci
91094332d3Sopenharmony_cistruct Bmi270DrvData {
92094332d3Sopenharmony_ci    struct IDeviceIoService ioService;
93094332d3Sopenharmony_ci    struct HdfDeviceObject *device;
94094332d3Sopenharmony_ci    struct SensorCfgData *sensorCfg;
95094332d3Sopenharmony_ci};
96094332d3Sopenharmony_ci
97094332d3Sopenharmony_ci#endif /* GYRO_BMI270_H */
98