-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathbhi3_defs.h
200 lines (166 loc) · 7.36 KB
/
bhi3_defs.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
/**
* Copyright (c) 2023 Bosch Sensortec GmbH. All rights reserved.
*
* BSD-3-Clause
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* @file bhi3_defs.h
* @date 2023-03-24
* @version v1.6.0
*
*/
#ifndef __BHI3_DEFS_H__
#define __BHI3_DEFS_H__
/* Start of CPP Guard */
#ifdef __cplusplus
extern "C" {
#endif /*__cplusplus */
#include "bhy2_defs.h"
/*! The Product ID needs to be replaced with Chip ID for explicit HW specific Identification*/
#define BHI3_PRODUCT_ID BHY2_PRODUCT_ID
/*! Firmware header identifier */
/*#define BHY2_FW_MAGIC UINT16_C(0x662B) */
/*! BHI3 Variant IDs */
#define BHI3_VARIANT_ID_BHI360 UINT32_C(0x18BC5434)
#define BHI3_VARIANT_ID_BHI380 UINT32_C(0x6E6D6CA6)
/*! BHI3 Specifc Sensor IDs */
#define BHI3_SENSOR_ID_AR_WEAR_WU UINT8_C(154) /* Activity Recognition (wear/hear) */
#define BHI3_SENSOR_ID_WRIST_GEST_DETECT_LP_WU UINT8_C(156) /* Wrist Gesture Detector Low Power Wakeup*/
#define BHI3_SENSOR_ID_WRIST_WEAR_LP_WU UINT8_C(158) /* Wrist Wear Low Power Wakeup */
#define BHI3_SENSOR_ID_NO_MOTION_LP_WU UINT8_C(159) /* No motion Low Power */
/*! Physical Sensor Control Parameter Page Base Address*/
#define BHI3_PHY_SENSOR_CTRL_PAGE UINT16_C(0x0E)
/*! Physical Sensor Control pages
* Here the 'id' refers to the Sensor ID of requisite Physical Sensors (Acc/Gyro)
* */
#define BHI3_PHY_SENSOR_CTRL_PARAM(id) (((BHI3_PHY_SENSOR_CTRL_PAGE) << 8) | (id))
#define BHI3_PHY_SENSOR_CTRL_CODE(dir, code) ((dir << 7) | (code))
#define BHI3_PHY_SENSOR_CTRL_WRITE UINT8_C(0x00)
#define BHI3_PHY_SENSOR_CTRL_READ UINT8_C(0x01)
#define BHI3_PHY_ACC_FOC_CTRL_CODE UINT8_C(0x01)
#define BHI3_PHY_ACC_FOC_CTRL_LEN 6
#define BHI3_PHY_ACC_LOW_POWER_MODE_CTRL_CODE UINT8_C(0x05)
#define BHI3_PHY_ACC_NORMAL_POWER_MODE UINT8_C(0x00)
#define BHI3_PHY_ACC_LOW_POWER_MODE UINT8_C(0x02)
#define BHI3_PHY_ACC_LOW_POWER_MODE_CTRL_LEN 1
#define BHI3_PHY_GYRO_FOC_CTRL_CODE UINT8_C(0x01)
#define BHI3_PHY_GYRO_FOC_CTRL_LEN 6
#define BHI3_PHY_GYRO_OIS_CTRL_CODE UINT8_C(0x02)
#define BHI3_PHY_GYRO_DISABLE_OIS UINT8_C(0x00)
#define BHI3_PHY_GYRO_ENABLE_OIS UINT8_C(0x01)
#define BHI3_PHY_GYRO_OIS_CTRL_LEN 1
#define BHI3_PHY_GYRO_FAST_STARTUP_CTRL_CODE UINT8_C(0x03)
#define BHI3_PHY_GYRO_DISABLE_FAST_STARTUP UINT8_C(0x00)
#define BHI3_PHY_GYRO_ENABLE_FAST_STARTUP UINT8_C(0x01)
#define BHI3_PHY_GYRO_FAST_STARTUP_CTRL_LEN 1
#define BHI3_PHY_GYRO_CRT_CTRL_CODE UINT8_C(0x04)
#define BHI3_PHY_GYRO_CRT_STATUS_SUCCESS UINT8_C(0x00)
#define BHI3_PHY_GYRO_ENABLE_CRT UINT8_C(0x01)
#define BHI3_PHY_GYRO_CRT_CTRL_LEN 1
#define BHI3_PHY_GYRO_LOW_POWER_MODE_CTRL_CODE UINT8_C(0x05)
#define BHI3_PHY_GYRO_NORMAL_POWER_MODE UINT8_C(0x00)
#define BHI3_PHY_GYRO_PERFORMANCE_POWER_MODE UINT8_C(0x01)
#define BHI3_PHY_GYRO_LOW_POWER_MODE UINT8_C(0x02)
#define BHI3_PHY_GYRO_LOW_POWER_MODE_CTRL_LEN 1
#define BHI3_PHY_GYRO_TIMER_AUTO_TRIM_CTRL_CODE UINT8_C(0x06)
#define BHI3_PHY_GYRO_DISABLE_TIMER_AUTO_TRIM UINT8_C(0x00)
#define BHI3_PHY_GYRO_ENABLE_TIMER_AUTO_TRIM UINT8_C(0x01)
#define BHI3_PHY_GYRO_TIMER_AUTO_TRIM_CTRL_LEN 1
#define BHI3_PHY_WRIST_WEAR_WAKEUP_CTRL_CODE UINT8_C(0x01)
#define BHI3_PHY_WRIST_WEAR_WAKEUP_CTRL_LEN 10
#define BHI3_PHY_ANY_MOTION_CTRL_CODE UINT8_C(0x01)
#define BHI3_PHY_ANY_MOTION_CTRL_LEN 4
#define BHI3_PHY_NO_MOTION_CTRL_CODE UINT8_C(0x01)
#define BHI3_PHY_NO_MOTION_CTRL_LEN 4
#define BHI3_PHY_WRIST_GESTURE_DETECT_CTRL_CODE UINT8_C(0x07)
#define BHI3_PHY_WRIST_GESTURE_DETECT_CTRL_LEN 19
typedef struct bhi3_wrist_wear_wakeup_config_param
{
uint16_t min_angle_focus;
uint16_t min_angle_nonfocus;
uint8_t angle_landscape_right;
uint8_t angle_landscape_left;
uint8_t angle_portrait_down;
uint8_t angle_portrait_up;
uint8_t min_dur_moved;
uint8_t min_dur_quite;
} __attribute__ ((packed)) bhi3_wrist_wear_wakeup_config_param_t;
typedef struct bhi3_any_no_motion_config_param
{
uint16_t duration;
uint8_t axis;
uint16_t threshold;
} __attribute__ ((packed)) bhi3_any_no_motion_config_param_t;
typedef struct bhi3_wrist_gesture_detect_config_param
{
uint16_t min_flick_peak_y_threshold;
uint16_t min_flick_peak_z_threshold;
uint16_t gravity_bounds_x_pos;
uint16_t gravity_bounds_x_neg;
uint16_t gravity_bounds_y_neg;
uint16_t gravity_bounds_z_neg;
uint16_t flick_peak_decay_coeff;
uint16_t lp_mean_filter_coeff;
uint16_t max_duration_jiggle_peaks;
uint8_t device_position;
} __attribute__ ((packed)) bhi3_wrist_gesture_detect_config_param_t;
enum bhi3_wrist_gesture_activity {
NO_GESTURE,
WRIST_SHAKE_JIGGLE = 0x03,
FLICK_IN,
FLICK_OUT
};
typedef struct bhi3_wrist_gesture_detect
{
enum bhi3_wrist_gesture_activity wrist_gesture;
} __attribute__ ((packed)) bhi3_wrist_gesture_detect_t;
static const char * const bhi3_wrist_gesture_detect_output[] = {
[NO_GESTURE] = "NO_GESTURE", [WRIST_SHAKE_JIGGLE] = "WRIST_SHAKE_JIGGLE", [FLICK_IN] = "FLICK_IN",
[FLICK_OUT] = "FLICK_OUT"
}; /*lint -e528 */
enum bhi3_phy_sensor_acc_power_mode {
ACC_NORMAL,
ACC_LOW_POWER = 0x02
};
enum bhi3_phy_sensor_gyro_power_mode {
GYRO_NORMAL,
GYRO_PERFORMANCE,
GYRO_LOW_POWER
};
static const char * const bhi3_phy_sensor_acc_pwm_output[] = {
[ACC_NORMAL] = "NORMAL", [ACC_LOW_POWER] = "LOW POWER"
}; /*lint -e528 */
static const char * const bhi3_phy_sensor_gyro_pwm_output[] = {
[GYRO_NORMAL] = "NORMAL", [GYRO_PERFORMANCE] = "PERFORMANCE", [GYRO_LOW_POWER] = "LOW POWER"
}; /*lint -e528 */
/* End of CPP Guard */
#ifdef __cplusplus
}
#endif /*__cplusplus */
#endif /* __BHI3_DEFS_H__ */