1094332d3Sopenharmony_ci/** 2094332d3Sopenharmony_ci* Copyright (c) 2024 Bosch Sensortec GmbH. All rights reserved. 3094332d3Sopenharmony_ci* 4094332d3Sopenharmony_ci* accel_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 ACC_BMI270_H 11094332d3Sopenharmony_ci#define ACC_BMI270_H 12094332d3Sopenharmony_ci 13094332d3Sopenharmony_ci#include "sensor_accel_driver.h" 14094332d3Sopenharmony_ci#include "sensor_config_parser.h" 15094332d3Sopenharmony_ci 16094332d3Sopenharmony_ci#define BMI270_ACC_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_ACC_POWER_BIT_POS_IN_PWR_CTRL_REG 2 30094332d3Sopenharmony_ci 31094332d3Sopenharmony_ci#define BST_GET_VAL_BIT(val, bit) (((val) >> (bit)) & 0x01) 32094332d3Sopenharmony_ci#define BST_GET_VAL_BITBLOCK(val, start, end) (((val) >> (start)) & ((1 << (end - start + 1))-1)) 33094332d3Sopenharmony_ci 34094332d3Sopenharmony_ci#define BST_SET_VAL_BIT(val, bit) (val | (1 << (bit))) 35094332d3Sopenharmony_ci#define BST_CLR_VAL_BIT(val, bit) (val & (~(1 << (bit)))) 36094332d3Sopenharmony_ci 37094332d3Sopenharmony_ci#define BMI270_ACCEL_REGA_STATUS 0X03 38094332d3Sopenharmony_ci#define BMI270_ACCEL_REGA_X_LSB_ADDR 0X0C 39094332d3Sopenharmony_ci#define BMI270_ACCEL_REGA_X_MSB_ADDR 0X0D 40094332d3Sopenharmony_ci#define BMI270_ACCEL_REGA_Y_LSB_ADDR 0X0E 41094332d3Sopenharmony_ci#define BMI270_ACCEL_REGA_Y_MSB_ADDR 0X0F 42094332d3Sopenharmony_ci#define BMI270_ACCEL_REGA_Z_LSB_ADDR 0X10 43094332d3Sopenharmony_ci#define BMI270_ACCEL_REGA_Z_MSB_ADDR 0X11 44094332d3Sopenharmony_ci#define BMI270_ACCEL_REGA_INT_STATUS 0X1D 45094332d3Sopenharmony_ci 46094332d3Sopenharmony_ci/* ACCEL ODR */ 47094332d3Sopenharmony_ci#define BMI270_ACCEL_REGA_ODR_RESERVED 0x00 48094332d3Sopenharmony_ci#define BMI270_ACCEL_REGA_ODR_0_78HZ 0x01 49094332d3Sopenharmony_ci#define BMI270_ACCEL_REGA_ODR_1_56HZ 0x02 50094332d3Sopenharmony_ci#define BMI270_ACCEL_REGA_ODR_3_12HZ 0x03 51094332d3Sopenharmony_ci#define BMI270_ACCEL_REGA_ODR_6_25HZ 0x04 52094332d3Sopenharmony_ci#define BMI270_ACCEL_REGA_ODR_12_5HZ 0x05 53094332d3Sopenharmony_ci#define BMI270_ACCEL_REGA_ODR_25HZ 0x06 54094332d3Sopenharmony_ci#define BMI270_ACCEL_REGA_ODR_50HZ 0x07 55094332d3Sopenharmony_ci#define BMI270_ACCEL_REGA_ODR_100HZ 0x08 56094332d3Sopenharmony_ci#define BMI270_ACCEL_REGA_ODR_200HZ 0x09 57094332d3Sopenharmony_ci#define BMI270_ACCEL_REGA_ODR_400HZ 0x0A 58094332d3Sopenharmony_ci#define BMI270_ACCEL_REGA_ODR_800HZ 0x0B 59094332d3Sopenharmony_ci#define BMI270_ACCEL_REGA_ODR_1600HZ 0x0C 60094332d3Sopenharmony_ci#define BMI270_ACCEL_REGA_ODR_RESERVED0 0x0D 61094332d3Sopenharmony_ci#define BMI270_ACCEL_REGA_ODR_RESERVED1 0x0E 62094332d3Sopenharmony_ci#define BMI270_ACCEL_REGA_ODR_RESERVED2 0x0F 63094332d3Sopenharmony_ci 64094332d3Sopenharmony_ci 65094332d3Sopenharmony_ci#define BMI270_REGA_INTERNAL_STATUS 0x21 66094332d3Sopenharmony_ci 67094332d3Sopenharmony_ci#define BMI26X_REGA_ACC_ODR 0x40 68094332d3Sopenharmony_ci#define BMI26X_REGA_ACC_RANGE 0x41 69094332d3Sopenharmony_ci#define BMI26X_REGA_USR_ERR_REG_MASK 0x52 70094332d3Sopenharmony_ci#define BMI26X_REGA_USR_INT1_IO_CTRL 0x53 71094332d3Sopenharmony_ci#define BMI26X_REGA_USR_INT2_IO_CTRL 0x54 72094332d3Sopenharmony_ci#define BMI26X_REGA_USR_INT_LATCH 0x55 73094332d3Sopenharmony_ci#define BMI26X_REGA_USR_INT1_MAP 0x56 74094332d3Sopenharmony_ci#define BMI26X_REGA_USR_INT2_MAP 0x57 75094332d3Sopenharmony_ci#define BMI26X_REGA_USR_INT_MAP_HW 0x58 76094332d3Sopenharmony_ci#define BMI26X_REGA_USR_TITAN_CTRL 0x59 77094332d3Sopenharmony_ci#define BMI26X_REGA_USR_CONF_STREAM_IDX_LSB 0x5b 78094332d3Sopenharmony_ci#define BMI26X_REGA_USR_CONF_STREAM_IN 0x5e 79094332d3Sopenharmony_ci#define BMI26X_REGA_USR_INTERNAL_ERROR 0x5f 80094332d3Sopenharmony_ci 81094332d3Sopenharmony_ci#define BMI270_REGA_PWR_CFG 0x7C 82094332d3Sopenharmony_ci#define BMI270_REGA_PWR_CTRL 0x7D 83094332d3Sopenharmony_ci#define BMI26X_REGA_USR_CMD 0x7E 84094332d3Sopenharmony_ci 85094332d3Sopenharmony_ci#define BMI26X_REGV_WHOAMI 0x24 86094332d3Sopenharmony_ci#define BMI26X_REGV_CMD_SOFT_RESET 0xB6 87094332d3Sopenharmony_ci 88094332d3Sopenharmony_ci/* default HZ */ 89094332d3Sopenharmony_ci#define BMI270_ACCEL_DEFAULT_ODR_100HZ 100 /*hw defualt value @0x8*/ 90094332d3Sopenharmony_ci#define BMI270_ACCEL_DEFAULT_ODR_25HZ 25 91094332d3Sopenharmony_ci 92094332d3Sopenharmony_ci#define BMI26X_CHECK_CONFIGURE_STATUS_TIMES 15 93094332d3Sopenharmony_ci#define BMI270_ACCEL_DATA_READY_MASK 0x80 94094332d3Sopenharmony_ci 95094332d3Sopenharmony_ci#define BMI270_ACC_ODR_FILTER_DEFAULT 0xA0 96094332d3Sopenharmony_ci 97094332d3Sopenharmony_ci/* ACC sensitivity */ 98094332d3Sopenharmony_ci#define BMI270_ACC_SENSITIVITY_2G 61 99094332d3Sopenharmony_ci#define BMI270_ACC_SENSITIVITY_4G 122 100094332d3Sopenharmony_ci#define BMI270_ACC_SENSITIVITY_8G 244 101094332d3Sopenharmony_ci#define BMI270_ACC_SENSITIVITY_16G 488 102094332d3Sopenharmony_ci 103094332d3Sopenharmony_cistruct Bmi270DrvData { 104094332d3Sopenharmony_ci struct IDeviceIoService ioService; 105094332d3Sopenharmony_ci struct HdfDeviceObject *device; 106094332d3Sopenharmony_ci struct SensorCfgData *sensorCfg; 107094332d3Sopenharmony_ci}; 108094332d3Sopenharmony_ci 109094332d3Sopenharmony_ci#endif /* ACC_BMI270_H */ 110