Updated and Validated
[betaflight.git] / lib / main / BoschSensortec / BMI270-Sensor-API / bmi270_wh.c
blobeda23cc0229ad796e2231c57c65b6dba13acb8d8
1 /**
2 * Copyright (c) 2020 Bosch Sensortec GmbH. All rights reserved.
4 * BSD-3-Clause
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions are met:
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
16 * 3. Neither the name of the copyright holder nor the names of its
17 * contributors may be used to endorse or promote products derived from
18 * this software without specific prior written permission.
20 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
23 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
24 * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
25 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
26 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
27 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
29 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
30 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31 * POSSIBILITY OF SUCH DAMAGE.
33 * @file bmi270_wh.c
34 * @date 2020-11-04
35 * @version v2.63.1
39 /***************************************************************************/
41 /*! Header files
42 ****************************************************************************/
43 #include "bmi270_wh.h"
45 /***************************************************************************/
47 /*! Global Variable
48 ****************************************************************************/
50 /*! @name Global array that stores the configuration file of BMI270_WH */
51 const uint8_t bmi270_wh_config_file[] = {
52 0xc8, 0x2e, 0x00, 0x2e, 0x80, 0x2e, 0xf8, 0x02, 0xc8, 0x2e, 0x00, 0x2e, 0x80, 0x2e, 0xe1, 0x00, 0x80, 0x2e, 0xc0,
53 0x02, 0x80, 0x2e, 0xe2, 0x00, 0xc8, 0x2e, 0x00, 0x2e, 0x80, 0x2e, 0x2c, 0x02, 0x80, 0x2e, 0xe4, 0x07, 0x59, 0xf5,
54 0x10, 0x30, 0x21, 0x2e, 0x6a, 0xf5, 0x80, 0x2e, 0xdd, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3e, 0x31, 0x01, 0x00, 0x22,
55 0x00, 0x80, 0x00, 0xfa, 0x07, 0xff, 0x0f, 0xd1, 0x00, 0x65, 0x9d, 0x80, 0x2e, 0x00, 0xc1, 0x80, 0x2e, 0x00, 0xc1,
56 0x80, 0x2e, 0x00, 0xc1, 0x80, 0x2e, 0x00, 0xc1, 0x80, 0x2e, 0x00, 0xc1, 0x80, 0x2e, 0x00, 0xc1, 0x80, 0x2e, 0x00,
57 0xc1, 0x80, 0x2e, 0x00, 0xc1, 0x80, 0x2e, 0x00, 0xc1, 0x80, 0x2e, 0x00, 0xc1, 0x80, 0x2e, 0x00, 0xc1, 0x80, 0x2e,
58 0x00, 0xc1, 0x80, 0x2e, 0x00, 0xc1, 0x80, 0x2e, 0x00, 0xc1, 0x80, 0x2e, 0x00, 0xc1, 0x80, 0x2e, 0x00, 0xc1, 0x80,
59 0x2e, 0x00, 0xc1, 0x80, 0x2e, 0x00, 0xc1, 0x80, 0x2e, 0x00, 0xc1, 0x80, 0x2e, 0x00, 0xc1, 0x80, 0x2e, 0x00, 0xc1,
60 0x80, 0x2e, 0x00, 0xc1, 0x80, 0x2e, 0x00, 0xc1, 0x80, 0x2e, 0x00, 0xc1, 0x80, 0x2e, 0x00, 0xc1, 0x80, 0x2e, 0x00,
61 0xc1, 0x80, 0x2e, 0x00, 0xc1, 0x80, 0x2e, 0x00, 0xc1, 0x80, 0x2e, 0x00, 0xc1, 0x80, 0x2e, 0x00, 0xc1, 0x80, 0x2e,
62 0x00, 0xc1, 0x80, 0x2e, 0x00, 0xc1, 0x80, 0x2e, 0x00, 0xc1, 0x80, 0x2e, 0x00, 0xc1, 0x80, 0x2e, 0x00, 0xc1, 0x80,
63 0x2e, 0x00, 0xc1, 0x80, 0x2e, 0x00, 0xc1, 0x80, 0x2e, 0x00, 0xc1, 0x80, 0x2e, 0x00, 0xc1, 0x80, 0x2e, 0x00, 0xc1,
64 0x80, 0x2e, 0x00, 0xc1, 0x80, 0x2e, 0x00, 0xc1, 0x80, 0x2e, 0x00, 0xc1, 0x80, 0x2e, 0x00, 0xc1, 0x80, 0x2e, 0x00,
65 0xc1, 0x80, 0x2e, 0x00, 0xc1, 0x80, 0x2e, 0x00, 0xc1, 0xfd, 0x2d, 0x7b, 0xaf, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
66 0x00, 0x00, 0x03, 0x00, 0x18, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x01, 0x12,
67 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
68 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
69 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
70 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
71 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
72 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
73 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
74 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
75 0x00, 0x00, 0x00, 0x00, 0x00, 0x1a, 0x24, 0x22, 0x00, 0x80, 0x2e, 0x8e, 0x01, 0xc8, 0x2e, 0xc8, 0x2e, 0xbb, 0x52,
76 0x00, 0x2e, 0x60, 0x40, 0x41, 0x40, 0x0d, 0xbc, 0x98, 0xbc, 0xc0, 0x2e, 0x01, 0x0a, 0x0f, 0xb8, 0x43, 0x86, 0x25,
77 0x40, 0x04, 0x40, 0xd8, 0xbe, 0x2c, 0x0b, 0x22, 0x11, 0x54, 0x42, 0x03, 0x80, 0x4b, 0x0e, 0xf6, 0x2f, 0xb8, 0x2e,
78 0x80, 0x2e, 0x00, 0xc1, 0x80, 0x2e, 0x00, 0xc1, 0x80, 0x2e, 0x00, 0xc1, 0x80, 0x2e, 0x00, 0xc1, 0xfd, 0x2d, 0x00,
79 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3e, 0x31, 0x00, 0x00,
80 0x88, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0xe0, 0xaa, 0x38, 0x05, 0xe0, 0x90, 0x30, 0x04, 0x00, 0xee,
81 0x06, 0xf2, 0x05, 0x80, 0x80, 0x16, 0xf1, 0x02, 0x02, 0x2d, 0x01, 0xd4, 0x7b, 0x3b, 0x01, 0xdb, 0x7a, 0x04, 0x00,
82 0x3f, 0x7b, 0xcd, 0x6c, 0xc3, 0x04, 0x85, 0x09, 0xc3, 0x04, 0xec, 0xe6, 0x0c, 0x46, 0x01, 0x00, 0x27, 0x00, 0x19,
83 0x00, 0x96, 0x00, 0xa0, 0x00, 0x01, 0x00, 0x0c, 0x00, 0xf0, 0x3c, 0x00, 0x01, 0x01, 0x00, 0x03, 0x00, 0x01, 0x00,
84 0x0e, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
85 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
86 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x92, 0x00, 0x98, 0xf1, 0xaf, 0x00, 0xae, 0x00, 0x1e,
87 0xf2, 0x19, 0xf4, 0x66, 0xf5, 0x00, 0x04, 0xff, 0x00, 0x64, 0xf5, 0x96, 0x00, 0xaa, 0x00, 0x86, 0x00, 0x99, 0x00,
88 0x88, 0x00, 0x8a, 0x00, 0xff, 0x3f, 0xff, 0xfb, 0x31, 0x01, 0x00, 0x38, 0x00, 0x30, 0xfd, 0xf5, 0xb2, 0x00, 0xff,
89 0x03, 0x00, 0xfc, 0xf0, 0x3f, 0x0b, 0x01, 0x0e, 0x01, 0x10, 0x01, 0xb9, 0x00, 0x2d, 0xf5, 0xca, 0xf5, 0xb0, 0x00,
90 0x20, 0xf2, 0xb2, 0x00, 0xff, 0x1f, 0x00, 0x40, 0x80, 0x2e, 0xc0, 0x08, 0x1d, 0x6c, 0xad, 0x00, 0x59, 0x01, 0x31,
91 0xd1, 0xff, 0x7f, 0x00, 0x08, 0xee, 0x7a, 0xe4, 0x0c, 0x12, 0x02, 0xb3, 0x00, 0xb4, 0x04, 0x62, 0x03, 0xc0, 0x02,
92 0x1f, 0xf8, 0xe1, 0x07, 0xd3, 0x07, 0xd7, 0x00, 0xd3, 0x00, 0xb9, 0x00, 0xc3, 0x00, 0xc5, 0x00, 0xbd, 0x00, 0xbc,
93 0x00, 0xbf, 0x00, 0xdd, 0x00, 0x95, 0x00, 0xc2, 0x00, 0xd6, 0x00, 0xf0, 0x00, 0x00, 0xff, 0x00, 0x80, 0x30, 0x50,
94 0x98, 0x2e, 0xc3, 0xb0, 0x02, 0x30, 0x00, 0x30, 0x00, 0x2e, 0x00, 0x2e, 0xd0, 0x2e, 0x01, 0x30, 0x00, 0x2e, 0x41,
95 0x82, 0x48, 0xa2, 0xfb, 0x2f, 0x03, 0x2e, 0x95, 0x00, 0x40, 0xb2, 0x1a, 0x2f, 0x05, 0x2e, 0x0a, 0x01, 0x91, 0x52,
96 0x98, 0x2e, 0xc7, 0xc1, 0x05, 0x2e, 0x18, 0x00, 0x80, 0xb2, 0x02, 0x30, 0x10, 0x2f, 0xf0, 0x7f, 0x00, 0x2e, 0x91,
97 0x50, 0x98, 0x2e, 0x4d, 0xc3, 0x91, 0x50, 0x98, 0x2e, 0x5a, 0xc7, 0x98, 0x2e, 0xbc, 0x03, 0x98, 0x2e, 0x00, 0xb0,
98 0x10, 0x30, 0x21, 0x2e, 0x19, 0x00, 0xf0, 0x6f, 0x02, 0x30, 0x03, 0x2e, 0x85, 0x00, 0x40, 0xb2, 0x40, 0x2f, 0x03,
99 0x2e, 0x85, 0x00, 0x03, 0x31, 0x4b, 0x08, 0x40, 0xb2, 0x07, 0x2f, 0xf0, 0x7f, 0x98, 0x2e, 0x47, 0xcb, 0x10, 0x30,
100 0x21, 0x2e, 0x19, 0x00, 0xf0, 0x6f, 0x02, 0x30, 0x03, 0x2e, 0x85, 0x00, 0x43, 0x30, 0x4b, 0x08, 0x40, 0xb2, 0x2a,
101 0x2f, 0x03, 0x2e, 0x90, 0x00, 0xf0, 0x7f, 0x40, 0xb2, 0x0e, 0x2f, 0x41, 0x90, 0x20, 0x2f, 0x05, 0x2e, 0x3f, 0x01,
102 0x07, 0x2e, 0x91, 0x00, 0xa1, 0x32, 0x95, 0x58, 0x98, 0x2e, 0x97, 0xb3, 0x02, 0x30, 0x25, 0x2e, 0x90, 0x00, 0x15,
103 0x2c, 0xf0, 0x6f, 0x93, 0x58, 0xa3, 0x32, 0x10, 0x41, 0x11, 0x41, 0x18, 0xb9, 0x04, 0x41, 0x98, 0xbc, 0x41, 0x0a,
104 0x94, 0x0a, 0x98, 0x2e, 0xf1, 0x03, 0x12, 0x30, 0x21, 0x2e, 0x91, 0x00, 0x21, 0x2e, 0xaf, 0x00, 0x25, 0x2e, 0x90,
105 0x00, 0xf0, 0x6f, 0x02, 0x30, 0x11, 0x30, 0x23, 0x2e, 0x19, 0x00, 0x25, 0x2e, 0x85, 0x00, 0x03, 0x2e, 0x19, 0x00,
106 0x40, 0xb2, 0x22, 0x2f, 0xf0, 0x7f, 0x98, 0x2e, 0xf5, 0xcb, 0x97, 0x54, 0xbc, 0x84, 0x21, 0x2e, 0xae, 0x00, 0x81,
107 0x40, 0x82, 0x86, 0x99, 0x54, 0x18, 0xb8, 0xc3, 0x40, 0x91, 0x42, 0x90, 0x42, 0x33, 0xbc, 0x90, 0x42, 0xe2, 0x7f,
108 0xf0, 0x31, 0x82, 0x40, 0x10, 0x08, 0xf2, 0x6f, 0x25, 0xbd, 0x02, 0x0a, 0xd0, 0x7f, 0x98, 0x2e, 0xa8, 0xcf, 0x06,
109 0xbc, 0xd2, 0x6f, 0xe1, 0x6f, 0x10, 0x0a, 0x40, 0x42, 0x98, 0x2e, 0x2c, 0x03, 0xf0, 0x6f, 0x02, 0x30, 0x25, 0x2e,
110 0x19, 0x00, 0x25, 0x2e, 0x95, 0x00, 0x80, 0x2e, 0x93, 0x01, 0x90, 0x50, 0xf7, 0x7f, 0xe6, 0x7f, 0xd5, 0x7f, 0xc4,
111 0x7f, 0xb3, 0x7f, 0xa1, 0x7f, 0x90, 0x7f, 0x82, 0x7f, 0x7b, 0x7f, 0x98, 0x2e, 0xe3, 0x00, 0x00, 0xb2, 0x65, 0x2f,
112 0x05, 0x2e, 0x31, 0x01, 0x01, 0x2e, 0x11, 0x01, 0x03, 0x2e, 0x0f, 0x01, 0x8f, 0xb9, 0x23, 0xbe, 0x9f, 0xb8, 0xcb,
113 0x0a, 0x24, 0xbc, 0x4f, 0xba, 0x03, 0x2e, 0x12, 0x01, 0x0f, 0xb8, 0x22, 0xbd, 0xdc, 0x0a, 0x2f, 0xb9, 0x9b, 0xbc,
114 0x18, 0x0a, 0x9f, 0xb8, 0x82, 0x0a, 0x91, 0x0a, 0x25, 0x2e, 0x18, 0x00, 0x05, 0x2e, 0xc1, 0xf5, 0x2e, 0xbd, 0x2e,
115 0xb9, 0x01, 0x2e, 0x18, 0x00, 0x31, 0x30, 0x8a, 0x04, 0x00, 0x90, 0x03, 0x2f, 0x01, 0x2e, 0x83, 0x00, 0x00, 0xb2,
116 0x19, 0x2f, 0x9b, 0x50, 0x91, 0x52, 0x98, 0x2e, 0xec, 0x00, 0x05, 0x2e, 0x82, 0x00, 0x25, 0x2e, 0x95, 0x00, 0x05,
117 0x2e, 0x82, 0x00, 0x80, 0x90, 0x02, 0x2f, 0x12, 0x30, 0x25, 0x2e, 0x82, 0x00, 0x01, 0x2e, 0x83, 0x00, 0x00, 0xb2,
118 0x10, 0x30, 0x05, 0x2e, 0x18, 0x00, 0x01, 0x2f, 0x21, 0x2e, 0x18, 0x00, 0x25, 0x2e, 0x83, 0x00, 0x05, 0x2e, 0x18,
119 0x00, 0x80, 0xb2, 0x20, 0x2f, 0x01, 0x2e, 0xc0, 0xf5, 0xf2, 0x30, 0x02, 0x08, 0x07, 0xaa, 0x73, 0x30, 0x03, 0x2e,
120 0x84, 0x00, 0x18, 0x22, 0x41, 0x1a, 0x05, 0x2f, 0x03, 0x2e, 0x66, 0xf5, 0x9f, 0xbc, 0x9f, 0xb8, 0x40, 0x90, 0x0c,
121 0x2f, 0x9d, 0x52, 0x03, 0x30, 0x53, 0x42, 0x2b, 0x30, 0x90, 0x04, 0x5b, 0x42, 0x21, 0x2e, 0x84, 0x00, 0x24, 0xbd,
122 0x7e, 0x80, 0x81, 0x84, 0x43, 0x42, 0x02, 0x42, 0x02, 0x32, 0x25, 0x2e, 0x62, 0xf5, 0x9f, 0x52, 0x05, 0x2e, 0x0a,
123 0x01, 0x91, 0x08, 0x00, 0x31, 0x21, 0x2e, 0x60, 0xf5, 0x80, 0xb2, 0x0b, 0x2f, 0xf2, 0x3e, 0x01, 0x2e, 0xca, 0xf5,
124 0x82, 0x08, 0x25, 0x2e, 0xca, 0xf5, 0x05, 0x2e, 0x59, 0xf5, 0xe0, 0x3f, 0x90, 0x08, 0x25, 0x2e, 0x59, 0xf5, 0xa1,
125 0x6f, 0xb3, 0x6f, 0xc4, 0x6f, 0xd5, 0x6f, 0xe6, 0x6f, 0xf7, 0x6f, 0x7b, 0x6f, 0x82, 0x6f, 0x90, 0x6f, 0x70, 0x5f,
126 0xc8, 0x2e, 0xa0, 0x50, 0x80, 0x7f, 0xe7, 0x7f, 0xd5, 0x7f, 0xc4, 0x7f, 0xb3, 0x7f, 0xa2, 0x7f, 0x91, 0x7f, 0xf6,
127 0x7f, 0x7b, 0x7f, 0x00, 0x2e, 0x01, 0x2e, 0x60, 0xf5, 0x60, 0x7f, 0x98, 0x2e, 0xe3, 0x00, 0x62, 0x6f, 0x01, 0x32,
128 0x91, 0x08, 0x80, 0xb2, 0x0d, 0x2f, 0x00, 0xb2, 0x03, 0x2f, 0x05, 0x2e, 0x18, 0x00, 0x80, 0x90, 0x05, 0x2f, 0xa3,
129 0x56, 0x02, 0x30, 0xc1, 0x42, 0xc2, 0x86, 0x00, 0x2e, 0xc2, 0x42, 0x23, 0x2e, 0x60, 0xf5, 0x00, 0x90, 0x00, 0x30,
130 0x06, 0x2f, 0x21, 0x2e, 0x82, 0x00, 0xa1, 0x50, 0x21, 0x2e, 0x5a, 0xf2, 0x98, 0x2e, 0x3d, 0x03, 0xf6, 0x6f, 0x80,
131 0x6f, 0x91, 0x6f, 0xa2, 0x6f, 0xb3, 0x6f, 0xc4, 0x6f, 0xd5, 0x6f, 0xe7, 0x6f, 0x7b, 0x6f, 0x60, 0x5f, 0xc8, 0x2e,
132 0xc0, 0x50, 0xe7, 0x7f, 0xf6, 0x7f, 0x26, 0x30, 0x0f, 0x2e, 0x61, 0xf5, 0x2f, 0x2e, 0x85, 0x00, 0x0f, 0x2e, 0x85,
133 0x00, 0xbe, 0x09, 0xd5, 0x7f, 0xc4, 0x7f, 0xb3, 0x7f, 0xa2, 0x7f, 0x90, 0x7f, 0x7b, 0x7f, 0x80, 0xb3, 0x81, 0x7f,
134 0x11, 0x2f, 0xa5, 0x50, 0x1a, 0x25, 0x12, 0x40, 0x42, 0x7f, 0x74, 0x82, 0x12, 0x40, 0x52, 0x7f, 0x00, 0x2e, 0x00,
135 0x40, 0x60, 0x7f, 0x98, 0x2e, 0x6a, 0xd6, 0x03, 0x2e, 0x61, 0xf7, 0x00, 0x31, 0x48, 0x0a, 0x23, 0x2e, 0x61, 0xf7,
136 0xe1, 0x31, 0x23, 0x2e, 0x61, 0xf5, 0xf6, 0x6f, 0xe7, 0x6f, 0x81, 0x6f, 0x90, 0x6f, 0xa2, 0x6f, 0xb3, 0x6f, 0xc4,
137 0x6f, 0xd5, 0x6f, 0x7b, 0x6f, 0x40, 0x5f, 0xc8, 0x2e, 0xa7, 0x50, 0x10, 0x50, 0xbd, 0x52, 0x05, 0x2e, 0x8d, 0x00,
138 0xfb, 0x7f, 0x00, 0x2e, 0x13, 0x40, 0x93, 0x42, 0x41, 0x0e, 0xfb, 0x2f, 0x98, 0x2e, 0x91, 0x03, 0xfb, 0x6f, 0xf0,
139 0x5f, 0x80, 0x2e, 0x87, 0xcf, 0x10, 0x50, 0xfb, 0x7f, 0x98, 0x2e, 0x56, 0xc7, 0x98, 0x2e, 0x49, 0xc3, 0x11, 0x30,
140 0x30, 0x30, 0xfb, 0x6f, 0xf0, 0x5f, 0x23, 0x2e, 0x8f, 0x00, 0x21, 0x2e, 0x86, 0x00, 0x23, 0x2e, 0x19, 0x00, 0x21,
141 0x2e, 0xac, 0x00, 0xb8, 0x2e, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x9a, 0x01,
142 0x34, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
143 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
144 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
145 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
146 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
147 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
148 0x00, 0x00, 0x03, 0x2e, 0x8d, 0x00, 0x16, 0xb8, 0x02, 0x34, 0x4a, 0x0c, 0x21, 0x2e, 0x2d, 0xf5, 0xc0, 0x2e, 0x23,
149 0x2e, 0x8d, 0x00, 0x40, 0x50, 0xf1, 0x7f, 0x0a, 0x25, 0x3c, 0x86, 0xeb, 0x7f, 0x41, 0x33, 0x22, 0x30, 0x98, 0x2e,
150 0xc2, 0xc4, 0xd3, 0x6f, 0xf4, 0x30, 0xdc, 0x09, 0xc1, 0x58, 0xc2, 0x6f, 0x94, 0x09, 0xc3, 0x58, 0x6a, 0xbb, 0xdc,
151 0x08, 0xb4, 0xb9, 0xb1, 0xbd, 0xbf, 0x5a, 0x95, 0x08, 0x21, 0xbd, 0xf6, 0xbf, 0x77, 0x0b, 0x51, 0xbe, 0xf1, 0x6f,
152 0xeb, 0x6f, 0x52, 0x42, 0x54, 0x42, 0xc0, 0x2e, 0x43, 0x42, 0xc0, 0x5f, 0x03, 0x2e, 0x12, 0x01, 0x00, 0x31, 0x08,
153 0x08, 0xf2, 0x30, 0x20, 0x50, 0x4a, 0x08, 0xe1, 0x7f, 0x00, 0xb2, 0xfb, 0x7f, 0x01, 0x30, 0x15, 0x2f, 0x01, 0x2e,
154 0x8f, 0x00, 0x01, 0x90, 0x03, 0x2f, 0x23, 0x2e, 0x8f, 0x00, 0x98, 0x2e, 0xe7, 0x03, 0x98, 0x2e, 0xa8, 0xcf, 0x11,
155 0x30, 0x41, 0x08, 0x23, 0x2e, 0xd5, 0x00, 0x98, 0x2e, 0x41, 0xb1, 0x10, 0x25, 0xfb, 0x6f, 0xe0, 0x6f, 0xe0, 0x5f,
156 0x80, 0x2e, 0x95, 0xcf, 0xe0, 0x6f, 0x98, 0x2e, 0x95, 0xcf, 0x11, 0x30, 0x23, 0x2e, 0x8f, 0x00, 0xfb, 0x6f, 0xe0,
157 0x5f, 0xb8, 0x2e, 0xd5, 0x50, 0x01, 0x30, 0x0f, 0x55, 0x11, 0x42, 0x42, 0x0e, 0xfc, 0x2f, 0x10, 0x30, 0xc0, 0x2e,
158 0x21, 0x2e, 0xbc, 0x00, 0x40, 0x50, 0x0a, 0x25, 0x3c, 0x80, 0xfb, 0x7f, 0x01, 0x42, 0xd2, 0x7f, 0xe3, 0x7f, 0x32,
159 0x30, 0x10, 0x25, 0x98, 0x2e, 0x7a, 0xc1, 0xfb, 0x6f, 0xc0, 0x5f, 0xb8, 0x2e, 0x44, 0x47, 0xb5, 0x50, 0xf0, 0x50,
160 0x12, 0x40, 0x06, 0x40, 0x1a, 0x25, 0x6c, 0xbe, 0x76, 0x8a, 0x74, 0x80, 0xfb, 0x7f, 0x68, 0xbf, 0xb7, 0x56, 0x0b,
161 0x30, 0xd3, 0x08, 0x4c, 0xba, 0x6c, 0xbb, 0x5b, 0x7f, 0x4b, 0x43, 0x0b, 0x42, 0xc0, 0xb2, 0xc6, 0x7f, 0xb4, 0x7f,
162 0xd0, 0x7f, 0xe5, 0x7f, 0xa3, 0x7f, 0x90, 0x2e, 0xaf, 0xb0, 0x01, 0x2e, 0x8c, 0x00, 0x00, 0xb2, 0x0b, 0x2f, 0xab,
163 0x52, 0x01, 0x2e, 0x87, 0x00, 0x92, 0x7f, 0x98, 0x2e, 0xbb, 0xcc, 0x01, 0x30, 0x23, 0x2e, 0x8c, 0x00, 0x92, 0x6f,
164 0xa3, 0x6f, 0x1a, 0x25, 0x26, 0xbc, 0x86, 0xba, 0x25, 0xbc, 0x0f, 0xb8, 0x54, 0xb1, 0x00, 0xb2, 0x96, 0x7f, 0x0c,
165 0x2f, 0xad, 0x50, 0xaf, 0x54, 0x0b, 0x30, 0x0b, 0x2e, 0x31, 0x01, 0xb3, 0x58, 0x1b, 0x42, 0x9b, 0x42, 0x6c, 0x09,
166 0x0b, 0x42, 0x2b, 0x2e, 0x31, 0x01, 0x8b, 0x42, 0x71, 0x84, 0xb9, 0x50, 0x58, 0x09, 0xb1, 0x52, 0x91, 0x50, 0x82,
167 0x7f, 0x75, 0x7f, 0x98, 0x2e, 0xc2, 0xc0, 0x01, 0x2e, 0x87, 0x00, 0xe5, 0x6f, 0xd4, 0x6f, 0x73, 0x6f, 0x82, 0x6f,
168 0xab, 0x52, 0xa9, 0x5c, 0x98, 0x2e, 0x06, 0xcd, 0x65, 0x6f, 0xa0, 0x6f, 0xad, 0x52, 0x40, 0xb3, 0x04, 0xbd, 0x53,
169 0x40, 0xaf, 0xba, 0x44, 0x40, 0xe1, 0x7f, 0x02, 0x30, 0x06, 0x2f, 0x40, 0xb3, 0x02, 0x30, 0x03, 0x2f, 0xaf, 0x5c,
170 0x12, 0x30, 0x93, 0x43, 0x84, 0x43, 0x03, 0xbf, 0x6f, 0xbb, 0x80, 0xb3, 0x20, 0x2f, 0x46, 0x6f, 0xde, 0x00, 0x56,
171 0x6f, 0x26, 0x03, 0x44, 0x42, 0x40, 0x91, 0x27, 0x2e, 0x88, 0x00, 0xaf, 0x52, 0x14, 0x2f, 0xaf, 0x5c, 0x00, 0x2e,
172 0x95, 0x41, 0x86, 0x41, 0x5d, 0x05, 0xa6, 0x07, 0x80, 0xab, 0x04, 0x2f, 0x80, 0x91, 0x0a, 0x2f, 0x96, 0x6f, 0x75,
173 0x0f, 0x07, 0x2f, 0x95, 0x6f, 0x40, 0xb3, 0x04, 0x2f, 0x53, 0x42, 0x44, 0x42, 0x12, 0x30, 0x04, 0x2c, 0x11, 0x30,
174 0x02, 0x2c, 0x11, 0x30, 0x11, 0x30, 0x02, 0xbc, 0x0f, 0xb8, 0xd2, 0x7f, 0x00, 0x90, 0x06, 0x2f, 0x31, 0x30, 0x23,
175 0x2e, 0xac, 0x00, 0x23, 0x2e, 0x86, 0x00, 0x0b, 0x2c, 0x01, 0x30, 0x01, 0x2e, 0x86, 0x00, 0x05, 0x2e, 0xac, 0x00,
176 0x10, 0x1a, 0x02, 0x2f, 0x21, 0x2e, 0xac, 0x00, 0x01, 0x2d, 0x01, 0x30, 0xc0, 0x6f, 0x98, 0x2e, 0x95, 0xcf, 0xd1,
177 0x6f, 0xb0, 0x6f, 0x98, 0x2e, 0x95, 0xcf, 0xe2, 0x6f, 0xa7, 0x52, 0x01, 0x2e, 0x88, 0x00, 0x82, 0x40, 0x50, 0x42,
178 0x11, 0x2c, 0x42, 0x42, 0x10, 0x30, 0x31, 0x30, 0x21, 0x2e, 0x8c, 0x00, 0x23, 0x2e, 0xac, 0x00, 0x23, 0x2e, 0x86,
179 0x00, 0xc0, 0x6f, 0x01, 0x30, 0x98, 0x2e, 0x95, 0xcf, 0xb0, 0x6f, 0x01, 0x30, 0x98, 0x2e, 0x95, 0xcf, 0x00, 0x2e,
180 0xfb, 0x6f, 0x10, 0x5f, 0xb8, 0x2e, 0x50, 0x50, 0xcd, 0x50, 0x51, 0x30, 0x11, 0x42, 0xfb, 0x7f, 0x7b, 0x30, 0x0b,
181 0x42, 0x11, 0x30, 0x02, 0x80, 0x23, 0x33, 0x01, 0x42, 0x03, 0x00, 0x07, 0x2e, 0x80, 0x03, 0x05, 0x2e, 0x8d, 0x00,
182 0xa5, 0x52, 0xe2, 0x7f, 0xd3, 0x7f, 0xc0, 0x7f, 0x98, 0x2e, 0x9b, 0x03, 0xd1, 0x6f, 0x08, 0x0a, 0x1a, 0x25, 0x7b,
183 0x86, 0xd0, 0x7f, 0x01, 0x33, 0x12, 0x30, 0x98, 0x2e, 0xc2, 0xc4, 0xd1, 0x6f, 0x08, 0x0a, 0x00, 0xb2, 0x0d, 0x2f,
184 0xe3, 0x6f, 0x01, 0x2e, 0x80, 0x03, 0x51, 0x30, 0xc7, 0x86, 0x23, 0x2e, 0x21, 0xf2, 0x08, 0xbc, 0xc0, 0x42, 0x98,
185 0x2e, 0x91, 0x03, 0x00, 0x2e, 0x00, 0x2e, 0xd0, 0x2e, 0xb0, 0x6f, 0x0b, 0xb8, 0x03, 0x2e, 0x1b, 0x00, 0x08, 0x1a,
186 0xb0, 0x7f, 0x70, 0x30, 0x04, 0x2f, 0x21, 0x2e, 0x21, 0xf2, 0x00, 0x2e, 0x00, 0x2e, 0xd0, 0x2e, 0x98, 0x2e, 0x6d,
187 0xc0, 0x98, 0x2e, 0x5d, 0xc0, 0xc5, 0x50, 0x98, 0x2e, 0x44, 0xcb, 0xc7, 0x50, 0x98, 0x2e, 0x46, 0xc3, 0xc9, 0x50,
188 0x98, 0x2e, 0x53, 0xc7, 0x20, 0x26, 0xc0, 0x6f, 0x02, 0x31, 0x12, 0x42, 0x6b, 0x31, 0x0b, 0x42, 0x37, 0x80, 0x0b,
189 0x30, 0x0b, 0x42, 0xf3, 0x37, 0xcf, 0x52, 0xd3, 0x50, 0x44, 0x40, 0xa2, 0x0a, 0x42, 0x42, 0x8b, 0x31, 0x09, 0x2e,
190 0x5e, 0xf7, 0xd1, 0x54, 0xe3, 0x08, 0x83, 0x42, 0x1b, 0x42, 0x23, 0x33, 0x4b, 0x00, 0xbc, 0x84, 0x0b, 0x40, 0x33,
191 0x30, 0x83, 0x42, 0x0b, 0x42, 0xe0, 0x7f, 0xd1, 0x7f, 0x98, 0x2e, 0x2c, 0x03, 0xd1, 0x6f, 0x80, 0x30, 0x40, 0x42,
192 0x03, 0x30, 0xe0, 0x6f, 0xcb, 0x54, 0x04, 0x30, 0x00, 0x2e, 0x00, 0x2e, 0x01, 0x89, 0x62, 0x0e, 0xfa, 0x2f, 0x43,
193 0x42, 0x11, 0x30, 0xfb, 0x6f, 0xc0, 0x2e, 0x01, 0x42, 0xb0, 0x5f, 0x50, 0x51, 0x91, 0x54, 0xeb, 0x7f, 0x11, 0x30,
194 0x0a, 0x25, 0xff, 0x56, 0x11, 0x5d, 0x95, 0x40, 0xc4, 0x40, 0x25, 0x01, 0xd4, 0x42, 0x4d, 0x17, 0xc4, 0x40, 0x65,
195 0x03, 0xd5, 0x42, 0x56, 0x0e, 0xf5, 0x2f, 0x15, 0x57, 0x02, 0x30, 0xc6, 0x40, 0xb1, 0x29, 0xe6, 0x42, 0x00, 0x2e,
196 0xc3, 0x40, 0xc0, 0xb2, 0x0a, 0x23, 0x4c, 0x14, 0x71, 0x0e, 0xd4, 0x7f, 0x90, 0x2e, 0x93, 0xb3, 0x03, 0x31, 0xe1,
197 0x52, 0xe3, 0x54, 0x5c, 0x05, 0x8a, 0x28, 0x2b, 0x82, 0x03, 0x57, 0xdd, 0x5e, 0x2e, 0x80, 0xde, 0x8c, 0x30, 0x89,
198 0xff, 0x29, 0x96, 0x7f, 0x60, 0x7f, 0xc5, 0x7f, 0xb3, 0x7f, 0xa4, 0x7f, 0x82, 0x7f, 0x77, 0x7f, 0x51, 0x7f, 0x00,
199 0x2e, 0x90, 0x41, 0x92, 0x41, 0xd3, 0x6f, 0xc0, 0xb2, 0x46, 0x7f, 0x31, 0x7f, 0x08, 0x2f, 0xd0, 0xa0, 0x02, 0x2f,
200 0xa0, 0x6f, 0x05, 0x2c, 0x10, 0x10, 0xc6, 0x6f, 0x96, 0x14, 0x03, 0x12, 0x02, 0x0a, 0x05, 0x2e, 0xd3, 0x00, 0x80,
201 0x90, 0xd7, 0x54, 0x40, 0x42, 0x4a, 0x2f, 0x41, 0x40, 0x98, 0x2e, 0xd9, 0xc0, 0xdb, 0x54, 0xd9, 0x52, 0x20, 0x7f,
202 0x98, 0x2e, 0xfe, 0xc9, 0x72, 0x6f, 0x10, 0x25, 0x98, 0x2e, 0xfe, 0xc9, 0x22, 0x6f, 0xe3, 0x30, 0x10, 0x25, 0x98,
203 0x2e, 0x0f, 0xca, 0x91, 0x6f, 0x76, 0x86, 0xd9, 0x52, 0xdd, 0x54, 0xd0, 0x42, 0x93, 0x7f, 0x98, 0x2e, 0xfe, 0xc9,
204 0x22, 0x6f, 0xe3, 0x30, 0x10, 0x25, 0x98, 0x2e, 0x0f, 0xca, 0x91, 0x6f, 0xdf, 0x54, 0x40, 0x42, 0x79, 0x80, 0xd9,
205 0x52, 0x90, 0x7f, 0x98, 0x2e, 0xfe, 0xc9, 0x82, 0x6f, 0x10, 0x25, 0x98, 0x2e, 0xfe, 0xc9, 0x22, 0x6f, 0xe3, 0x30,
206 0x10, 0x25, 0x98, 0x2e, 0x0f, 0xca, 0x93, 0x6f, 0xe1, 0x54, 0xd9, 0x52, 0xd0, 0x42, 0x13, 0x7f, 0x98, 0x2e, 0xfe,
207 0xc9, 0x22, 0x6f, 0xe3, 0x30, 0x10, 0x25, 0x98, 0x2e, 0x0f, 0xca, 0x13, 0x6f, 0xe5, 0x5e, 0xc0, 0x42, 0xf7, 0x7f,
208 0x00, 0x2e, 0x22, 0x6f, 0x91, 0x6f, 0xe1, 0x5a, 0xe3, 0x58, 0xdf, 0x5c, 0xe1, 0x56, 0x98, 0x2e, 0x67, 0xcc, 0xb1,
209 0x6f, 0x02, 0x2c, 0x40, 0x42, 0xb1, 0x6f, 0x41, 0x80, 0x32, 0x6f, 0x81, 0x82, 0x62, 0x6f, 0x46, 0x6f, 0x96, 0x7f,
210 0x4a, 0x0e, 0xb0, 0x7f, 0x94, 0x2f, 0xf1, 0x3d, 0x01, 0x55, 0x10, 0x30, 0x53, 0x6f, 0x91, 0x00, 0x21, 0x2e, 0xd3,
211 0x00, 0x66, 0x6f, 0xd1, 0x40, 0x80, 0x40, 0x01, 0x00, 0x90, 0x42, 0x09, 0x16, 0x85, 0x40, 0x28, 0x02, 0x80, 0x42,
212 0x9a, 0x80, 0xd7, 0x54, 0xd6, 0x7f, 0xc3, 0x7f, 0xb0, 0x7f, 0x98, 0x2e, 0xd9, 0xc0, 0x05, 0x30, 0xf5, 0x7f, 0x20,
213 0x25, 0xb1, 0x6f, 0xdd, 0x58, 0xdb, 0x5c, 0xdd, 0x56, 0x98, 0x2e, 0x67, 0xcc, 0xd6, 0x6f, 0xc3, 0x6f, 0xb2, 0x6f,
214 0x61, 0x6f, 0xa7, 0x84, 0x90, 0x43, 0x59, 0x0e, 0xdf, 0x2f, 0x10, 0x30, 0x81, 0x40, 0x08, 0x28, 0x90, 0x42, 0xd2,
215 0x7f, 0x02, 0xa0, 0x27, 0x2f, 0xd5, 0x54, 0x03, 0x53, 0x03, 0x30, 0x96, 0x40, 0x80, 0x40, 0x08, 0x17, 0x15, 0x30,
216 0x65, 0x09, 0xb5, 0x01, 0xc3, 0x02, 0x61, 0xb8, 0x94, 0x8c, 0xb6, 0x7f, 0xbf, 0xbd, 0xd7, 0x54, 0xc1, 0x7f, 0x43,
217 0x0a, 0x98, 0x2e, 0xd9, 0xc0, 0xe5, 0x54, 0xf2, 0x7f, 0x20, 0x25, 0xb1, 0x6f, 0xe1, 0x5a, 0xe3, 0x58, 0xdf, 0x5c,
218 0xe1, 0x56, 0x98, 0x2e, 0x67, 0xcc, 0xb2, 0x6f, 0x03, 0x30, 0xc1, 0x6f, 0xab, 0x84, 0x0b, 0x5d, 0x93, 0x42, 0x50,
219 0x42, 0x4e, 0x0e, 0x93, 0x42, 0xdb, 0x2f, 0x83, 0x42, 0x00, 0x2e, 0xd1, 0x6f, 0x98, 0x2e, 0xb3, 0xc0, 0x61, 0x6f,
220 0xc0, 0x7f, 0x98, 0x2e, 0xb3, 0xc0, 0x51, 0x6f, 0xb0, 0x7f, 0x98, 0x2e, 0xb3, 0xc0, 0x00, 0xa0, 0xe7, 0x52, 0x08,
221 0x22, 0xb2, 0x6f, 0xc1, 0x6f, 0xa0, 0x7f, 0xb3, 0x30, 0x98, 0x2e, 0x0f, 0xca, 0xb2, 0x6f, 0xb0, 0x7f, 0xb3, 0x30,
222 0xe9, 0x52, 0x98, 0x2e, 0x5a, 0xca, 0xd6, 0x6f, 0x02, 0x30, 0x61, 0x6f, 0xd2, 0x7f, 0x90, 0x7f, 0x81, 0x7f, 0xb3,
223 0x30, 0x42, 0x40, 0x91, 0x41, 0x76, 0x7f, 0x98, 0x2e, 0x0f, 0xca, 0xd2, 0x6f, 0x81, 0x6f, 0x10, 0x28, 0x41, 0x40,
224 0x92, 0x6f, 0xd0, 0x7f, 0xb3, 0x30, 0x98, 0x2e, 0x0f, 0xca, 0x81, 0x6f, 0x76, 0x6f, 0x0b, 0x55, 0x50, 0x42, 0x72,
225 0x0e, 0xe9, 0x2f, 0xc2, 0x6f, 0xa1, 0x6f, 0x98, 0x2e, 0xfe, 0xc9, 0x10, 0x25, 0xb3, 0x30, 0x21, 0x25, 0x98, 0x2e,
226 0x0f, 0xca, 0x20, 0x25, 0x13, 0x51, 0xeb, 0x52, 0x98, 0x2e, 0xcb, 0xb3, 0xc5, 0x6f, 0x13, 0x51, 0xed, 0x5c, 0x12,
227 0x40, 0x75, 0x05, 0x31, 0x30, 0x11, 0x86, 0x05, 0x5d, 0xc1, 0x7f, 0x15, 0x0f, 0x00, 0x40, 0x08, 0x2f, 0x3f, 0x80,
228 0x00, 0xa8, 0x21, 0x2e, 0xc3, 0x00, 0x00, 0x30, 0x0a, 0x2f, 0x90, 0x43, 0x09, 0x2c, 0x80, 0x43, 0x01, 0x80, 0x03,
229 0xa0, 0x21, 0x2e, 0xc3, 0x00, 0x10, 0x30, 0x01, 0x2f, 0x91, 0x43, 0x80, 0x43, 0x00, 0x2e, 0xef, 0x54, 0x00, 0x6f,
230 0x82, 0x0f, 0x03, 0x2f, 0xf0, 0x6e, 0xf1, 0x54, 0x02, 0x0f, 0x14, 0x2f, 0xe1, 0x6e, 0xc3, 0x7f, 0x98, 0x2e, 0x74,
231 0xc0, 0xc3, 0x6f, 0xf3, 0x54, 0x01, 0x30, 0xc1, 0x7f, 0xc2, 0x0f, 0x0a, 0x2f, 0xf0, 0x6e, 0xf5, 0x52, 0x81, 0x0e,
232 0x11, 0x30, 0x04, 0x2f, 0x00, 0x6f, 0x00, 0xa4, 0x11, 0x30, 0x00, 0x2f, 0x21, 0x30, 0xc1, 0x7f, 0xf1, 0x80, 0xc2,
233 0x40, 0x80, 0x90, 0x07, 0x2f, 0x07, 0x55, 0xb8, 0x86, 0x12, 0x30, 0xc1, 0x42, 0xd7, 0x86, 0x23, 0x2e, 0xc5, 0x00,
234 0xc2, 0x42, 0x38, 0x8a, 0x02, 0x40, 0x0a, 0x1a, 0x07, 0x55, 0x00, 0x30, 0x02, 0x2f, 0x91, 0x42, 0x0e, 0x2c, 0x80,
235 0x42, 0x03, 0x2e, 0xc6, 0x00, 0x12, 0x30, 0x4a, 0x28, 0x23, 0x2e, 0xc6, 0x00, 0x50, 0xa0, 0x04, 0x2f, 0x09, 0x55,
236 0x89, 0x82, 0xc3, 0x6f, 0x83, 0x42, 0x40, 0x42, 0x00, 0x2e, 0x05, 0x2e, 0x8e, 0x00, 0x84, 0x8c, 0x47, 0x41, 0xa1,
237 0x41, 0xa1, 0x56, 0xc0, 0xb3, 0x0b, 0x09, 0xc4, 0x05, 0x44, 0x89, 0x85, 0x41, 0xf3, 0xbf, 0x82, 0x8d, 0xa7, 0x7f,
238 0x94, 0x7f, 0x0a, 0x2f, 0x09, 0x2e, 0xc4, 0x00, 0x00, 0x91, 0x06, 0x2f, 0x81, 0x80, 0xf9, 0x58, 0x0b, 0x40, 0xfb,
239 0x5a, 0x84, 0x7f, 0x0c, 0x2c, 0xfb, 0x50, 0x2b, 0x09, 0x98, 0xb9, 0x44, 0x04, 0xd8, 0xba, 0x82, 0x84, 0x53, 0xbc,
240 0xf7, 0x5e, 0xb3, 0xbe, 0x8b, 0x40, 0x13, 0xbe, 0x87, 0x7f, 0xb3, 0x30, 0x86, 0x41, 0xfd, 0x52, 0xb2, 0x6f, 0x76,
241 0x7f, 0x60, 0x7f, 0x55, 0x7f, 0x4b, 0x7f, 0x34, 0x7f, 0x98, 0x2e, 0x0f, 0xca, 0xd1, 0x6f, 0x88, 0x0e, 0x03, 0x2f,
242 0x01, 0x2e, 0xbc, 0x00, 0x00, 0xb2, 0x03, 0x2f, 0x00, 0x30, 0x21, 0x2e, 0xbe, 0x00, 0x10, 0x2d, 0x03, 0x2e, 0xbe,
243 0x00, 0x10, 0x30, 0x48, 0x28, 0x72, 0x6f, 0xa8, 0xb9, 0x23, 0x2e, 0xbe, 0x00, 0x0b, 0x0e, 0xc1, 0x6f, 0x0b, 0x55,
244 0x03, 0x2f, 0x90, 0x42, 0x91, 0x42, 0x00, 0x30, 0x80, 0x42, 0xb3, 0x30, 0xb2, 0x6f, 0x41, 0x6f, 0x98, 0x2e, 0x0f,
245 0xca, 0xd1, 0x6f, 0x08, 0x0f, 0x03, 0x2f, 0x01, 0x2e, 0xbc, 0x00, 0x00, 0x90, 0x03, 0x2f, 0x00, 0x30, 0x21, 0x2e,
246 0xc0, 0x00, 0x12, 0x2d, 0x01, 0x2e, 0xc0, 0x00, 0x71, 0x6f, 0xa1, 0x54, 0x01, 0x80, 0x4a, 0x08, 0x21, 0x2e, 0xc0,
247 0x00, 0x01, 0x0e, 0x07, 0x2f, 0x0d, 0x51, 0x02, 0x80, 0x01, 0x30, 0x21, 0x42, 0x12, 0x30, 0x01, 0x42, 0x25, 0x2e,
248 0xbf, 0x00, 0x91, 0x6f, 0x7e, 0x84, 0x43, 0x40, 0x82, 0x40, 0x7c, 0x80, 0x9a, 0x29, 0x03, 0x40, 0x46, 0x42, 0xc3,
249 0xb2, 0x06, 0x30, 0x00, 0x30, 0x2b, 0x2f, 0xc0, 0x6f, 0x00, 0xb2, 0x00, 0x30, 0x27, 0x2f, 0x01, 0x2e, 0xc4, 0x00,
250 0x00, 0x90, 0x00, 0x30, 0x05, 0x2f, 0xc2, 0x90, 0x03, 0x2f, 0xc0, 0x6f, 0x03, 0x90, 0x00, 0x30, 0x1c, 0x2f, 0x00,
251 0x6f, 0x83, 0x6f, 0x83, 0x0e, 0x00, 0x30, 0x17, 0x2f, 0xf3, 0x6e, 0x50, 0x6f, 0x98, 0x0f, 0x00, 0x30, 0x12, 0x2f,
252 0xa0, 0x6f, 0x98, 0x0e, 0x00, 0x30, 0x0e, 0x2f, 0xe3, 0x6e, 0x60, 0x6f, 0x98, 0x0f, 0x00, 0x30, 0x09, 0x2f, 0x30,
253 0x6f, 0x98, 0x0e, 0x00, 0x30, 0x05, 0x2f, 0x80, 0xb2, 0x00, 0x30, 0x02, 0x2f, 0x2d, 0x2e, 0xbc, 0x00, 0x10, 0x30,
254 0x42, 0x40, 0x82, 0xac, 0x56, 0x82, 0x01, 0x2f, 0x00, 0xb2, 0x05, 0x2f, 0x0d, 0x55, 0x82, 0x84, 0x2d, 0x2e, 0xbf,
255 0x00, 0x86, 0x42, 0x00, 0x2e, 0x0f, 0x55, 0x56, 0x42, 0x56, 0x42, 0x4a, 0x0e, 0xfb, 0x2f, 0x2d, 0x2e, 0xd6, 0x00,
256 0x01, 0x2d, 0x00, 0x30, 0xeb, 0x6f, 0xb0, 0x5e, 0xb8, 0x2e, 0x70, 0x50, 0x0a, 0x25, 0x39, 0x80, 0xf3, 0x7f, 0x03,
257 0x42, 0xa1, 0x7f, 0xc2, 0x7f, 0xd1, 0x7f, 0x03, 0x30, 0x03, 0x43, 0xe4, 0x7f, 0xbb, 0x7f, 0x22, 0x30, 0x10, 0x25,
258 0x98, 0x2e, 0x7a, 0xc1, 0xd2, 0x6f, 0x02, 0x17, 0x04, 0x08, 0xc1, 0x6f, 0x0c, 0x09, 0x04, 0x1a, 0x10, 0x30, 0x04,
259 0x30, 0x20, 0x22, 0x01, 0xb2, 0x14, 0x2f, 0x17, 0x59, 0x14, 0x09, 0xf3, 0x30, 0x93, 0x08, 0x24, 0xbd, 0x44, 0xba,
260 0x94, 0x0a, 0x02, 0x17, 0xf3, 0x6f, 0x4c, 0x08, 0x9a, 0x08, 0x8a, 0x0a, 0x19, 0x53, 0x51, 0x08, 0xa1, 0x58, 0x94,
261 0x08, 0x28, 0xbd, 0x98, 0xb8, 0xe4, 0x6f, 0x51, 0x0a, 0x01, 0x43, 0x00, 0x2e, 0xbb, 0x6f, 0x90, 0x5f, 0xb8, 0x2e,
262 0x1b, 0x57, 0x05, 0x40, 0x69, 0x18, 0x0d, 0x17, 0xe1, 0x18, 0x19, 0x05, 0x16, 0x25, 0x37, 0x25, 0x4a, 0x17, 0x54,
263 0x18, 0xec, 0x18, 0x04, 0x30, 0x64, 0x07, 0xea, 0x18, 0x8e, 0x00, 0x5f, 0x02, 0xd9, 0x56, 0x93, 0x00, 0x4c, 0x02,
264 0x2f, 0xb9, 0x91, 0xbc, 0x91, 0x0a, 0x02, 0x42, 0xb8, 0x2e, 0x00, 0x2e, 0x10, 0x24, 0xfa, 0x07, 0x11, 0x24, 0x00,
265 0x10, 0x12, 0x24, 0x80, 0x2e, 0x13, 0x24, 0x00, 0xc1, 0x12, 0x42, 0x13, 0x42, 0x41, 0x1a, 0xfb, 0x2f, 0x10, 0x24,
266 0x50, 0x32, 0x11, 0x24, 0x21, 0x2e, 0x21, 0x2e, 0x10, 0x00, 0x23, 0x2e, 0x11, 0x00, 0x80, 0x2e, 0x10, 0x00
269 /*! @name Global array that stores the feature input configuration of BMI270_WH */
270 const struct bmi2_feature_config bmi270_wh_feat_in[BMI270_WH_MAX_FEAT_IN] = {
271 { .type = BMI2_CONFIG_ID, .page = BMI2_PAGE_1, .start_addr = BMI270_WH_CONFIG_ID_STRT_ADDR },
272 { .type = BMI2_MAX_BURST_LEN, .page = BMI2_PAGE_1, .start_addr = BMI270_WH_MAX_BURST_LEN_STRT_ADDR },
273 { .type = BMI2_AXIS_MAP, .page = BMI2_PAGE_1, .start_addr = BMI270_WH_AXIS_MAP_STRT_ADDR },
274 { .type = BMI2_NVM_PROG_PREP, .page = BMI2_PAGE_1, .start_addr = BMI270_WH_NVM_PROG_PREP_STRT_ADDR },
275 { .type = BMI2_GYRO_GAIN_UPDATE, .page = BMI2_PAGE_1, .start_addr = BMI270_WH_GYRO_GAIN_UPDATE_STRT_ADDR },
276 { .type = BMI2_ANY_MOTION, .page = BMI2_PAGE_1, .start_addr = BMI270_WH_ANY_MOT_STRT_ADDR },
277 { .type = BMI2_NO_MOTION, .page = BMI2_PAGE_2, .start_addr = BMI270_WH_NO_MOT_STRT_ADDR },
278 { .type = BMI2_STEP_COUNTER_PARAMS, .page = BMI2_PAGE_3, .start_addr = BMI270_WH_STEP_CNT_1_STRT_ADDR },
279 { .type = BMI2_STEP_DETECTOR, .page = BMI2_PAGE_6, .start_addr = BMI270_WH_STEP_CNT_4_STRT_ADDR },
280 { .type = BMI2_STEP_COUNTER, .page = BMI2_PAGE_6, .start_addr = BMI270_WH_STEP_CNT_4_STRT_ADDR },
281 { .type = BMI2_STEP_ACTIVITY, .page = BMI2_PAGE_6, .start_addr = BMI270_WH_STEP_CNT_4_STRT_ADDR },
282 { .type = BMI2_WRIST_WEAR_WAKE_UP_WH, .page = BMI2_PAGE_2, .start_addr = BMI270_WH_WRIST_WEAR_WAKE_UP_STRT_ADDR },
285 /*! @name Global array that stores the feature output configuration */
286 const struct bmi2_feature_config bmi270_wh_feat_out[BMI270_WH_MAX_FEAT_OUT] = {
287 { .type = BMI2_STEP_COUNTER, .page = BMI2_PAGE_0, .start_addr = BMI270_WH_STEP_CNT_OUT_STRT_ADDR },
288 { .type = BMI2_STEP_ACTIVITY, .page = BMI2_PAGE_0, .start_addr = BMI270_WH_STEP_ACT_OUT_STRT_ADDR },
289 { .type = BMI2_GYRO_GAIN_UPDATE, .page = BMI2_PAGE_0, .start_addr = BMI270_WH_GYR_USER_GAIN_OUT_STRT_ADDR },
290 { .type = BMI2_GYRO_CROSS_SENSE, .page = BMI2_PAGE_0, .start_addr = BMI270_WH_GYRO_CROSS_SENSE_STRT_ADDR },
291 { .type = BMI2_NVM_STATUS, .page = BMI2_PAGE_0, .start_addr = BMI270_WH_NVM_VFRM_OUT_STRT_ADDR },
292 { .type = BMI2_VFRM_STATUS, .page = BMI2_PAGE_0, .start_addr = BMI270_WH_NVM_VFRM_OUT_STRT_ADDR }
295 /*! @name Global array that stores the feature interrupts of BMI270_WH */
296 struct bmi2_map_int bmi270wh_map_int[BMI270_WH_MAX_INT_MAP] = {
297 { .type = BMI2_STEP_COUNTER, .sens_map_int = BMI270_WH_INT_STEP_COUNTER_MASK },
298 { .type = BMI2_STEP_DETECTOR, .sens_map_int = BMI270_WH_INT_STEP_DETECTOR_MASK },
299 { .type = BMI2_STEP_ACTIVITY, .sens_map_int = BMI270_WH_INT_STEP_ACT_MASK },
300 { .type = BMI2_WRIST_WEAR_WAKE_UP_WH, .sens_map_int = BMI270_WH_INT_WRIST_WEAR_WAKEUP_WH_MASK },
301 { .type = BMI2_ANY_MOTION, .sens_map_int = BMI270_WH_INT_ANY_MOT_MASK },
302 { .type = BMI2_NO_MOTION, .sens_map_int = BMI270_WH_INT_NO_MOT_MASK },
305 /******************************************************************************/
307 /*! Local Function Prototypes
308 ******************************************************************************/
311 * @brief This internal API is used to validate the device pointer for
312 * null conditions.
314 * @param[in] dev : Structure instance of bmi2_dev.
316 * @return Result of API execution status
317 * @retval 0 -> Success
318 * @retval < 0 -> Fail
320 static int8_t null_ptr_check(const struct bmi2_dev *dev);
323 * @brief This internal API enables the selected sensor/features.
325 * @param[in] sensor_sel : Selects the desired sensor.
326 * @param[in, out] dev : Structure instance of bmi2_dev.
328 * @return Result of API execution status
329 * @retval 0 -> Success
330 * @retval < 0 -> Fail
332 static int8_t sensor_enable(uint64_t sensor_sel, struct bmi2_dev *dev);
335 * @brief This internal API disables the selected sensor/features.
337 * @param[in] sensor_sel : Selects the desired sensor.
338 * @param[in, out] dev : Structure instance of bmi2_dev.
340 * @return Result of API execution status
341 * @retval 0 -> Success
342 * @retval < 0 -> Fail
344 static int8_t sensor_disable(uint64_t sensor_sel, struct bmi2_dev *dev);
347 * @brief This internal API selects the sensors/features to be enabled or
348 * disabled.
350 * @param[in] sens_list : Pointer to select the sensor.
351 * @param[in] n_sens : Number of sensors selected.
352 * @param[out] sensor_sel : Gets the selected sensor.
354 * @return Result of API execution status
355 * @retval 0 -> Success
356 * @retval < 0 -> Fail
358 static int8_t select_sensor(const uint8_t *sens_list, uint8_t n_sens, uint64_t *sensor_sel);
361 * @brief This internal API is used to enable/disable any-motion feature.
363 * @param[in] dev : Structure instance of bmi2_dev.
364 * @param[in] enable : Enables/Disables any-motion.
366 * Enable | Description
367 * -------------|---------------
368 * BMI2_DISABLE | Disables any-motion.
369 * BMI2_ENABLE | Enables any-motion.
371 * @return Result of API execution status
372 * @retval 0 -> Success
373 * @retval < 0 -> Fail
375 static int8_t set_any_motion(uint8_t enable, struct bmi2_dev *dev);
378 * @brief This internal API is used to enable/disable no-motion feature.
380 * @param[in] dev : Structure instance of bmi2_dev.
381 * @param[in] enable : Enables/Disables no-motion.
383 * Enable | Description
384 * -------------|---------------
385 * BMI2_DISABLE | Disables no-motion.
386 * BMI2_ENABLE | Enables no-motion.
388 * @return Result of API execution status
389 * @retval 0 -> Success
390 * @retval < 0 -> Fail
392 static int8_t set_no_motion(uint8_t enable, struct bmi2_dev *dev);
395 * @brief This internal API is used to enable/disable step detector feature.
397 * @param[in] dev : Structure instance of bmi2_dev.
398 * @param[in] enable : Enables/Disables step-detector.
400 * Enable | Description
401 * -------------|---------------
402 * BMI2_DISABLE | Disables step detector
403 * BMI2_ENABLE | Enables step detector
405 * @return Result of API execution status
406 * @retval 0 -> Success
407 * @retval < 0 -> Fail
409 static int8_t set_step_detector(uint8_t enable, struct bmi2_dev *dev);
412 * @brief This internal API is used to enable/disable step counter feature.
414 * @param[in] dev : Structure instance of bmi2_dev.
415 * @param[in] enable : Enables/Disables step counter.
417 * Enable | Description
418 * -------------|---------------
419 * BMI2_DISABLE | Disables step counter
420 * BMI2_ENABLE | Enables step counter
422 * @return Result of API execution status
423 * @retval 0 -> Success
424 * @retval < 0 -> Fail
426 static int8_t set_step_counter(uint8_t enable, struct bmi2_dev *dev);
429 * @brief This internal API is used to enable/disable step activity detection.
431 * @param[in] dev : Structure instance of bmi2_dev.
432 * @param[in] enable : Enables/Disables step activity.
434 * Enable | Description
435 * -------------|---------------
436 * BMI2_DISABLE | Disables step activity
437 * BMI2_ENABLE | Enables step activity
439 * @return Result of API execution status
440 * @retval 0 -> Success
441 * @retval < 0 -> Fail
443 static int8_t set_step_activity(uint8_t enable, struct bmi2_dev *dev);
446 * @brief This internal API is used to enable/disable gyroscope user gain
447 * feature.
449 * @param[in] dev : Structure instance of bmi2_dev.
450 * @param[in] enable : Enables/Disables gyroscope user gain.
452 * Enable | Description
453 * -------------|---------------
454 * BMI2_DISABLE | Disables gyroscope user gain
455 * BMI2_ENABLE | Enables gyroscope user gain
457 * @return Result of API execution status
458 * @retval 0 -> Success
459 * @retval < 0 -> Fail
461 static int8_t set_gyro_user_gain(uint8_t enable, struct bmi2_dev *dev);
464 * @brief This internal API enables the wrist wear wake up feature for wearable variant.
466 * @param[in] dev : Structure instance of bmi2_dev.
467 * @param[in] enable : Enables/Disables wrist wear wake up.
469 * Enable | Description
470 * -------------|---------------
471 * BMI2_DISABLE | Disables wrist wear wake up
472 * BMI2_ENABLE | Enables wrist wear wake up
474 * @return Result of API execution status
475 * @retval 0 -> Success
476 * @retval < 0 -> Fail
478 static int8_t set_wrist_wear_wake_up_wh(uint8_t enable, struct bmi2_dev *dev);
481 * @brief This internal API sets any-motion configurations like axes select,
482 * duration, threshold and output-configuration.
484 * @param[in] config : Structure instance of bmi2_any_motion_config.
485 * @param[in, out] dev : Structure instance of bmi2_dev.
487 * @verbatim
488 *----------------------------------------------------------------------------
489 * bmi2_any_motion_config |
490 * Structure parameters | Description
491 *--------------------------|--------------------------------------------------
492 * | Defines the number of consecutive data points for
493 * | which the threshold condition must be respected,
494 * | for interrupt assertion. It is expressed in 50 Hz
495 * duration | samples (20 msec).
496 * | Range is 0 to 163sec.
497 * | Default value is 5 = 100ms.
498 * -------------------------|---------------------------------------------------
499 * | Slope threshold value for in 5.11g format.
500 * threshold | Range is 0 to 1g.
501 * | Default value is 0xAA = 83mg.
502 * -------------------------|---------------------------------------------------
503 * x_sel, y_sel, z_sel | Selects the feature on a per-axis basis
504 * -------------------------|---------------------------------------------------
505 * @endverbatim
507 * @return Result of API execution status
508 * @retval 0 -> Success
509 * @retval < 0 -> Fail
511 static int8_t set_any_motion_config(const struct bmi2_any_motion_config *config, struct bmi2_dev *dev);
514 * @brief This internal API sets no-motion configurations like axes select,
515 * duration, threshold and output-configuration.
517 * @param[in] config : Structure instance of bmi2_no_motion_config.
518 * @param[in, out] dev : Structure instance of bmi2_dev.
520 * @verbatim
521 *----------------------------------------------------------------------------
522 * bmi2_no_motion_config |
523 * Structure parameters | Description
524 *--------------------------|--------------------------------------------------
525 * | Defines the number of consecutive data points for
526 * | which the threshold condition must be respected,
527 * | for interrupt assertion. It is expressed in 50 Hz
528 * duration | samples (20 msec).
529 * | Range is 0 to 163sec.
530 * | Default value is 5 = 100ms.
531 * -------------------------|---------------------------------------------------
532 * | Slope threshold value for in 5.11g format.
533 * threshold | Range is 0 to 1g.
534 * | Default value is 0xAA = 83mg.
535 * -------------------------|---------------------------------------------------
536 * x_sel, y_sel, z_sel | Selects the feature on a per-axis basis
537 * -------------------------|---------------------------------------------------
538 * @endverbatim
540 * @return Result of API execution status
541 * @retval 0 -> Success
542 * @retval < 0 -> Fail
544 static int8_t set_no_motion_config(const struct bmi2_no_motion_config *config, struct bmi2_dev *dev);
547 * @brief This internal API sets step counter parameter configurations.
549 * @param[in] step_count_params : Array that stores parameters 1 to 25.
550 * @param[in] dev : Structure instance of bmi2_dev.
552 * @return Result of API execution status
553 * @retval 0 -> Success
554 * @retval < 0 -> Fail
556 static int8_t set_step_count_params_config(const uint16_t *step_count_params, struct bmi2_dev *dev);
559 * @brief This internal API sets step counter/detector/activity configurations.
561 * @param[in] config : Structure instance of bmi2_step_config.
562 * @param[in] dev : Structure instance of bmi2_dev.
564 *---------------------------------------------------------------------------
565 * bmi2_step_config |
566 * Structure parameters | Description
567 *--------------------------|--------------------------------------------------
568 * | The Step-counter will trigger output every time
569 * | the number of steps are counted. Holds implicitly
570 * water-mark level | a 20x factor, so the range is 0 to 10230,
571 * | with resolution of 20 steps.
572 * -------------------------|---------------------------------------------------
573 * reset counter | Flag to reset the counted steps.
574 * -------------------------|---------------------------------------------------
575 * @endverbatim
577 * @return Result of API execution status
578 * @retval 0 -> Success
579 * @retval < 0 -> Fail
581 static int8_t set_step_config(const struct bmi2_step_config *config, struct bmi2_dev *dev);
584 * @brief This internal API sets wrist wear wake-up configurations like
585 * output-configuration for wearable variant.
587 * @param[in] config : Structure instance of
588 * bmi2_wrist_wear_wake_up_config.
589 * @param[in, out] dev : Structure instance of bmi2_dev.
591 * @verbatim
592 *-------------------------------------|----------------------------------------
593 * bmi2_wrist_wear_wake_up_wh_config |
594 * Structure parameters | Description
595 *-------------------------------------|-------------------------------------------
596 * | To set the wrist wear wake-up parameters like
597 * | min_angle_focus, min_angle_nonfocus,
598 * wrist_wear_wake_wh_params | angle_landscape_left, angle_landscape_right,
599 * | angle_potrait_up and down.
600 * ------------------------------------|-------------------------------------------
601 * @endverbatim
603 * @return Result of API execution status
604 * @retval 0 -> Success
605 * @retval < 0 -> Fail
607 static int8_t set_wrist_wear_wake_up_wh_config(const struct bmi2_wrist_wear_wake_up_wh_config *config,
608 struct bmi2_dev *dev);
611 * @brief This internal API gets any-motion configurations like axes select,
612 * duration, threshold and output-configuration.
614 * @param[out] config : Structure instance of bmi2_any_motion_config.
615 * @param[in, out] dev : Structure instance of bmi2_dev.
617 * @verbatim
618 *----------------------------------------------------------------------------
619 * bmi2_any_motion_config |
620 * Structure parameters | Description
621 *--------------------------|--------------------------------------------------
622 * | Defines the number of consecutive data points for
623 * | which the threshold condition must be respected,
624 * | for interrupt assertion. It is expressed in 50 Hz
625 * duration | samples (20 msec).
626 * | Range is 0 to 163sec.
627 * | Default value is 5 = 100ms.
628 * -------------------------|---------------------------------------------------
629 * | Slope threshold value for in 5.11g format.
630 * threshold | Range is 0 to 1g.
631 * | Default value is 0xAA = 83mg.
632 * -------------------------|---------------------------------------------------
633 * x_sel, y_sel, z_sel | Selects the feature on a per-axis basis
634 * -------------------------|---------------------------------------------------
635 * @endverbatim
637 * @return Result of API execution status
638 * @retval 0 -> Success
639 * @retval < 0 -> Fail
641 static int8_t get_any_motion_config(struct bmi2_any_motion_config *config, struct bmi2_dev *dev);
644 * @brief This internal API gets no-motion configurations like axes select,
645 * duration, threshold and output-configuration.
647 * @param[out] config : Structure instance of bmi2_no_motion_config.
648 * @param[in, out] dev : Structure instance of bmi2_dev.
650 * @verbatim
651 *----------------------------------------------------------------------------
652 * bmi2_no_motion_config |
653 * Structure parameters | Description
654 *--------------------------|--------------------------------------------------
655 * | Defines the number of consecutive data points for
656 * | which the threshold condition must be respected,
657 * | for interrupt assertion. It is expressed in 50 Hz
658 * duration | samples (20 msec).
659 * | Range is 0 to 163sec.
660 * | Default value is 5 = 100ms.
661 * -------------------------|---------------------------------------------------
662 * | Slope threshold value for in 5.11g format.
663 * threshold | Range is 0 to 1g.
664 * | Default value is 0xAA = 83mg.
665 * -------------------------|---------------------------------------------------
666 * x_sel, y_sel, z_sel | Selects the feature on a per-axis basis
667 * -------------------------|---------------------------------------------------
668 * @endverbatim
670 * @return Result of API execution status
671 * @retval 0 -> Success
672 * @retval < 0 -> Fail
674 static int8_t get_no_motion_config(struct bmi2_no_motion_config *config, struct bmi2_dev *dev);
677 * @brief This internal API gets step counter parameter configurations.
679 * @param[in] step_count_params : Array that stores parameters 1 to 25.
680 * @param[in] dev : Structure instance of bmi2_dev.
682 * @return Result of API execution status
683 * @retval 0 -> Success
684 * @retval < 0 -> Fail
686 static int8_t get_step_count_params_config(uint16_t *step_count_params, struct bmi2_dev *dev);
689 * @brief This internal API gets step counter/detector/activity configurations.
691 * @param[out] config : Structure instance of bmi2_step_config.
692 * @param[in] dev : Structure instance of bmi2_dev.
694 * @verbatim
695 *----------------------------------------------------------------------------
696 * bmi2_step_config |
697 * Structure parameters | Description
698 *--------------------------|--------------------------------------------------
699 * | The Step-counter will trigger output every time
700 * | the number of steps are counted. Holds implicitly
701 * water-mark level | a 20x factor, so the range is 0 to 10230,
702 * | with resolution of 20 steps.
703 * -------------------------|---------------------------------------------------
704 * reset counter | Flag to reset the counted steps.
705 * -------------------------|---------------------------------------------------
706 * @endverbatim
708 * @return Result of API execution status
709 * @retval 0 -> Success
710 * @retval < 0 -> Fail
712 static int8_t get_step_config(struct bmi2_step_config *config, struct bmi2_dev *dev);
715 * @brief This internal API gets wrist wear wake-up configurations like
716 * output-configuration for wearable variant.
718 * @param[out] config : Structure instance of
719 * bmi2_wrist_wear_wake_up_config.
720 * @param[in, out] dev : Structure instance of bmi2_dev.
722 * @verbatim
723 *-----------------------------------------------------------------------------
724 * bmi2_wrist_wear_wake_up_config |
725 * Structure parameters | Description
726 *----------------------------------|-------------------------------------------
727 * | To get the wrist wear wake-up parameters like
728 * | min_angle_focus, min_angle_nonfocus,
729 * wrist_wear_wake_params | angle_landscape_left, angle_landscape_right,
730 * | angle_potrait_up and down.
731 * ---------------------------------|-------------------------------------------
732 * @endverbatim
734 * @return Result of API execution status
735 * @retval 0 -> Success
736 * @retval < 0 -> Fail
738 static int8_t get_wrist_wear_wake_up_wh_config(struct bmi2_wrist_wear_wake_up_wh_config *config, struct bmi2_dev *dev);
741 * @brief This internal API gets the output values of step activity.
743 * @param[out] step_act : Pointer to the stored step activity data.
744 * @param[in] dev : Structure instance of bmi2_dev.
746 * *step_act | Output
747 * -----------|------------
748 * 0x00 | STILL
749 * 0x01 | WALKING
750 * 0x02 | RUNNING
751 * 0x03 | UNKNOWN
753 * @return Result of API execution status
754 * @retval 0 -> Success
755 * @retval < 0 -> Fail
757 static int8_t get_step_activity_output(uint8_t *step_act, struct bmi2_dev *dev);
760 * @brief This internal API gets the output values of step counter.
762 * @param[out] step_count : Pointer to the stored step counter data.
763 * @param[in] dev : Structure instance of bmi2_dev.
765 * @return Result of API execution status
766 * @retval 0 -> Success
767 * @retval < 0 -> Fail
769 static int8_t get_step_counter_output(uint32_t *step_count, struct bmi2_dev *dev);
772 * @brief This internal API gets the error status related to NVM.
774 * @param[out] nvm_err_stat : Stores the NVM error status.
775 * @param[in] dev : Structure instance of bmi2_dev.
777 * @return Result of API execution status
778 * @retval 0 -> Success
779 * @retval < 0 -> Fail
781 static int8_t get_nvm_error_status(struct bmi2_nvm_err_status *nvm_err_stat, struct bmi2_dev *dev);
784 * @brief This internal API gets the error status related to virtual frames.
786 * @param[out] vfrm_err_stat : Stores the VFRM related error status.
787 * @param[in] dev : Structure instance of bmi2_dev.
789 * @return Result of API execution status
790 * @retval 0 -> Success
791 * @retval < 0 -> Fail
793 static int8_t get_vfrm_error_status(struct bmi2_vfrm_err_status *vfrm_err_stat, struct bmi2_dev *dev);
796 * @brief This internal API is used to get enable status of gyroscope user gain
797 * update.
799 * @param[out] status : Stores status of gyroscope user gain update.
800 * @param[in] dev : Structure instance of bmi2_dev.
802 * @return Result of API execution status
803 * @retval 0 -> Success
804 * @retval < 0 -> Fail
806 static int8_t get_user_gain_upd_status(uint8_t *status, struct bmi2_dev *dev);
809 * @brief This internal API enables/disables compensation of the gain defined
810 * in the GAIN register.
812 * @param[in] enable : Enables/Disables gain compensation
813 * @param[in] dev : Structure instance of bmi2_dev.
815 * enable | Description
816 * -------------|---------------
817 * BMI2_ENABLE | Enable gain compensation.
818 * BMI2_DISABLE | Disable gain compensation.
820 * @return Result of API execution status
821 * @retval 0 -> Success
822 * @retval < 0 -> Fail
824 static int8_t enable_gyro_gain(uint8_t enable, struct bmi2_dev *dev);
827 * @brief This internal API is used to extract the output feature configuration
828 * details like page and start address from the look-up table.
830 * @param[out] feat_output : Structure that stores output feature
831 * configurations.
832 * @param[in] type : Type of feature or sensor.
833 * @param[in] dev : Structure instance of bmi2_dev.
835 * @return Returns the feature found flag.
837 * @retval BMI2_FALSE : Feature not found
838 * BMI2_TRUE : Feature found
840 static uint8_t extract_output_feat_config(struct bmi2_feature_config *feat_output,
841 uint8_t type,
842 const struct bmi2_dev *dev);
844 /***************************************************************************/
846 /*! User Interface Definitions
847 ****************************************************************************/
850 * @brief This API:
851 * 1) updates the device structure with address of the configuration file.
852 * 2) Initializes BMI270_WH sensor.
853 * 3) Writes the configuration file.
854 * 4) Updates the feature offset parameters in the device structure.
855 * 5) Updates the maximum number of pages, in the device structure.
857 int8_t bmi270_wh_init(struct bmi2_dev *dev)
859 /* Variable to define error */
860 int8_t rslt;
862 /* Null-pointer check */
863 rslt = null_ptr_check(dev);
864 if (rslt == BMI2_OK)
866 /* Assign chip id of BMI270_WH */
867 dev->chip_id = BMI270_WH_CHIP_ID;
869 /* get the size of config array */
870 dev->config_size = sizeof(bmi270_wh_config_file);
872 /* Enable the variant specific features if any */
873 dev->variant_feature = BMI2_GYRO_CROSS_SENS_ENABLE | BMI2_CRT_RTOSK_ENABLE;
875 /* An extra dummy byte is read during SPI read */
876 if (dev->intf == BMI2_SPI_INTF)
878 dev->dummy_byte = 1;
880 else
882 dev->dummy_byte = 0;
885 /* If configuration file pointer is not assigned any address */
886 if (!dev->config_file_ptr)
888 /* Give the address of the configuration file array to
889 * the device pointer
891 dev->config_file_ptr = bmi270_wh_config_file;
894 /* Initialize BMI2 sensor */
895 rslt = bmi2_sec_init(dev);
896 if (rslt == BMI2_OK)
898 /* Assign the offsets of the feature input
899 * configuration to the device structure
901 dev->feat_config = bmi270_wh_feat_in;
903 /* Assign the offsets of the feature output to
904 * the device structure
906 dev->feat_output = bmi270_wh_feat_out;
908 /* Assign the maximum number of pages to the
909 * device structure
911 dev->page_max = BMI270_WH_MAX_PAGE_NUM;
913 /* Assign maximum number of input sensors/
914 * features to device structure
916 dev->input_sens = BMI270_WH_MAX_FEAT_IN;
918 /* Assign maximum number of output sensors/
919 * features to device structure
921 dev->out_sens = BMI270_WH_MAX_FEAT_OUT;
923 /* Assign the offsets of the feature interrupt
924 * to the device structure
926 dev->map_int = bmi270wh_map_int;
928 /* Assign maximum number of feature interrupts
929 * to device structure
931 dev->sens_int_map = BMI270_WH_MAX_INT_MAP;
933 /* Get the gyroscope cross axis sensitivity */
934 rslt = bmi2_get_gyro_cross_sense(dev);
938 return rslt;
942 * @brief This API selects the sensors/features to be enabled.
944 int8_t bmi270_wh_sensor_enable(const uint8_t *sens_list, uint8_t n_sens, struct bmi2_dev *dev)
946 /* Variable to define error */
947 int8_t rslt;
949 /* Variable to select sensor */
950 uint64_t sensor_sel = 0;
952 /* Null-pointer check */
953 rslt = null_ptr_check(dev);
954 if ((rslt == BMI2_OK) && (sens_list != NULL))
956 /* Get the selected sensors */
957 rslt = select_sensor(sens_list, n_sens, &sensor_sel);
958 if (rslt == BMI2_OK)
960 /* Enable the selected sensors */
961 rslt = sensor_enable(sensor_sel, dev);
964 else
966 rslt = BMI2_E_NULL_PTR;
969 return rslt;
973 * @brief This API selects the sensors/features to be disabled.
975 int8_t bmi270_wh_sensor_disable(const uint8_t *sens_list, uint8_t n_sens, struct bmi2_dev *dev)
977 /* Variable to define error */
978 int8_t rslt;
980 /* Variable to select sensor */
981 uint64_t sensor_sel = 0;
983 /* Null-pointer check */
984 rslt = null_ptr_check(dev);
985 if ((rslt == BMI2_OK) && (sens_list != NULL))
987 /* Get the selected sensors */
988 rslt = select_sensor(sens_list, n_sens, &sensor_sel);
989 if (rslt == BMI2_OK)
991 /* Disable the selected sensors */
992 rslt = sensor_disable(sensor_sel, dev);
995 else
997 rslt = BMI2_E_NULL_PTR;
1000 return rslt;
1004 * @brief This API sets the sensor/feature configuration.
1006 int8_t bmi270_wh_set_sensor_config(struct bmi2_sens_config *sens_cfg, uint8_t n_sens, struct bmi2_dev *dev)
1008 /* Variable to define error */
1009 int8_t rslt;
1011 /* Variable to define loop */
1012 uint8_t loop;
1014 /* Variable to get the status of advance power save */
1015 uint8_t aps_stat = 0;
1017 /* Null-pointer check */
1018 rslt = null_ptr_check(dev);
1019 if ((rslt == BMI2_OK) && (sens_cfg != NULL))
1021 /* Get status of advance power save mode */
1022 aps_stat = dev->aps_status;
1024 for (loop = 0; loop < n_sens; loop++)
1026 if ((sens_cfg[loop].type == BMI2_ACCEL) || (sens_cfg[loop].type == BMI2_GYRO) ||
1027 (sens_cfg[loop].type == BMI2_AUX) || (sens_cfg[loop].type == BMI2_GYRO_GAIN_UPDATE))
1029 rslt = bmi2_set_sensor_config(&sens_cfg[loop], 1, dev);
1031 else
1033 /* Disable Advance power save if enabled for auxiliary
1034 * and feature configurations
1036 if (aps_stat == BMI2_ENABLE)
1038 /* Disable advance power save if
1039 * enabled
1041 rslt = bmi2_set_adv_power_save(BMI2_DISABLE, dev);
1044 if (rslt == BMI2_OK)
1046 switch (sens_cfg[loop].type)
1048 /* Set any motion configuration */
1049 case BMI2_ANY_MOTION:
1050 rslt = set_any_motion_config(&sens_cfg[loop].cfg.any_motion, dev);
1051 break;
1053 /* Set no motion configuration */
1054 case BMI2_NO_MOTION:
1055 rslt = set_no_motion_config(&sens_cfg[loop].cfg.no_motion, dev);
1056 break;
1058 /* Set the step counter parameters */
1059 case BMI2_STEP_COUNTER_PARAMS:
1060 rslt = set_step_count_params_config(sens_cfg[loop].cfg.step_counter_params, dev);
1061 break;
1063 /* Set step counter/detector/activity configuration */
1064 case BMI2_STEP_DETECTOR:
1065 case BMI2_STEP_COUNTER:
1066 case BMI2_STEP_ACTIVITY:
1067 rslt = set_step_config(&sens_cfg[loop].cfg.step_counter, dev);
1068 break;
1070 /* Set the wrist wear wake-up configuration for wearable variant */
1071 case BMI2_WRIST_WEAR_WAKE_UP_WH:
1072 rslt = set_wrist_wear_wake_up_wh_config(&sens_cfg[loop].cfg.wrist_wear_wake_up_wh, dev);
1073 break;
1075 default:
1076 rslt = BMI2_E_INVALID_SENSOR;
1077 break;
1081 /* Return error if any of the set configurations fail */
1082 if (rslt != BMI2_OK)
1084 break;
1089 /* Enable Advance power save if disabled while configuring and
1090 * not when already disabled
1092 if ((aps_stat == BMI2_ENABLE) && (rslt == BMI2_OK))
1094 rslt = bmi2_set_adv_power_save(BMI2_ENABLE, dev);
1097 else
1099 rslt = BMI2_E_NULL_PTR;
1102 return rslt;
1106 * @brief This API gets the sensor/feature configuration.
1108 int8_t bmi270_wh_get_sensor_config(struct bmi2_sens_config *sens_cfg, uint8_t n_sens, struct bmi2_dev *dev)
1110 /* Variable to define error */
1111 int8_t rslt;
1113 /* Variable to define loop */
1114 uint8_t loop;
1116 /* Variable to get the status of advance power save */
1117 uint8_t aps_stat = 0;
1119 /* Null-pointer check */
1120 rslt = null_ptr_check(dev);
1121 if ((rslt == BMI2_OK) && (sens_cfg != NULL))
1123 /* Get status of advance power save mode */
1124 aps_stat = dev->aps_status;
1125 for (loop = 0; loop < n_sens; loop++)
1127 if ((sens_cfg[loop].type == BMI2_ACCEL) || (sens_cfg[loop].type == BMI2_GYRO) ||
1128 (sens_cfg[loop].type == BMI2_AUX) || (sens_cfg[loop].type == BMI2_GYRO_GAIN_UPDATE))
1130 rslt = bmi2_get_sensor_config(&sens_cfg[loop], 1, dev);
1132 else
1134 /* Disable Advance power save if enabled for auxiliary
1135 * and feature configurations
1137 if ((sens_cfg[loop].type >= BMI2_MAIN_SENS_MAX_NUM) || (sens_cfg[loop].type == BMI2_AUX))
1140 if (aps_stat == BMI2_ENABLE)
1142 /* Disable advance power save if
1143 * enabled
1145 rslt = bmi2_set_adv_power_save(BMI2_DISABLE, dev);
1149 if (rslt == BMI2_OK)
1151 switch (sens_cfg[loop].type)
1153 /* Get any motion configuration */
1154 case BMI2_ANY_MOTION:
1155 rslt = get_any_motion_config(&sens_cfg[loop].cfg.any_motion, dev);
1156 break;
1158 /* Get no motion configuration */
1159 case BMI2_NO_MOTION:
1160 rslt = get_no_motion_config(&sens_cfg[loop].cfg.no_motion, dev);
1161 break;
1163 /* Set the step counter parameters */
1164 case BMI2_STEP_COUNTER_PARAMS:
1165 rslt = get_step_count_params_config(sens_cfg[loop].cfg.step_counter_params, dev);
1166 break;
1168 /* Get step counter/detector/activity configuration */
1169 case BMI2_STEP_DETECTOR:
1170 case BMI2_STEP_COUNTER:
1171 case BMI2_STEP_ACTIVITY:
1172 rslt = get_step_config(&sens_cfg[loop].cfg.step_counter, dev);
1173 break;
1175 /* Get the wrist wear wake-up configuration for wearable variant */
1176 case BMI2_WRIST_WEAR_WAKE_UP_WH:
1177 rslt = get_wrist_wear_wake_up_wh_config(&sens_cfg[loop].cfg.wrist_wear_wake_up_wh, dev);
1178 break;
1180 default:
1181 rslt = BMI2_E_INVALID_SENSOR;
1182 break;
1186 /* Return error if any of the get configurations fail */
1187 if (rslt != BMI2_OK)
1189 break;
1194 /* Enable Advance power save if disabled while configuring and
1195 * not when already disabled
1197 if ((aps_stat == BMI2_ENABLE) && (rslt == BMI2_OK))
1199 rslt = bmi2_set_adv_power_save(BMI2_ENABLE, dev);
1202 else
1204 rslt = BMI2_E_NULL_PTR;
1207 return rslt;
1211 * @brief This API gets the sensor/feature data for accelerometer, gyroscope,
1212 * auxiliary sensor, step counter, high-g, gyroscope user-gain update,
1213 * orientation, gyroscope cross sensitivity and error status for NVM and VFRM.
1215 int8_t bmi270_wh_get_sensor_data(struct bmi2_sensor_data *sensor_data, uint8_t n_sens, struct bmi2_dev *dev)
1217 /* Variable to define error */
1218 int8_t rslt;
1220 /* Variable to define loop */
1221 uint8_t loop;
1223 /* Variable to get the status of advance power save */
1224 uint8_t aps_stat = 0;
1226 /* Null-pointer check */
1227 rslt = null_ptr_check(dev);
1228 if ((rslt == BMI2_OK) && (sensor_data != NULL))
1230 /* Get status of advance power save mode */
1231 aps_stat = dev->aps_status;
1232 for (loop = 0; loop < n_sens; loop++)
1234 if ((sensor_data[loop].type == BMI2_ACCEL) || (sensor_data[loop].type == BMI2_GYRO) ||
1235 (sensor_data[loop].type == BMI2_AUX) || (sensor_data[loop].type == BMI2_GYRO_GAIN_UPDATE) ||
1236 (sensor_data[loop].type == BMI2_GYRO_CROSS_SENSE))
1238 rslt = bmi2_get_sensor_data(&sensor_data[loop], 1, dev);
1240 else
1242 /* Disable Advance power save if enabled for feature
1243 * configurations
1245 if (sensor_data[loop].type >= BMI2_MAIN_SENS_MAX_NUM)
1247 if (aps_stat == BMI2_ENABLE)
1249 /* Disable advance power save if
1250 * enabled
1252 rslt = bmi2_set_adv_power_save(BMI2_DISABLE, dev);
1256 if (rslt == BMI2_OK)
1258 switch (sensor_data[loop].type)
1260 case BMI2_STEP_COUNTER:
1262 /* Get step counter output */
1263 rslt = get_step_counter_output(&sensor_data[loop].sens_data.step_counter_output, dev);
1264 break;
1265 case BMI2_STEP_ACTIVITY:
1267 /* Get step activity output */
1268 rslt = get_step_activity_output(&sensor_data[loop].sens_data.activity_output, dev);
1269 break;
1270 case BMI2_NVM_STATUS:
1272 /* Get NVM error status */
1273 rslt = get_nvm_error_status(&sensor_data[loop].sens_data.nvm_status, dev);
1274 break;
1275 case BMI2_VFRM_STATUS:
1277 /* Get VFRM error status */
1278 rslt = get_vfrm_error_status(&sensor_data[loop].sens_data.vfrm_status, dev);
1279 break;
1280 default:
1281 rslt = BMI2_E_INVALID_SENSOR;
1282 break;
1285 /* Return error if any of the get sensor data fails */
1286 if (rslt != BMI2_OK)
1288 break;
1293 /* Enable Advance power save if disabled while
1294 * configuring and not when already disabled
1296 if ((aps_stat == BMI2_ENABLE) && (rslt == BMI2_OK))
1298 rslt = bmi2_set_adv_power_save(BMI2_ENABLE, dev);
1302 else
1304 rslt = BMI2_E_NULL_PTR;
1307 return rslt;
1311 * @brief This API updates the gyroscope user-gain.
1313 int8_t bmi270_wh_update_gyro_user_gain(const struct bmi2_gyro_user_gain_config *user_gain, struct bmi2_dev *dev)
1315 /* Variable to define error */
1316 int8_t rslt;
1318 /* Variable to select sensor */
1319 uint8_t sens_sel[2] = { BMI2_GYRO, BMI2_GYRO_GAIN_UPDATE };
1321 /* Structure to define sensor configurations */
1322 struct bmi2_sens_config sens_cfg;
1324 /* Variable to store status of user-gain update module */
1325 uint8_t status = 0;
1327 /* Variable to define count */
1328 uint8_t count = 100;
1330 /* Null-pointer check */
1331 rslt = null_ptr_check(dev);
1332 if ((rslt == BMI2_OK) && (user_gain != NULL))
1334 /* Select type of feature */
1335 sens_cfg.type = BMI2_GYRO_GAIN_UPDATE;
1337 /* Get the user gain configurations */
1338 rslt = bmi270_wh_get_sensor_config(&sens_cfg, 1, dev);
1339 if (rslt == BMI2_OK)
1341 /* Get the user-defined ratio */
1342 sens_cfg.cfg.gyro_gain_update = *user_gain;
1344 /* Set rate ratio for all axes */
1345 rslt = bmi270_wh_set_sensor_config(&sens_cfg, 1, dev);
1348 /* Disable gyroscope */
1349 if (rslt == BMI2_OK)
1351 rslt = bmi270_wh_sensor_disable(&sens_sel[0], 1, dev);
1354 /* Enable gyroscope user-gain update module */
1355 if (rslt == BMI2_OK)
1357 rslt = bmi270_wh_sensor_enable(&sens_sel[1], 1, dev);
1360 /* Set the command to trigger the computation */
1361 if (rslt == BMI2_OK)
1363 rslt = bmi2_set_command_register(BMI2_USR_GAIN_CMD, dev);
1366 if (rslt == BMI2_OK)
1368 /* Poll until enable bit of user-gain update is 0 */
1369 while (count--)
1371 rslt = get_user_gain_upd_status(&status, dev);
1372 if ((rslt == BMI2_OK) && (status == 0))
1374 /* Enable compensation of gain defined
1375 * in the GAIN register
1377 rslt = enable_gyro_gain(BMI2_ENABLE, dev);
1379 /* Enable gyroscope */
1380 if (rslt == BMI2_OK)
1382 rslt = bmi270_wh_sensor_enable(&sens_sel[0], 1, dev);
1385 break;
1388 dev->delay_us(10000, dev->intf_ptr);
1391 /* Return error if user-gain update is failed */
1392 if ((rslt == BMI2_OK) && (status != 0))
1394 rslt = BMI2_E_GYR_USER_GAIN_UPD_FAIL;
1398 else
1400 rslt = BMI2_E_NULL_PTR;
1403 return rslt;
1407 * @brief This API reads the compensated gyroscope user-gain values.
1409 int8_t bmi270_wh_read_gyro_user_gain(struct bmi2_gyro_user_gain_data *gyr_usr_gain, struct bmi2_dev *dev)
1411 /* Variable to define error */
1412 int8_t rslt;
1414 /* Variable to define register data */
1415 uint8_t reg_data[3] = { 0 };
1417 /* Null-pointer check */
1418 rslt = null_ptr_check(dev);
1419 if ((rslt == BMI2_OK) && (gyr_usr_gain != NULL))
1421 /* Get the gyroscope compensated gain values */
1422 rslt = bmi2_get_regs(BMI2_GYR_USR_GAIN_0_ADDR, reg_data, 3, dev);
1423 if (rslt == BMI2_OK)
1425 /* Gyroscope user gain correction X-axis */
1426 gyr_usr_gain->x = (int8_t)BMI2_GET_BIT_POS0(reg_data[0], BMI2_GYR_USR_GAIN_X);
1428 /* Gyroscope user gain correction Y-axis */
1429 gyr_usr_gain->y = (int8_t)BMI2_GET_BIT_POS0(reg_data[1], BMI2_GYR_USR_GAIN_Y);
1431 /* Gyroscope user gain correction z-axis */
1432 gyr_usr_gain->z = (int8_t)BMI2_GET_BIT_POS0(reg_data[2], BMI2_GYR_USR_GAIN_Z);
1435 else
1437 rslt = BMI2_E_NULL_PTR;
1440 return rslt;
1444 * @brief This API maps/unmaps feature interrupts to that of interrupt pins.
1446 int8_t bmi270_wh_map_feat_int(const struct bmi2_sens_int_config *sens_int, uint8_t n_sens, struct bmi2_dev *dev)
1448 /* Variable to define error */
1449 int8_t rslt;
1451 /* Variable to define loop */
1452 uint8_t loop;
1454 /* Null-pointer check */
1455 rslt = null_ptr_check(dev);
1456 if ((rslt == BMI2_OK) && (sens_int != NULL))
1458 for (loop = 0; loop < n_sens; loop++)
1460 switch (sens_int[loop].type)
1462 case BMI2_ANY_MOTION:
1463 case BMI2_NO_MOTION:
1464 case BMI2_STEP_COUNTER:
1465 case BMI2_STEP_DETECTOR:
1466 case BMI2_STEP_ACTIVITY:
1467 case BMI2_WRIST_WEAR_WAKE_UP_WH:
1469 rslt = bmi2_map_feat_int(sens_int[loop].type, sens_int[loop].hw_int_pin, dev);
1470 break;
1471 default:
1472 rslt = BMI2_E_INVALID_SENSOR;
1473 break;
1476 /* Return error if interrupt mapping fails */
1477 if (rslt != BMI2_OK)
1479 break;
1483 else
1485 rslt = BMI2_E_NULL_PTR;
1488 return rslt;
1491 /***************************************************************************/
1493 /*! Local Function Definitions
1494 ****************************************************************************/
1497 * @brief This internal API is used to validate the device structure pointer for
1498 * null conditions.
1500 static int8_t null_ptr_check(const struct bmi2_dev *dev)
1502 /* Variable to define error */
1503 int8_t rslt = BMI2_OK;
1505 if ((dev == NULL) || (dev->read == NULL) || (dev->write == NULL) || (dev->delay_us == NULL))
1507 /* Device structure pointer is not valid */
1508 rslt = BMI2_E_NULL_PTR;
1511 return rslt;
1515 * @brief This internal API selects the sensor/features to be enabled or
1516 * disabled.
1518 static int8_t select_sensor(const uint8_t *sens_list, uint8_t n_sens, uint64_t *sensor_sel)
1520 /* Variable to define error */
1521 int8_t rslt = BMI2_OK;
1523 /* Variable to define loop */
1524 uint8_t count;
1526 for (count = 0; count < n_sens; count++)
1528 switch (sens_list[count])
1530 case BMI2_ACCEL:
1531 *sensor_sel |= BMI2_ACCEL_SENS_SEL;
1532 break;
1533 case BMI2_GYRO:
1534 *sensor_sel |= BMI2_GYRO_SENS_SEL;
1535 break;
1536 case BMI2_AUX:
1537 *sensor_sel |= BMI2_AUX_SENS_SEL;
1538 break;
1539 case BMI2_TEMP:
1540 *sensor_sel |= BMI2_TEMP_SENS_SEL;
1541 break;
1542 case BMI2_ANY_MOTION:
1543 *sensor_sel |= BMI2_ANY_MOT_SEL;
1544 break;
1545 case BMI2_NO_MOTION:
1546 *sensor_sel |= BMI2_NO_MOT_SEL;
1547 break;
1548 case BMI2_STEP_DETECTOR:
1549 *sensor_sel |= BMI2_STEP_DETECT_SEL;
1550 break;
1551 case BMI2_STEP_COUNTER:
1552 *sensor_sel |= BMI2_STEP_COUNT_SEL;
1553 break;
1554 case BMI2_STEP_ACTIVITY:
1555 *sensor_sel |= BMI2_STEP_ACT_SEL;
1556 break;
1557 case BMI2_GYRO_GAIN_UPDATE:
1558 *sensor_sel |= BMI2_GYRO_GAIN_UPDATE_SEL;
1559 break;
1560 case BMI2_WRIST_WEAR_WAKE_UP_WH:
1561 *sensor_sel |= BMI2_WRIST_WEAR_WAKE_UP_WH_SEL;
1562 break;
1563 default:
1564 rslt = BMI2_E_INVALID_SENSOR;
1565 break;
1569 return rslt;
1573 * @brief This internal API enables the selected sensor/features.
1575 static int8_t sensor_enable(uint64_t sensor_sel, struct bmi2_dev *dev)
1577 /* Variable to define error */
1578 int8_t rslt;
1580 /* Variable to store register values */
1581 uint8_t reg_data = 0;
1583 /* Variable to define loop */
1584 uint8_t loop = 1;
1586 /* Variable to get the status of advance power save */
1587 uint8_t aps_stat = 0;
1589 rslt = bmi2_get_regs(BMI2_PWR_CTRL_ADDR, &reg_data, 1, dev);
1590 if (rslt == BMI2_OK)
1592 /* Enable accelerometer */
1593 if (sensor_sel & BMI2_ACCEL_SENS_SEL)
1595 reg_data = BMI2_SET_BITS(reg_data, BMI2_ACC_EN, BMI2_ENABLE);
1598 /* Enable gyroscope */
1599 if (sensor_sel & BMI2_GYRO_SENS_SEL)
1601 reg_data = BMI2_SET_BITS(reg_data, BMI2_GYR_EN, BMI2_ENABLE);
1604 /* Enable auxiliary sensor */
1605 if (sensor_sel & BMI2_AUX_SENS_SEL)
1607 reg_data = BMI2_SET_BIT_POS0(reg_data, BMI2_AUX_EN, BMI2_ENABLE);
1610 /* Enable temperature sensor */
1611 if (sensor_sel & BMI2_TEMP_SENS_SEL)
1613 reg_data = BMI2_SET_BITS(reg_data, BMI2_TEMP_EN, BMI2_ENABLE);
1616 /* Enable the sensors that are set in the power control register */
1617 if (sensor_sel & BMI2_MAIN_SENSORS)
1619 rslt = bmi2_set_regs(BMI2_PWR_CTRL_ADDR, &reg_data, 1, dev);
1623 if ((rslt == BMI2_OK) && (sensor_sel & ~(BMI2_MAIN_SENSORS)))
1625 /* Get status of advance power save mode */
1626 aps_stat = dev->aps_status;
1627 if (aps_stat == BMI2_ENABLE)
1629 /* Disable advance power save if enabled */
1630 rslt = bmi2_set_adv_power_save(BMI2_DISABLE, dev);
1633 if (rslt == BMI2_OK)
1635 while (loop--)
1637 /* Enable any motion feature */
1638 if (sensor_sel & BMI2_ANY_MOT_SEL)
1640 rslt = set_any_motion(BMI2_ENABLE, dev);
1641 if (rslt == BMI2_OK)
1643 dev->sens_en_stat |= BMI2_ANY_MOT_SEL;
1645 else
1647 break;
1651 /* Enable no motion feature */
1652 if (sensor_sel & BMI2_NO_MOT_SEL)
1654 rslt = set_no_motion(BMI2_ENABLE, dev);
1655 if (rslt == BMI2_OK)
1657 dev->sens_en_stat |= BMI2_NO_MOT_SEL;
1659 else
1661 break;
1665 /* Enable step detector feature */
1666 if (sensor_sel & BMI2_STEP_DETECT_SEL)
1668 rslt = set_step_detector(BMI2_ENABLE, dev);
1669 if (rslt == BMI2_OK)
1671 dev->sens_en_stat |= BMI2_STEP_DETECT_SEL;
1673 else
1675 break;
1679 /* Enable step counter feature */
1680 if (sensor_sel & BMI2_STEP_COUNT_SEL)
1682 rslt = set_step_counter(BMI2_ENABLE, dev);
1683 if (rslt == BMI2_OK)
1685 dev->sens_en_stat |= BMI2_STEP_COUNT_SEL;
1687 else
1689 break;
1693 /* Enable step activity feature */
1694 if (sensor_sel & BMI2_STEP_ACT_SEL)
1696 rslt = set_step_activity(BMI2_ENABLE, dev);
1697 if (rslt == BMI2_OK)
1699 dev->sens_en_stat |= BMI2_STEP_ACT_SEL;
1701 else
1703 break;
1707 /* Enable gyroscope user gain */
1708 if (sensor_sel & BMI2_GYRO_GAIN_UPDATE_SEL)
1710 rslt = set_gyro_user_gain(BMI2_ENABLE, dev);
1711 if (rslt == BMI2_OK)
1713 dev->sens_en_stat |= BMI2_GYRO_GAIN_UPDATE_SEL;
1715 else
1717 break;
1721 /* Enable wrist wear wake-up feature for wearable variant */
1722 if (sensor_sel & BMI2_WRIST_WEAR_WAKE_UP_WH_SEL)
1724 rslt = set_wrist_wear_wake_up_wh(BMI2_ENABLE, dev);
1725 if (rslt == BMI2_OK)
1727 dev->sens_en_stat |= BMI2_WRIST_WEAR_WAKE_UP_WH_SEL;
1729 else
1731 break;
1736 /* Enable Advance power save if disabled while
1737 * configuring and not when already disabled
1739 if ((aps_stat == BMI2_ENABLE) && (rslt == BMI2_OK))
1741 rslt = bmi2_set_adv_power_save(BMI2_ENABLE, dev);
1746 return rslt;
1750 * @brief This internal API disables the selected sensors/features.
1752 static int8_t sensor_disable(uint64_t sensor_sel, struct bmi2_dev *dev)
1754 /* Variable to define error */
1755 int8_t rslt;
1757 /* Variable to store register values */
1758 uint8_t reg_data = 0;
1760 /* Variable to define loop */
1761 uint8_t loop = 1;
1763 /* Variable to get the status of advance power save */
1764 uint8_t aps_stat = 0;
1766 rslt = bmi2_get_regs(BMI2_PWR_CTRL_ADDR, &reg_data, 1, dev);
1767 if (rslt == BMI2_OK)
1769 /* Disable accelerometer */
1770 if (sensor_sel & BMI2_ACCEL_SENS_SEL)
1772 reg_data = BMI2_SET_BIT_VAL0(reg_data, BMI2_ACC_EN);
1775 /* Disable gyroscope */
1776 if (sensor_sel & BMI2_GYRO_SENS_SEL)
1778 reg_data = BMI2_SET_BIT_VAL0(reg_data, BMI2_GYR_EN);
1781 /* Disable auxiliary sensor */
1782 if (sensor_sel & BMI2_AUX_SENS_SEL)
1784 reg_data = BMI2_SET_BIT_VAL0(reg_data, BMI2_AUX_EN);
1787 /* Disable temperature sensor */
1788 if (sensor_sel & BMI2_TEMP_SENS_SEL)
1790 reg_data = BMI2_SET_BIT_VAL0(reg_data, BMI2_TEMP_EN);
1793 /* Disable the sensors that are set in the power control register */
1794 if (sensor_sel & BMI2_MAIN_SENSORS)
1796 rslt = bmi2_set_regs(BMI2_PWR_CTRL_ADDR, &reg_data, 1, dev);
1800 if ((rslt == BMI2_OK) && (sensor_sel & ~(BMI2_MAIN_SENSORS)))
1802 /* Get status of advance power save mode */
1803 aps_stat = dev->aps_status;
1804 if (aps_stat == BMI2_ENABLE)
1806 /* Disable advance power save if enabled */
1807 rslt = bmi2_set_adv_power_save(BMI2_DISABLE, dev);
1810 if (rslt == BMI2_OK)
1812 while (loop--)
1814 /* Disable any-motion feature */
1815 if (sensor_sel & BMI2_ANY_MOT_SEL)
1817 rslt = set_any_motion(BMI2_DISABLE, dev);
1818 if (rslt == BMI2_OK)
1820 dev->sens_en_stat &= ~BMI2_ANY_MOT_SEL;
1822 else
1824 break;
1828 /* Disable no-motion feature */
1829 if (sensor_sel & BMI2_NO_MOT_SEL)
1831 rslt = set_no_motion(BMI2_DISABLE, dev);
1832 if (rslt == BMI2_OK)
1834 dev->sens_en_stat &= ~BMI2_NO_MOT_SEL;
1836 else
1838 break;
1842 /* Disable step detector feature */
1843 if (sensor_sel & BMI2_STEP_DETECT_SEL)
1845 rslt = set_step_detector(BMI2_DISABLE, dev);
1846 if (rslt == BMI2_OK)
1848 dev->sens_en_stat &= ~BMI2_STEP_DETECT_SEL;
1850 else
1852 break;
1856 /* Disable step counter feature */
1857 if (sensor_sel & BMI2_STEP_COUNT_SEL)
1859 rslt = set_step_counter(BMI2_DISABLE, dev);
1860 if (rslt == BMI2_OK)
1862 dev->sens_en_stat &= ~BMI2_STEP_COUNT_SEL;
1864 else
1866 break;
1870 /* Disable step activity feature */
1871 if (sensor_sel & BMI2_STEP_ACT_SEL)
1873 rslt = set_step_activity(BMI2_DISABLE, dev);
1874 if (rslt == BMI2_OK)
1876 dev->sens_en_stat &= ~BMI2_STEP_ACT_SEL;
1878 else
1880 break;
1884 /* Disable gyroscope user gain */
1885 if (sensor_sel & BMI2_GYRO_GAIN_UPDATE_SEL)
1887 rslt = set_gyro_user_gain(BMI2_DISABLE, dev);
1888 if (rslt == BMI2_OK)
1890 dev->sens_en_stat &= ~BMI2_GYRO_GAIN_UPDATE_SEL;
1892 else
1894 break;
1898 /* Disable wrist wear wake-up feature for wearable variant */
1899 if (sensor_sel & BMI2_WRIST_WEAR_WAKE_UP_WH_SEL)
1901 rslt = set_wrist_wear_wake_up_wh(BMI2_DISABLE, dev);
1902 if (rslt == BMI2_OK)
1904 dev->sens_en_stat &= ~BMI2_WRIST_WEAR_WAKE_UP_WH_SEL;
1906 else
1908 break;
1912 /* Enable Advance power save if disabled while
1913 * configuring and not when already disabled
1915 if ((aps_stat == BMI2_ENABLE) && (rslt == BMI2_OK))
1917 rslt = bmi2_set_adv_power_save(BMI2_ENABLE, dev);
1923 return rslt;
1927 * @brief This internal API is used to enable/disable any motion feature.
1929 static int8_t set_any_motion(uint8_t enable, struct bmi2_dev *dev)
1931 /* Variable to define error */
1932 int8_t rslt;
1934 /* Array to define the feature configuration */
1935 uint8_t feat_config[BMI2_FEAT_SIZE_IN_BYTES] = { 0 };
1937 /* Variable to define the array offset */
1938 uint8_t idx = 0;
1940 /* Variable to set flag */
1941 uint8_t feat_found;
1943 /* Initialize feature configuration for any-motion */
1944 struct bmi2_feature_config any_mot_config = { 0, 0, 0 };
1946 /* Search for any-motion feature and extract its configurations details */
1947 feat_found = bmi2_extract_input_feat_config(&any_mot_config, BMI2_ANY_MOTION, dev);
1948 if (feat_found)
1950 /* Get the configuration from the page where any-motion feature resides */
1951 rslt = bmi2_get_feat_config(any_mot_config.page, feat_config, dev);
1952 if (rslt == BMI2_OK)
1954 /* Define the offset for enable/disable of any-motion axes */
1955 idx = any_mot_config.start_addr + BMI2_ANY_MOT_FEAT_EN_OFFSET;
1957 /* Set the feature enable bit */
1958 feat_config[idx] = BMI2_SET_BITS(feat_config[idx], BMI2_ANY_NO_MOT_EN, enable);
1960 /* Set the configuration back to the page */
1961 rslt = bmi2_set_regs(BMI2_FEATURES_REG_ADDR, feat_config, BMI2_FEAT_SIZE_IN_BYTES, dev);
1964 else
1966 rslt = BMI2_E_INVALID_SENSOR;
1969 return rslt;
1973 * @brief This internal API is used to enable/disable no-motion feature.
1975 static int8_t set_no_motion(uint8_t enable, struct bmi2_dev *dev)
1977 /* Variable to define error */
1978 int8_t rslt;
1980 /* Array to define the feature configuration */
1981 uint8_t feat_config[BMI2_FEAT_SIZE_IN_BYTES] = { 0 };
1983 /* Variable to define the array offset */
1984 uint8_t idx = 0;
1986 /* Variable to set flag */
1987 uint8_t feat_found;
1989 /* Initialize feature configuration for no-motion */
1990 struct bmi2_feature_config no_mot_config = { 0, 0, 0 };
1992 /* Search for no-motion feature and extract its configurations details */
1993 feat_found = bmi2_extract_input_feat_config(&no_mot_config, BMI2_NO_MOTION, dev);
1994 if (feat_found)
1996 /* Get the configuration from the page where any/no-motion feature resides */
1997 rslt = bmi2_get_feat_config(no_mot_config.page, feat_config, dev);
1998 if (rslt == BMI2_OK)
2000 /* Define the offset for enable/disable of no-motion axes */
2001 idx = no_mot_config.start_addr + BMI2_NO_MOT_FEAT_EN_OFFSET;
2003 /* Set the feature enable bit */
2004 feat_config[idx] = BMI2_SET_BITS(feat_config[idx], BMI2_ANY_NO_MOT_EN, enable);
2006 /* Set the configuration back to the page */
2007 rslt = bmi2_set_regs(BMI2_FEATURES_REG_ADDR, feat_config, BMI2_FEAT_SIZE_IN_BYTES, dev);
2010 else
2012 rslt = BMI2_E_INVALID_SENSOR;
2015 return rslt;
2019 * @brief This internal API is used to enable/disable step detector feature.
2021 static int8_t set_step_detector(uint8_t enable, struct bmi2_dev *dev)
2023 /* Variable to define error */
2024 int8_t rslt;
2026 /* Array to define the feature configuration */
2027 uint8_t feat_config[BMI2_FEAT_SIZE_IN_BYTES] = { 0 };
2029 /* Variable to define the array offset */
2030 uint8_t idx = 0;
2032 /* Variable to set flag */
2033 uint8_t feat_found;
2035 /* Initialize feature configuration for step detector */
2036 struct bmi2_feature_config step_det_config = { 0, 0, 0 };
2038 /* Search for step detector feature and extract its configuration details */
2039 feat_found = bmi2_extract_input_feat_config(&step_det_config, BMI2_STEP_DETECTOR, dev);
2040 if (feat_found)
2042 /* Get the configuration from the page where step detector feature resides */
2043 rslt = bmi2_get_feat_config(step_det_config.page, feat_config, dev);
2044 if (rslt == BMI2_OK)
2046 /* Define the offset for enable/disable of step detector */
2047 idx = step_det_config.start_addr + BMI2_STEP_COUNT_FEAT_EN_OFFSET;
2049 /* Set the feature enable bit */
2050 feat_config[idx] = BMI2_SET_BITS(feat_config[idx], BMI2_STEP_DET_FEAT_EN, enable);
2052 /* Set the configuration back to the page */
2053 rslt = bmi2_set_regs(BMI2_FEATURES_REG_ADDR, feat_config, BMI2_FEAT_SIZE_IN_BYTES, dev);
2056 else
2058 rslt = BMI2_E_INVALID_SENSOR;
2061 return rslt;
2065 * @brief This internal API is used to enable/disable step counter feature.
2067 static int8_t set_step_counter(uint8_t enable, struct bmi2_dev *dev)
2069 /* Variable to define error */
2070 int8_t rslt;
2072 /* Array to define the feature configuration */
2073 uint8_t feat_config[BMI2_FEAT_SIZE_IN_BYTES] = { 0 };
2075 /* Variable to define the array offset */
2076 uint8_t idx = 0;
2078 /* Variable to set flag */
2079 uint8_t feat_found;
2081 /* Initialize feature configuration for step counter */
2082 struct bmi2_feature_config step_count_config = { 0, 0, 0 };
2084 /* Search for step counter feature and extract its configuration details */
2085 feat_found = bmi2_extract_input_feat_config(&step_count_config, BMI2_STEP_COUNTER, dev);
2086 if (feat_found)
2088 /* Get the configuration from the page where step-counter feature resides */
2089 rslt = bmi2_get_feat_config(step_count_config.page, feat_config, dev);
2090 if (rslt == BMI2_OK)
2092 /* Define the offset for enable/disable of step counter */
2093 idx = step_count_config.start_addr + BMI2_STEP_COUNT_FEAT_EN_OFFSET;
2095 /* Set the feature enable bit */
2096 feat_config[idx] = BMI2_SET_BITS(feat_config[idx], BMI2_STEP_COUNT_FEAT_EN, enable);
2098 /* Set the configuration back to the page */
2099 rslt = bmi2_set_regs(BMI2_FEATURES_REG_ADDR, feat_config, BMI2_FEAT_SIZE_IN_BYTES, dev);
2102 else
2104 rslt = BMI2_E_INVALID_SENSOR;
2107 return rslt;
2111 * @brief This internal API is used to enable/disable step activity detection.
2113 static int8_t set_step_activity(uint8_t enable, struct bmi2_dev *dev)
2115 /* Variable to define error */
2116 int8_t rslt;
2118 /* Array to define the feature configuration */
2119 uint8_t feat_config[BMI2_FEAT_SIZE_IN_BYTES] = { 0 };
2121 /* Variable to define the array offset */
2122 uint8_t idx = 0;
2124 /* Variable to set flag */
2125 uint8_t feat_found;
2127 /* Initialize feature configuration for step activity */
2128 struct bmi2_feature_config step_act_config = { 0, 0, 0 };
2130 /* Search for step activity feature and extract its configuration details */
2131 feat_found = bmi2_extract_input_feat_config(&step_act_config, BMI2_STEP_ACTIVITY, dev);
2132 if (feat_found)
2134 /* Get the configuration from the page where step-activity
2135 * feature resides
2137 rslt = bmi2_get_feat_config(step_act_config.page, feat_config, dev);
2138 if (rslt == BMI2_OK)
2140 /* Define the offset for enable/disable of step activity */
2141 idx = step_act_config.start_addr + BMI2_STEP_COUNT_FEAT_EN_OFFSET;
2143 /* Set the feature enable bit */
2144 feat_config[idx] = BMI2_SET_BITS(feat_config[idx], BMI2_STEP_ACT_FEAT_EN, enable);
2146 /* Set the configuration back to the page */
2147 rslt = bmi2_set_regs(BMI2_FEATURES_REG_ADDR, feat_config, BMI2_FEAT_SIZE_IN_BYTES, dev);
2150 else
2152 rslt = BMI2_E_INVALID_SENSOR;
2155 return rslt;
2159 * @brief This internal API enables the wrist wear wake up feature.
2161 static int8_t set_wrist_wear_wake_up_wh(uint8_t enable, struct bmi2_dev *dev)
2163 /* Variable to define error */
2164 int8_t rslt;
2166 /* Array to define the feature configuration */
2167 uint8_t feat_config[BMI2_FEAT_SIZE_IN_BYTES] = { 0 };
2169 /* Variable to define the array offset */
2170 uint8_t idx = 0;
2172 /* Variable to set flag */
2173 uint8_t feat_found;
2175 /* Initialize feature configuration for wrist wear wake up */
2176 struct bmi2_feature_config wrist_wake_up_cfg = { 0, 0, 0 };
2178 /* Search for wrist wear wake up and extract its configuration details */
2179 feat_found = bmi2_extract_input_feat_config(&wrist_wake_up_cfg, BMI2_WRIST_WEAR_WAKE_UP_WH, dev);
2180 if (feat_found)
2182 /* Get the configuration from the page where wrist wear wake up
2183 * feature resides
2185 rslt = bmi2_get_feat_config(wrist_wake_up_cfg.page, feat_config, dev);
2186 if (rslt == BMI2_OK)
2188 /* Define the offset for enable/disable of wrist wear wake up */
2189 idx = wrist_wake_up_cfg.start_addr;
2191 /* Set the feature enable bit */
2192 feat_config[idx] = BMI2_SET_BITS(feat_config[idx], BMI2_WRIST_WEAR_WAKE_UP_FEAT_EN, enable);
2194 /* Set the configuration back to the page */
2195 rslt = bmi2_set_regs(BMI2_FEATURES_REG_ADDR, feat_config, BMI2_FEAT_SIZE_IN_BYTES, dev);
2198 else
2200 rslt = BMI2_E_INVALID_SENSOR;
2203 return rslt;
2207 * @brief This internal API is used to enable/disable gyroscope user gain
2208 * feature.
2210 static int8_t set_gyro_user_gain(uint8_t enable, struct bmi2_dev *dev)
2212 /* Variable to define error */
2213 int8_t rslt;
2215 /* Array to define the feature configuration */
2216 uint8_t feat_config[BMI2_FEAT_SIZE_IN_BYTES] = { 0 };
2218 /* Variable to define the array offset */
2219 uint8_t idx = 0;
2221 /* Variable to set flag */
2222 uint8_t feat_found;
2224 /* Initialize feature configuration for gyroscope user gain */
2225 struct bmi2_feature_config gyr_user_gain_cfg = { 0, 0, 0 };
2227 /* Search for user gain feature and extract its configuration details */
2228 feat_found = bmi2_extract_input_feat_config(&gyr_user_gain_cfg, BMI2_GYRO_GAIN_UPDATE, dev);
2229 if (feat_found)
2231 /* Get the configuration from the page where user gain feature resides */
2232 rslt = bmi2_get_feat_config(gyr_user_gain_cfg.page, feat_config, dev);
2233 if (rslt == BMI2_OK)
2235 /* Define the offset for enable/disable of user gain */
2236 idx = gyr_user_gain_cfg.start_addr + BMI2_GYR_USER_GAIN_FEAT_EN_OFFSET;
2238 /* Set the feature enable bit */
2239 feat_config[idx] = BMI2_SET_BITS(feat_config[idx], BMI2_GYR_USER_GAIN_FEAT_EN, enable);
2241 /* Set the configuration back to the page */
2242 rslt = bmi2_set_regs(BMI2_FEATURES_REG_ADDR, feat_config, BMI2_FEAT_SIZE_IN_BYTES, dev);
2245 else
2247 rslt = BMI2_E_INVALID_SENSOR;
2250 return rslt;
2254 * @brief This internal API sets any-motion configurations like axes select,
2255 * duration, threshold and output-configuration.
2257 static int8_t set_any_motion_config(const struct bmi2_any_motion_config *config, struct bmi2_dev *dev)
2259 /* Variable to define error */
2260 int8_t rslt;
2262 /* Array to define the feature configuration */
2263 uint8_t feat_config[BMI2_FEAT_SIZE_IN_BYTES] = { 0 };
2265 /* Variable to define the array offset */
2266 uint8_t idx = 0;
2268 /* Variable to define count */
2269 uint8_t index = 0;
2271 /* Variable to set flag */
2272 uint8_t feat_found;
2274 /* Initialize feature configuration for any motion */
2275 struct bmi2_feature_config any_mot_config = { 0, 0, 0 };
2277 /* Copy the feature configuration address to a local pointer */
2278 uint16_t *data_p = (uint16_t *) (void *)feat_config;
2280 /* Search for any-motion feature and extract its configuration details */
2281 feat_found = bmi2_extract_input_feat_config(&any_mot_config, BMI2_ANY_MOTION, dev);
2282 if (feat_found)
2284 /* Get the configuration from the page where any-motion feature resides */
2285 rslt = bmi2_get_feat_config(any_mot_config.page, feat_config, dev);
2286 if (rslt == BMI2_OK)
2288 /* Define the offset in bytes for any-motion select */
2289 idx = any_mot_config.start_addr;
2291 /* Get offset in words since all the features are set in words length */
2292 idx = idx / 2;
2294 /* Set duration */
2295 *(data_p + idx) = BMI2_SET_BIT_POS0(*(data_p + idx), BMI2_ANY_NO_MOT_DUR, config->duration);
2297 /* Set x-select */
2298 *(data_p + idx) = BMI2_SET_BITS(*(data_p + idx), BMI2_ANY_NO_MOT_X_SEL, config->select_x);
2300 /* Set y-select */
2301 *(data_p + idx) = BMI2_SET_BITS(*(data_p + idx), BMI2_ANY_NO_MOT_Y_SEL, config->select_y);
2303 /* Set z-select */
2304 *(data_p + idx) = BMI2_SET_BITS(*(data_p + idx), BMI2_ANY_NO_MOT_Z_SEL, config->select_z);
2306 /* Increment offset by 1 word to set threshold and output configuration */
2307 idx++;
2309 /* Set threshold */
2310 *(data_p + idx) = BMI2_SET_BIT_POS0(*(data_p + idx), BMI2_ANY_NO_MOT_THRES, config->threshold);
2312 /* Increment offset by 1 more word to get the total length in words */
2313 idx++;
2315 /* Get total length in bytes to copy from local pointer to the array */
2316 idx = (uint8_t)(idx * 2) - any_mot_config.start_addr;
2318 /* Copy the bytes to be set back to the array */
2319 for (index = 0; index < idx; index++)
2321 feat_config[any_mot_config.start_addr +
2322 index] = *((uint8_t *) data_p + any_mot_config.start_addr + index);
2325 /* Set the configuration back to the page */
2326 rslt = bmi2_set_regs(BMI2_FEATURES_REG_ADDR, feat_config, BMI2_FEAT_SIZE_IN_BYTES, dev);
2329 else
2331 rslt = BMI2_E_INVALID_SENSOR;
2334 return rslt;
2338 * @brief This internal API sets no-motion configurations like axes select,
2339 * duration, threshold and output-configuration.
2341 static int8_t set_no_motion_config(const struct bmi2_no_motion_config *config, struct bmi2_dev *dev)
2343 /* Variable to define error */
2344 int8_t rslt;
2346 /* Array to define the feature configuration */
2347 uint8_t feat_config[BMI2_FEAT_SIZE_IN_BYTES] = { 0 };
2349 /* Variable to define the array offset */
2350 uint8_t idx = 0;
2352 /* Variable to define count */
2353 uint8_t index = 0;
2355 /* Variable to set flag */
2356 uint8_t feat_found;
2358 /* Initialize feature configuration for no-motion */
2359 struct bmi2_feature_config no_mot_config = { 0, 0, 0 };
2361 /* Copy the feature configuration address to a local pointer */
2362 uint16_t *data_p = (uint16_t *) (void *)feat_config;
2364 /* Search for no-motion feature and extract its configuration details */
2365 feat_found = bmi2_extract_input_feat_config(&no_mot_config, BMI2_NO_MOTION, dev);
2366 if (feat_found)
2368 /* Get the configuration from the page where no-motion feature resides */
2369 rslt = bmi2_get_feat_config(no_mot_config.page, feat_config, dev);
2370 if (rslt == BMI2_OK)
2372 /* Define the offset in bytes for no-motion select */
2373 idx = no_mot_config.start_addr;
2375 /* Get offset in words since all the features are set in words length */
2376 idx = idx / 2;
2378 /* Set duration */
2379 *(data_p + idx) = BMI2_SET_BIT_POS0(*(data_p + idx), BMI2_ANY_NO_MOT_DUR, config->duration);
2381 /* Set x-select */
2382 *(data_p + idx) = BMI2_SET_BITS(*(data_p + idx), BMI2_ANY_NO_MOT_X_SEL, config->select_x);
2384 /* Set y-select */
2385 *(data_p + idx) = BMI2_SET_BITS(*(data_p + idx), BMI2_ANY_NO_MOT_Y_SEL, config->select_y);
2387 /* Set z-select */
2388 *(data_p + idx) = BMI2_SET_BITS(*(data_p + idx), BMI2_ANY_NO_MOT_Z_SEL, config->select_z);
2390 /* Increment offset by 1 word to set threshold and output configuration */
2391 idx++;
2393 /* Set threshold */
2394 *(data_p + idx) = BMI2_SET_BIT_POS0(*(data_p + idx), BMI2_ANY_NO_MOT_THRES, config->threshold);
2396 /* Increment offset by 1 more word to get the total length in words */
2397 idx++;
2399 /* Get total length in bytes to copy from local pointer to the array */
2400 idx = (uint8_t)(idx * 2) - no_mot_config.start_addr;
2402 /* Copy the bytes to be set back to the array */
2403 for (index = 0; index < idx; index++)
2405 feat_config[no_mot_config.start_addr +
2406 index] = *((uint8_t *) data_p + no_mot_config.start_addr + index);
2409 /* Set the configuration back to the page */
2410 rslt = bmi2_set_regs(BMI2_FEATURES_REG_ADDR, feat_config, BMI2_FEAT_SIZE_IN_BYTES, dev);
2413 else
2415 rslt = BMI2_E_INVALID_SENSOR;
2418 return rslt;
2422 * @brief This internal API sets step counter parameter configurations.
2424 static int8_t set_step_count_params_config(const uint16_t *step_count_params, struct bmi2_dev *dev)
2426 /* Variable to define error */
2427 int8_t rslt = BMI2_OK;
2429 /* Array to define the feature configuration */
2430 uint8_t feat_config[BMI2_FEAT_SIZE_IN_BYTES] = { 0 };
2432 /* Variable to define index */
2433 uint8_t index = 0;
2435 /* Variable to set flag */
2436 uint8_t feat_found;
2438 /* Initialize feature configuration for step counter parameters */
2439 struct bmi2_feature_config step_params_config = { 0, 0, 0 };
2441 /* Variable to index the page number */
2442 uint8_t page_idx;
2444 /* Variable to define the start page */
2445 uint8_t start_page;
2447 /* Variable to define start address of the parameters */
2448 uint8_t start_addr;
2450 /* Variable to define number of bytes */
2451 uint8_t n_bytes = (BMI2_STEP_CNT_N_PARAMS * 2);
2453 /* Variable to store number of pages */
2454 uint8_t n_pages = (n_bytes / 16);
2456 /* Variable to define the end page */
2457 uint8_t end_page;
2459 /* Variable to define the remaining bytes to be read */
2460 uint8_t remain_len;
2462 /* Variable to define the maximum words(16 bytes or 8 words) to be read in a page */
2463 uint8_t max_len = 8;
2465 /* Variable index bytes in a page */
2466 uint8_t page_byte_idx;
2468 /* Variable to index the parameters */
2469 uint8_t param_idx = 0;
2471 /* Copy the feature configuration address to a local pointer */
2472 uint16_t *data_p = (uint16_t *) (void *)feat_config;
2474 /* Search for step counter parameter feature and extract its configuration details */
2475 feat_found = bmi2_extract_input_feat_config(&step_params_config, BMI2_STEP_COUNTER_PARAMS, dev);
2476 if (feat_found)
2478 /* Get the start page for the step counter parameters */
2479 start_page = step_params_config.page;
2481 /* Get the end page for the step counter parameters */
2482 end_page = start_page + n_pages;
2484 /* Get the start address for the step counter parameters */
2485 start_addr = step_params_config.start_addr;
2487 /* Get the remaining length of bytes to be read */
2488 remain_len = (uint8_t)((n_bytes - (n_pages * 16)) + start_addr);
2489 for (page_idx = start_page; page_idx <= end_page; page_idx++)
2491 /* Get the configuration from the respective page */
2492 rslt = bmi2_get_feat_config(page_idx, feat_config, dev);
2493 if (rslt == BMI2_OK)
2495 /* Start from address 0x00 when switched to next page */
2496 if (page_idx > start_page)
2498 start_addr = 0;
2501 /* Remaining number of words to be read in the page */
2502 if (page_idx == end_page)
2504 max_len = (remain_len / 2);
2507 /* Get offset in words since all the features are set in words length */
2508 page_byte_idx = start_addr / 2;
2509 for (; page_byte_idx < max_len;)
2511 /* Set parameters 1 to 25 */
2512 *(data_p + page_byte_idx) = BMI2_SET_BIT_POS0(*(data_p + page_byte_idx),
2513 BMI2_STEP_COUNT_PARAMS,
2514 step_count_params[param_idx]);
2516 /* Increment offset by 1 word to set to the next parameter */
2517 page_byte_idx++;
2519 /* Increment to next parameter */
2520 param_idx++;
2523 /* Get total length in bytes to copy from local pointer to the array */
2524 page_byte_idx = (uint8_t)(page_byte_idx * 2) - step_params_config.start_addr;
2526 /* Copy the bytes to be set back to the array */
2527 for (index = 0; index < page_byte_idx; index++)
2529 feat_config[step_params_config.start_addr +
2530 index] = *((uint8_t *) data_p + step_params_config.start_addr + index);
2533 /* Set the configuration back to the page */
2534 rslt = bmi2_set_regs(BMI2_FEATURES_REG_ADDR, feat_config, BMI2_FEAT_SIZE_IN_BYTES, dev);
2538 else
2540 rslt = BMI2_E_INVALID_SENSOR;
2543 return rslt;
2546 /* @brief This internal API sets step counter configurations like water-mark
2547 * level, reset-counter and output-configuration step detector and activity.
2549 static int8_t set_step_config(const struct bmi2_step_config *config, struct bmi2_dev *dev)
2551 /* Variable to define error */
2552 int8_t rslt;
2554 /* Array to define the feature configuration */
2555 uint8_t feat_config[BMI2_FEAT_SIZE_IN_BYTES] = { 0 };
2557 /* Variable to define the array offset */
2558 uint8_t idx = 0;
2560 /* Variable to define index */
2561 uint8_t index = 0;
2563 /* Variable to set flag */
2564 uint8_t feat_found;
2566 /* Initialize feature configuration for step counter 4 */
2567 struct bmi2_feature_config step_count_config = { 0, 0, 0 };
2569 /* Copy the feature configuration address to a local pointer */
2570 uint16_t *data_p = (uint16_t *) (void *)feat_config;
2572 /* Search for step counter feature and extract its configuration details */
2573 feat_found = bmi2_extract_input_feat_config(&step_count_config, BMI2_STEP_COUNTER, dev);
2574 if (feat_found)
2576 /* Get the configuration from the page where step counter resides */
2577 rslt = bmi2_get_feat_config(step_count_config.page, feat_config, dev);
2578 if (rslt == BMI2_OK)
2580 /* Define the offset in bytes */
2581 idx = step_count_config.start_addr;
2583 /* Get offset in words since all the features are set in words length */
2584 idx = idx / 2;
2586 /* Set water-mark level */
2587 *(data_p + idx) = BMI2_SET_BIT_POS0(*(data_p + idx), BMI2_STEP_COUNT_WM_LEVEL, config->watermark_level);
2589 /* Set reset-counter */
2590 *(data_p + idx) = BMI2_SET_BITS(*(data_p + idx), BMI2_STEP_COUNT_RST_CNT, config->reset_counter);
2592 /* Increment offset by 1 word to set output
2593 * configuration of step detector and step activity
2595 idx++;
2597 /* Set step buffer size */
2598 *(data_p + idx) = BMI2_SET_BITS(*(data_p + idx), BMI2_STEP_BUFFER_SIZE, config->step_buffer_size);
2600 /* Increment offset by 1 more word to get the total length in words */
2601 idx++;
2603 /* Get total length in bytes to copy from local pointer to the array */
2604 idx = (uint8_t)(idx * 2) - step_count_config.start_addr;
2606 /* Copy the bytes to be set back to the array */
2607 for (index = 0; index < idx; index++)
2609 feat_config[step_count_config.start_addr +
2610 index] = *((uint8_t *) data_p + step_count_config.start_addr + index);
2613 /* Set the configuration back to the page */
2614 rslt = bmi2_set_regs(BMI2_FEATURES_REG_ADDR, feat_config, BMI2_FEAT_SIZE_IN_BYTES, dev);
2617 else
2619 rslt = BMI2_E_INVALID_SENSOR;
2622 return rslt;
2626 * @brief This internal API sets wrist wear wake-up configurations like
2627 * output-configuration for wearable variant.
2629 static int8_t set_wrist_wear_wake_up_wh_config(const struct bmi2_wrist_wear_wake_up_wh_config *config,
2630 struct bmi2_dev *dev)
2632 /* Variable to define error */
2633 int8_t rslt;
2635 /* Array to define the feature configuration */
2636 uint8_t feat_config[BMI2_FEAT_SIZE_IN_BYTES] = { 0 };
2638 /* Variable to define the array offset */
2639 uint8_t idx = 0;
2641 /* Variable to define index */
2642 uint8_t index = 0;
2644 /* Variable to set flag */
2645 uint8_t feat_found;
2647 /* Initialize feature configuration for wrist wear wake-up */
2648 struct bmi2_feature_config wrist_wake_up_config = { 0, 0, 0 };
2650 /* Copy the feature configuration address to a local pointer */
2651 uint16_t *data_p = (uint16_t *) (void *)feat_config;
2653 /* Search for wrist wear wake-up feature and extract its configuration details */
2654 feat_found = bmi2_extract_input_feat_config(&wrist_wake_up_config, BMI2_WRIST_WEAR_WAKE_UP_WH, dev);
2655 if (feat_found)
2657 /* Get the configuration from the page where wrist wear wake-up feature resides */
2658 rslt = bmi2_get_feat_config(wrist_wake_up_config.page, feat_config, dev);
2659 if (rslt == BMI2_OK)
2661 /* Define the offset in bytes for wrist wear wake-up select */
2662 idx = wrist_wake_up_config.start_addr;
2664 /* Get offset in words since all the features are set in words length */
2665 idx = idx / 2;
2667 *(data_p + idx) = config->min_angle_focus;
2669 /* Increment offset by 1 more word to set min_angle_nonfocus */
2670 idx++;
2671 *(data_p + idx) = config->min_angle_nonfocus;
2673 /* Increment offset by 1 more word to set angle landscape right and angle landscape left */
2674 idx++;
2675 *(data_p + idx) = BMI2_SET_BIT_POS0(*(data_p + idx), BMI2_WRIST_WAKE_UP_ANGLE_LR, config->angle_lr);
2676 *(data_p + idx) = BMI2_SET_BITS(*(data_p + idx), BMI2_WRIST_WAKE_UP_ANGLE_LL, config->angle_ll);
2678 /* Increment offset by 1 more word to set angle portrait down and angle portrait left */
2679 idx++;
2680 *(data_p + idx) = BMI2_SET_BIT_POS0(*(data_p + idx), BMI2_WRIST_WAKE_UP_ANGLE_PD, config->angle_pd);
2681 *(data_p + idx) = BMI2_SET_BITS(*(data_p + idx), BMI2_WRIST_WAKE_UP_ANGLE_PU, config->angle_pu);
2683 /* Increment offset by 1 more word to set min duration moved and min duration quite */
2684 idx++;
2685 *(data_p + idx) = BMI2_SET_BIT_POS0(*(data_p + idx), BMI2_WRIST_WAKE_UP_MIN_DUR_MOVED, config->min_dur_mov);
2686 *(data_p + idx) = BMI2_SET_BITS(*(data_p + idx), BMI2_WRIST_WAKE_UP_MIN_DUR_QUITE, config->min_dur_quite);
2688 /* Increment offset by 1 more word to get the total length in words */
2689 idx++;
2691 /* Get total length in bytes to copy from local pointer to the array */
2692 idx = (uint8_t)(idx * 2) - wrist_wake_up_config.start_addr;
2694 /* Copy the bytes to be set back to the array */
2695 for (index = 0; index < idx; index++)
2697 feat_config[wrist_wake_up_config.start_addr +
2698 index] = *((uint8_t *) data_p + wrist_wake_up_config.start_addr + index);
2701 /* Set the configuration back to the page */
2702 rslt = bmi2_set_regs(BMI2_FEATURES_REG_ADDR, feat_config, BMI2_FEAT_SIZE_IN_BYTES, dev);
2705 else
2707 rslt = BMI2_E_INVALID_SENSOR;
2710 return rslt;
2714 * @brief This internal API gets any-motion configurations like axes select,
2715 * duration, threshold and output-configuration.
2717 static int8_t get_any_motion_config(struct bmi2_any_motion_config *config, struct bmi2_dev *dev)
2719 /* Variable to define error */
2720 int8_t rslt;
2722 /* Array to define the feature configuration */
2723 uint8_t feat_config[BMI2_FEAT_SIZE_IN_BYTES] = { 0 };
2725 /* Variable to define the array offset */
2726 uint8_t idx = 0;
2728 /* Variable to define LSB */
2729 uint16_t lsb;
2731 /* Variable to define MSB */
2732 uint16_t msb;
2734 /* Variable to define a word */
2735 uint16_t lsb_msb;
2737 /* Variable to set flag */
2738 uint8_t feat_found;
2740 /* Initialize feature configuration for any-motion */
2741 struct bmi2_feature_config any_mot_config = { 0, 0, 0 };
2743 /* Search for any-motion feature and extract its configuration details */
2744 feat_found = bmi2_extract_input_feat_config(&any_mot_config, BMI2_ANY_MOTION, dev);
2745 if (feat_found)
2747 /* Get the configuration from the page where any-motion feature resides */
2748 rslt = bmi2_get_feat_config(any_mot_config.page, feat_config, dev);
2749 if (rslt == BMI2_OK)
2751 /* Define the offset for feature enable for any-motion */
2752 idx = any_mot_config.start_addr;
2754 /* Get word to calculate duration, x, y and z select */
2755 lsb = (uint16_t) feat_config[idx++];
2756 msb = ((uint16_t) feat_config[idx++] << 8);
2757 lsb_msb = lsb | msb;
2759 /* Get duration */
2760 config->duration = lsb_msb & BMI2_ANY_NO_MOT_DUR_MASK;
2762 /* Get x-select */
2763 config->select_x = (lsb_msb & BMI2_ANY_NO_MOT_X_SEL_MASK) >> BMI2_ANY_NO_MOT_X_SEL_POS;
2765 /* Get y-select */
2766 config->select_y = (lsb_msb & BMI2_ANY_NO_MOT_Y_SEL_MASK) >> BMI2_ANY_NO_MOT_Y_SEL_POS;
2768 /* Get z-select */
2769 config->select_z = (lsb_msb & BMI2_ANY_NO_MOT_Z_SEL_MASK) >> BMI2_ANY_NO_MOT_Z_SEL_POS;
2771 /* Get word to calculate threshold, output configuration from the same word */
2772 lsb = (uint16_t) feat_config[idx++];
2773 msb = ((uint16_t) feat_config[idx++] << 8);
2774 lsb_msb = lsb | msb;
2776 /* Get threshold */
2777 config->threshold = lsb_msb & BMI2_ANY_NO_MOT_THRES_MASK;
2780 else
2782 rslt = BMI2_E_INVALID_SENSOR;
2785 return rslt;
2789 * @brief This internal API gets no-motion configurations like axes select,
2790 * duration, threshold and output-configuration.
2792 static int8_t get_no_motion_config(struct bmi2_no_motion_config *config, struct bmi2_dev *dev)
2794 /* Variable to define error */
2795 int8_t rslt;
2797 /* Array to define the feature configuration */
2798 uint8_t feat_config[BMI2_FEAT_SIZE_IN_BYTES] = { 0 };
2800 /* Variable to define the array offset */
2801 uint8_t idx = 0;
2803 /* Variable to define LSB */
2804 uint16_t lsb = 0;
2806 /* Variable to define MSB */
2807 uint16_t msb = 0;
2809 /* Variable to define a word */
2810 uint16_t lsb_msb = 0;
2812 /* Variable to set flag */
2813 uint8_t feat_found;
2815 /* Initialize feature configuration for no-motion */
2816 struct bmi2_feature_config no_mot_config = { 0, 0, 0 };
2818 /* Search for no-motion feature and extract its configuration details */
2819 feat_found = bmi2_extract_input_feat_config(&no_mot_config, BMI2_NO_MOTION, dev);
2820 if (feat_found)
2822 /* Get the configuration from the page where no-motion feature resides */
2823 rslt = bmi2_get_feat_config(no_mot_config.page, feat_config, dev);
2824 if (rslt == BMI2_OK)
2826 /* Define the offset for feature enable for no-motion */
2827 idx = no_mot_config.start_addr;
2829 /* Get word to calculate duration, x, y and z select */
2830 lsb = (uint16_t) feat_config[idx++];
2831 msb = ((uint16_t) feat_config[idx++] << 8);
2832 lsb_msb = lsb | msb;
2834 /* Get duration */
2835 config->duration = lsb_msb & BMI2_ANY_NO_MOT_DUR_MASK;
2837 /* Get x-select */
2838 config->select_x = (lsb_msb & BMI2_ANY_NO_MOT_X_SEL_MASK) >> BMI2_ANY_NO_MOT_X_SEL_POS;
2840 /* Get y-select */
2841 config->select_y = (lsb_msb & BMI2_ANY_NO_MOT_Y_SEL_MASK) >> BMI2_ANY_NO_MOT_Y_SEL_POS;
2843 /* Get z-select */
2844 config->select_z = (lsb_msb & BMI2_ANY_NO_MOT_Z_SEL_MASK) >> BMI2_ANY_NO_MOT_Z_SEL_POS;
2846 /* Get word to calculate threshold, output configuration from the same word */
2847 lsb = (uint16_t) feat_config[idx++];
2848 msb = ((uint16_t) feat_config[idx++] << 8);
2849 lsb_msb = lsb | msb;
2851 /* Get threshold */
2852 config->threshold = lsb_msb & BMI2_ANY_NO_MOT_THRES_MASK;
2855 else
2857 rslt = BMI2_E_INVALID_SENSOR;
2860 return rslt;
2864 * @brief This internal API gets step counter parameter configurations.
2866 static int8_t get_step_count_params_config(uint16_t *step_count_params, struct bmi2_dev *dev)
2868 /* Variable to define error */
2869 int8_t rslt = BMI2_OK;
2871 /* Array to define the feature configuration */
2872 uint8_t feat_config[BMI2_FEAT_SIZE_IN_BYTES] = { 0 };
2874 /* Variable to set flag */
2875 uint8_t feat_found;
2877 /* Variable to define LSB */
2878 uint16_t lsb = 0;
2880 /* Variable to define MSB */
2881 uint16_t msb = 0;
2883 /* Variable to define a word */
2884 uint16_t lsb_msb = 0;
2886 /* Initialize feature configuration for step counter 1 */
2887 struct bmi2_feature_config step_params_config = { 0, 0, 0 };
2889 /* Variable to index the page number */
2890 uint8_t page_idx;
2892 /* Variable to define the start page */
2893 uint8_t start_page;
2895 /* Variable to define start address of the parameters */
2896 uint8_t start_addr;
2898 /* Variable to define number of bytes */
2899 uint8_t n_bytes = (BMI2_STEP_CNT_N_PARAMS * 2);
2901 /* Variable to store number of pages */
2902 uint8_t n_pages = (n_bytes / 16);
2904 /* Variable to define the end page */
2905 uint8_t end_page;
2907 /* Variable to define the remaining bytes to be read */
2908 uint8_t remain_len;
2910 /* Variable to define the maximum words to be read in a page */
2911 uint8_t max_len = BMI2_FEAT_SIZE_IN_BYTES;
2913 /* Variable index bytes in a page */
2914 uint8_t page_byte_idx;
2916 /* Variable to index the parameters */
2917 uint8_t param_idx = 0;
2919 /* Search for step counter parameter feature and extract its configuration details */
2920 feat_found = bmi2_extract_input_feat_config(&step_params_config, BMI2_STEP_COUNTER_PARAMS, dev);
2921 if (feat_found)
2923 /* Get the start page for the step counter parameters */
2924 start_page = step_params_config.page;
2926 /* Get the end page for the step counter parameters */
2927 end_page = start_page + n_pages;
2929 /* Get the start address for the step counter parameters */
2930 start_addr = step_params_config.start_addr;
2932 /* Get the remaining length of bytes to be read */
2933 remain_len = (uint8_t)((n_bytes - (n_pages * 16)) + start_addr);
2934 for (page_idx = start_page; page_idx <= end_page; page_idx++)
2936 /* Get the configuration from the respective page */
2937 rslt = bmi2_get_feat_config(page_idx, feat_config, dev);
2938 if (rslt == BMI2_OK)
2940 /* Start from address 0x00 when switched to next page */
2941 if (page_idx > start_page)
2943 start_addr = 0;
2946 /* Remaining number of bytes to be read in the page */
2947 if (page_idx == end_page)
2949 max_len = remain_len;
2952 /* Get the offset */
2953 page_byte_idx = start_addr;
2954 while (page_byte_idx < max_len)
2956 /* Get word to calculate the parameter*/
2957 lsb = (uint16_t) feat_config[page_byte_idx++];
2958 if (page_byte_idx < max_len)
2960 msb = ((uint16_t) feat_config[page_byte_idx++] << 8);
2963 lsb_msb = lsb | msb;
2965 /* Get parameters 1 to 25 */
2966 step_count_params[param_idx] = lsb_msb & BMI2_STEP_COUNT_PARAMS_MASK;
2968 /* Increment to next parameter */
2969 param_idx++;
2974 else
2976 rslt = BMI2_E_INVALID_SENSOR;
2979 return rslt;
2983 * @brief This internal API gets step counter/detector/activity configurations.
2985 static int8_t get_step_config(struct bmi2_step_config *config, struct bmi2_dev *dev)
2987 /* Variable to define error */
2988 int8_t rslt;
2990 /* Array to define the feature configuration */
2991 uint8_t feat_config[BMI2_FEAT_SIZE_IN_BYTES] = { 0 };
2993 /* Variable to define the array offset */
2994 uint8_t idx = 0;
2996 /* Variable to define LSB */
2997 uint16_t lsb = 0;
2999 /* Variable to define MSB */
3000 uint16_t msb = 0;
3002 /* Variable to define a word */
3003 uint16_t lsb_msb = 0;
3005 /* Variable to set flag */
3006 uint8_t feat_found;
3008 /* Initialize feature configuration for step counter */
3009 struct bmi2_feature_config step_count_config = { 0, 0, 0 };
3011 /* Search for step counter 4 feature and extract its configuration details */
3012 feat_found = bmi2_extract_input_feat_config(&step_count_config, BMI2_STEP_COUNTER, dev);
3013 if (feat_found)
3015 /* Get the configuration from the page where step counter 4 parameter resides */
3016 rslt = bmi2_get_feat_config(step_count_config.page, feat_config, dev);
3017 if (rslt == BMI2_OK)
3019 /* Define the offset for feature enable for step counter/detector/activity */
3020 idx = step_count_config.start_addr;
3022 /* Get word to calculate water-mark level and reset counter */
3023 lsb = (uint16_t) feat_config[idx++];
3024 msb = ((uint16_t) feat_config[idx++] << 8);
3025 lsb_msb = lsb | msb;
3027 /* Get water-mark level */
3028 config->watermark_level = lsb_msb & BMI2_STEP_COUNT_WM_LEVEL_MASK;
3030 /* Get reset counter */
3031 config->reset_counter = (lsb_msb & BMI2_STEP_COUNT_RST_CNT_MASK) >> BMI2_STEP_COUNT_RST_CNT_POS;
3033 /* Get word to calculate output configuration of step detector and activity */
3034 lsb = (uint16_t) feat_config[idx++];
3035 msb = ((uint16_t) feat_config[idx++] << 8);
3036 lsb_msb = lsb | msb;
3038 config->step_buffer_size = (lsb_msb & BMI2_STEP_BUFFER_SIZE_MASK) >> BMI2_STEP_BUFFER_SIZE_POS;
3041 else
3043 rslt = BMI2_E_INVALID_SENSOR;
3046 return rslt;
3050 * @brief This internal API gets wrist wear wake-up configurations like min_angle_focus,
3051 * min_angle_nonfocus for wearable variant.
3053 static int8_t get_wrist_wear_wake_up_wh_config(struct bmi2_wrist_wear_wake_up_wh_config *config, struct bmi2_dev *dev)
3055 /* Variable to define error */
3056 int8_t rslt;
3058 /* Array to define the feature configuration */
3059 uint8_t feat_config[BMI2_FEAT_SIZE_IN_BYTES] = { 0 };
3061 /* Variable to define the array offset */
3062 uint8_t idx = 0;
3064 /* Variable to set flag */
3065 uint8_t feat_found;
3067 /* Initialize feature configuration for wrist wear wake-up */
3068 struct bmi2_feature_config wrist_wake_up_config = { 0, 0, 0 };
3070 /* Copy the feature configuration address to a local pointer */
3071 uint16_t *data_p = (uint16_t *) (void *)feat_config;
3073 /* Search for wrist wear wake-up feature and extract its configuration details */
3074 feat_found = bmi2_extract_input_feat_config(&wrist_wake_up_config, BMI2_WRIST_WEAR_WAKE_UP_WH, dev);
3075 if (feat_found)
3077 /* Get the configuration from the page where wrist wear wake-up feature resides */
3078 rslt = bmi2_get_feat_config(wrist_wake_up_config.page, feat_config, dev);
3079 if (rslt == BMI2_OK)
3081 /* Define the offset in bytes for wrist wear wake-up select */
3082 idx = wrist_wake_up_config.start_addr;
3084 /* Get offset in words since all the features are set in words length */
3085 idx = idx / 2;
3087 config->min_angle_focus = *(data_p + idx);
3089 /* Increment the offset value by 1 word to get min_angle_nonfocus */
3090 idx++;
3091 config->min_angle_nonfocus = *(data_p + idx);
3093 /* Increment the offset value by 1 word to get angle landscape right and angle landscape left */
3094 idx++;
3095 config->angle_lr = BMI2_GET_BIT_POS0(*(data_p + idx), BMI2_WRIST_WAKE_UP_ANGLE_LR);
3096 config->angle_ll = BMI2_GET_BITS(*(data_p + idx), BMI2_WRIST_WAKE_UP_ANGLE_LL);
3098 /* Increment the offset value by 1 word to get angle portrait down and angle portrait up */
3099 idx++;
3100 config->angle_pd = BMI2_GET_BIT_POS0(*(data_p + idx), BMI2_WRIST_WAKE_UP_ANGLE_PD);
3101 config->angle_pu = BMI2_GET_BITS(*(data_p + idx), BMI2_WRIST_WAKE_UP_ANGLE_PU);
3103 /* Increment the offset value by 1 word to get min duration quite and min duration moved */
3104 idx++;
3105 config->min_dur_mov = BMI2_GET_BIT_POS0(*(data_p + idx), BMI2_WRIST_WAKE_UP_MIN_DUR_MOVED);
3106 config->min_dur_quite = BMI2_GET_BITS(*(data_p + idx), BMI2_WRIST_WAKE_UP_MIN_DUR_QUITE);
3110 else
3112 rslt = BMI2_E_INVALID_SENSOR;
3115 return rslt;
3119 * @brief This internal API gets the output values of step counter.
3121 static int8_t get_step_counter_output(uint32_t *step_count, struct bmi2_dev *dev)
3123 /* Variable to define error */
3124 int8_t rslt;
3126 /* Array to define the feature configuration */
3127 uint8_t feat_config[BMI2_FEAT_SIZE_IN_BYTES] = { 0 };
3129 /* Variables to define index */
3130 uint8_t idx = 0;
3132 /* Variable to set flag */
3133 uint8_t feat_found;
3135 /* Initialize feature output for step counter */
3136 struct bmi2_feature_config step_cnt_out_config = { 0, 0, 0 };
3138 /* Search for step counter output feature and extract its configuration details */
3139 feat_found = extract_output_feat_config(&step_cnt_out_config, BMI2_STEP_COUNTER, dev);
3140 if (feat_found)
3142 /* Get the feature output configuration for step-counter */
3143 rslt = bmi2_get_feat_config(step_cnt_out_config.page, feat_config, dev);
3144 if (rslt == BMI2_OK)
3146 /* Define the offset in bytes for step counter output */
3147 idx = step_cnt_out_config.start_addr;
3149 /* Get the step counter output in 4 bytes */
3150 *step_count = (uint32_t) feat_config[idx++];
3151 *step_count |= ((uint32_t) feat_config[idx++] << 8);
3152 *step_count |= ((uint32_t) feat_config[idx++] << 16);
3153 *step_count |= ((uint32_t) feat_config[idx++] << 24);
3156 else
3158 rslt = BMI2_E_INVALID_SENSOR;
3161 return rslt;
3165 * @brief This internal API gets the error status related to NVM.
3167 static int8_t get_nvm_error_status(struct bmi2_nvm_err_status *nvm_err_stat, struct bmi2_dev *dev)
3169 /* Variable to define error */
3170 int8_t rslt;
3172 /* Array to define the feature configuration */
3173 uint8_t feat_config[BMI2_FEAT_SIZE_IN_BYTES] = { 0 };
3175 /* Variables to define index */
3176 uint8_t idx = 0;
3178 /* Variable to set flag */
3179 uint8_t feat_found;
3181 /* Initialize feature output for NVM error status */
3182 struct bmi2_feature_config nvm_err_cfg = { 0, 0, 0 };
3184 /* Search for NVM error status feature and extract its configuration details */
3185 feat_found = extract_output_feat_config(&nvm_err_cfg, BMI2_NVM_STATUS, dev);
3186 if (feat_found)
3188 /* Get the feature output configuration for NVM error status */
3189 rslt = bmi2_get_feat_config(nvm_err_cfg.page, feat_config, dev);
3190 if (rslt == BMI2_OK)
3192 /* Define the offset in bytes for NVM error status */
3193 idx = nvm_err_cfg.start_addr;
3195 /* Increment index to get the error status */
3196 idx++;
3198 /* Error when NVM load action fails */
3199 nvm_err_stat->load_error = BMI2_GET_BIT_POS0(feat_config[idx], BMI2_NVM_LOAD_ERR_STATUS);
3201 /* Error when NVM program action fails */
3202 nvm_err_stat->prog_error = BMI2_GET_BITS(feat_config[idx], BMI2_NVM_PROG_ERR_STATUS);
3204 /* Error when NVM erase action fails */
3205 nvm_err_stat->erase_error = BMI2_GET_BITS(feat_config[idx], BMI2_NVM_ERASE_ERR_STATUS);
3207 /* Error when NVM program limit is exceeded */
3208 nvm_err_stat->exceed_error = BMI2_GET_BITS(feat_config[idx], BMI2_NVM_END_EXCEED_STATUS);
3210 /* Error when NVM privilege mode is not acquired */
3211 nvm_err_stat->privil_error = BMI2_GET_BITS(feat_config[idx], BMI2_NVM_PRIV_ERR_STATUS);
3214 else
3216 rslt = BMI2_E_INVALID_SENSOR;
3219 return rslt;
3223 * @brief This internal API is used to get enable status of gyroscope user gain
3224 * update.
3226 static int8_t get_user_gain_upd_status(uint8_t *status, struct bmi2_dev *dev)
3228 /* Variable to define error */
3229 int8_t rslt = BMI2_OK;
3231 /* Array to define the feature configuration */
3232 uint8_t feat_config[BMI2_FEAT_SIZE_IN_BYTES] = { 0 };
3234 /* Variable to define the array offset */
3235 uint8_t idx = 0;
3237 /* Variable to set flag */
3238 uint8_t feat_found;
3240 /* Variable to check APS status */
3241 uint8_t aps_stat = 0;
3243 /* Initialize feature configuration for gyroscope user gain */
3244 struct bmi2_feature_config gyr_user_gain_cfg = { 0, 0, 0 };
3246 /* Search for user gain feature and extract its configuration details */
3247 feat_found = bmi2_extract_input_feat_config(&gyr_user_gain_cfg, BMI2_GYRO_GAIN_UPDATE, dev);
3248 if (feat_found)
3250 /* Disable advance power save */
3251 aps_stat = dev->aps_status;
3252 if (aps_stat == BMI2_ENABLE)
3254 rslt = bmi2_set_adv_power_save(BMI2_DISABLE, dev);
3257 if (rslt == BMI2_OK)
3259 /* Get the configuration from the page where user gain feature resides */
3260 rslt = bmi2_get_feat_config(gyr_user_gain_cfg.page, feat_config, dev);
3261 if (rslt == BMI2_OK)
3263 /* Define the offset for enable/disable of user gain */
3264 idx = gyr_user_gain_cfg.start_addr + BMI2_GYR_USER_GAIN_FEAT_EN_OFFSET;
3266 /* Set the feature enable status */
3267 *status = BMI2_GET_BITS(feat_config[idx], BMI2_GYR_USER_GAIN_FEAT_EN);
3271 else
3273 rslt = BMI2_E_INVALID_SENSOR;
3276 /* Enable Advance power save if disabled while configuring and not when already disabled */
3277 if ((rslt == BMI2_OK) && (aps_stat == BMI2_ENABLE))
3279 rslt = bmi2_set_adv_power_save(BMI2_ENABLE, dev);
3282 return rslt;
3286 * @brief This internal API gets the output values of step activity.
3288 static int8_t get_step_activity_output(uint8_t *step_act, struct bmi2_dev *dev)
3290 /* Variable to define error */
3291 int8_t rslt;
3293 /* Array to define the feature configuration */
3294 uint8_t feat_config[BMI2_FEAT_SIZE_IN_BYTES] = { 0 };
3296 /* Variables to define index */
3297 uint8_t idx = 0;
3299 /* Variable to set flag */
3300 uint8_t feat_found;
3302 /* Initialize feature output for step activity */
3303 struct bmi2_feature_config step_act_out_config = { 0, 0, 0 };
3305 /* Search for step activity output feature and extract its configuration details */
3306 feat_found = extract_output_feat_config(&step_act_out_config, BMI2_STEP_ACTIVITY, dev);
3307 if (feat_found)
3309 /* Get the feature output configuration for step-activity */
3310 rslt = bmi2_get_feat_config(step_act_out_config.page, feat_config, dev);
3311 if (rslt == BMI2_OK)
3313 /* Define the offset in bytes for step activity output */
3314 idx = step_act_out_config.start_addr;
3316 /* Get the step activity output */
3317 *step_act = feat_config[idx];
3320 else
3322 rslt = BMI2_E_INVALID_SENSOR;
3325 return rslt;
3329 * @brief This internal API gets the error status related to virtual frames.
3331 static int8_t get_vfrm_error_status(struct bmi2_vfrm_err_status *vfrm_err_stat, struct bmi2_dev *dev)
3333 /* Variable to define error */
3334 int8_t rslt;
3336 /* Array to define the feature configuration */
3337 uint8_t feat_config[BMI2_FEAT_SIZE_IN_BYTES] = { 0 };
3339 /* Variables to define index */
3340 uint8_t idx = 0;
3342 /* Variable to set flag */
3343 uint8_t feat_found;
3345 /* Initialize feature output for VFRM error status */
3346 struct bmi2_feature_config vfrm_err_cfg = { 0, 0, 0 };
3348 /* Search for VFRM error status feature and extract its configuration details */
3349 feat_found = extract_output_feat_config(&vfrm_err_cfg, BMI2_VFRM_STATUS, dev);
3350 if (feat_found)
3352 /* Get the feature output configuration for VFRM error status */
3353 rslt = bmi2_get_feat_config(vfrm_err_cfg.page, feat_config, dev);
3354 if (rslt == BMI2_OK)
3356 /* Define the offset in bytes for VFRM error status */
3357 idx = vfrm_err_cfg.start_addr;
3359 /* Increment index to get the error status */
3360 idx++;
3362 /* Internal error while acquiring lock for FIFO */
3363 vfrm_err_stat->lock_error = BMI2_GET_BITS(feat_config[idx], BMI2_VFRM_LOCK_ERR_STATUS);
3365 /* Internal error while writing byte into FIFO */
3366 vfrm_err_stat->write_error = BMI2_GET_BITS(feat_config[idx], BMI2_VFRM_WRITE_ERR_STATUS);
3368 /* Internal error while writing into FIFO */
3369 vfrm_err_stat->fatal_error = BMI2_GET_BITS(feat_config[idx], BMI2_VFRM_FATAL_ERR_STATUS);
3372 else
3374 rslt = BMI2_E_INVALID_SENSOR;
3377 return rslt;
3381 * @brief This internal API enables/disables compensation of the gain defined
3382 * in the GAIN register.
3384 static int8_t enable_gyro_gain(uint8_t enable, struct bmi2_dev *dev)
3386 /* Variable to define error */
3387 int8_t rslt;
3389 /* Variable to define register data */
3390 uint8_t reg_data = 0;
3392 rslt = bmi2_get_regs(BMI2_GYR_OFF_COMP_6_ADDR, &reg_data, 1, dev);
3393 if (rslt == BMI2_OK)
3395 reg_data = BMI2_SET_BITS(reg_data, BMI2_GYR_GAIN_EN, enable);
3396 rslt = bmi2_set_regs(BMI2_GYR_OFF_COMP_6_ADDR, &reg_data, 1, dev);
3399 return rslt;
3403 * @brief This internal API is used to extract the output feature configuration
3404 * details from the look-up table.
3406 static uint8_t extract_output_feat_config(struct bmi2_feature_config *feat_output,
3407 uint8_t type,
3408 const struct bmi2_dev *dev)
3410 /* Variable to define loop */
3411 uint8_t loop = 0;
3413 /* Variable to set flag */
3414 uint8_t feat_found = BMI2_FALSE;
3416 /* Search for the output feature from the output configuration array */
3417 while (loop < dev->out_sens)
3419 if (dev->feat_output[loop].type == type)
3421 *feat_output = dev->feat_output[loop];
3422 feat_found = BMI2_TRUE;
3423 break;
3426 loop++;
3429 /* Return flag */
3430 return feat_found;