Skip to content

Commit 0f89760

Browse files
BST-Github-Adminkegov
authored andcommittedMay 6, 2020
Updated to v2.53.0. Added the support for the context variant. Added generic examples.
1 parent 886f52e commit 0f89760

36 files changed

+7364
-3166
lines changed
 

‎OIS_README.md

+172
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,172 @@
1+
# Sensor API for the BMI2's OIS interface
2+
3+
## Table of Contents
4+
- [Introduction](#Intro)
5+
- [Integration details](#Integration)
6+
- [Driver files information](#file)
7+
- [Sensor interfaces](#interface)
8+
- [Integration Examples](#examples)
9+
10+
### Introduction<a name=Intro></a>
11+
This package contains Bosch Sensortec's BMI2 Sensor API.
12+
13+
### Integration details<a name=Integration></a>
14+
- Integrate _bmi2.c_, _bmi2.h_, _bmi2_ois.c_, _bmi2_ois.h_, _bmi2_defs.h_ and the required variant files in your project.
15+
- User has to include _bmi2_ois.h_ in the code to call OIS related APIs and a _variant header_ for initialization as
16+
well as BMI2 related API calls, as shown below:
17+
``` c
18+
#include "bmi261.h"
19+
#include "bmi2_ois.h"
20+
````
21+
### Driver files information<a name=file></a>
22+
- *_bmi2_ois.c_*
23+
* This file has function definitions of OIS related API interfaces.
24+
- *_bmi2_ois.h_*
25+
* This header file has necessary include files, function declarations, required to make OIS related API calls.
26+
27+
### Sensor interfaces<a name=interface></a>
28+
#### _Host Interface_
29+
- I2C interface
30+
- SPI interface
31+
_Note: By default, the interface is I2C._
32+
33+
#### _OIS Interface_
34+
- SPI interface
35+
36+
### Integration examples<a name=examples></a>
37+
#### Configuring SPI/I2C for host interface.
38+
To configure host interface, an instance of the bmi2_dev structure should be
39+
created for initializing BMI2 sensor. "_Refer **README** for initializing BMI2
40+
sensor._"
41+
42+
#### Configuring SPI for OIS interface.
43+
To configure OIS interface, an instance of the bmi2_ois_dev structure should be
44+
created. The following parameters are required to be updated in the structure,
45+
by the user.
46+
47+
Parameters | Details
48+
--------------|-----------------------------------
49+
_intf_ptr_ | device address reference of SPI interface
50+
_ois_read_ | read through SPI interface
51+
_ois_write_ | read through SPI interface
52+
_ois_delay_us_| delay in micro seconds
53+
_acc_en_ | for enabling accelerometer
54+
_gyr_en_ | for enabling gyroscope
55+
56+
``` c
57+
int8_t rslt = 0;
58+
59+
struct bmi2_ois_dev ois_dev = {
60+
.intf_ptr = intf_ptr will contain the chip selection info of SPI CS pin,
61+
.ois_read = user_spi_reg_read,
62+
.ois_write = user_spi_reg_write,
63+
.ois_delay_us = user_delay_us
64+
};
65+
```
66+
>**_Important Note_**: For initializing and configuring BMI2 sensors, which is
67+
done through host interface, the API's are to be used from bmi2.c file. Rest
68+
of the API's, for OIS configurations and the reading of OIS data, which is done
69+
through OIS interface, are to be used from bmi2_ois.c file.
70+
71+
##### Get accelerometer and gyroscope data through OIS interface
72+
``` c
73+
int8_t rslt;
74+
/* Array to enable sensor through host interface */
75+
uint8_t sens_list[2] = {BMI2_ACCEL, BMI2_GYRO};
76+
/* Array to enable sensor through OIS interface */
77+
uint8_t sens_sel[2] = {BMI2_OIS_ACCEL, BMI2_OIS_GYRO};
78+
/* Initialize the configuration structure */
79+
struct bmi2_sens_config sens_cfg = {0};
80+
81+
/* Initialize BMI2 */
82+
rslt = bmi2_init(&dev);
83+
if (rslt != BMI2_OK) {
84+
printf("Error: %d\n", rslt);
85+
return;
86+
}
87+
88+
/* Enable accelerometer and gyroscope through host interface */
89+
rslt = bmi2_sensor_enable(sens_list, 2, &dev);
90+
if (rslt != BMI2_OK) {
91+
printf("Error: %d\n", rslt);
92+
return;
93+
}
94+
95+
/* Setting of OIS Range is done through host interface */
96+
/* Select the gyroscope sensor for OIS Range configuration */
97+
sens_cfg.type = BMI2_GYRO;
98+
99+
/* Get gyroscope configuration */
100+
rslt = bmi2_get_sensor_config(&sens_cfg, 1, &dev);
101+
if (rslt != BMI2_OK) {
102+
printf("Error: %d\n", rslt);
103+
return;
104+
}
105+
106+
/* Set the desired OIS Range */
107+
sens_cfg.cfg.gyr.ois_range = BMI2_GYR_OIS_2000;
108+
109+
/* Set gyroscope configuration for default values */
110+
rslt = bmi2_set_sensor_config(&sens_cfg, 1, &dev);
111+
if (rslt != BMI2_OK) {
112+
printf("Error: %d\n", rslt);
113+
return;
114+
}
115+
116+
/* Enable OIS through host interface */
117+
rslt = bmi2_set_ois_interface(BMI2_ENABLE, &dev);
118+
if (rslt != BMI2_OK) {
119+
printf("Error: %d\n", rslt);
120+
return;
121+
}
122+
123+
/* Disable Advance Power Save Mode through host interface */
124+
rslt = bmi2_set_adv_power_save(BMI2_DISABLE, &dev);
125+
if (rslt != BMI2_OK) {
126+
printf("Error: %d\n", rslt);
127+
return;
128+
}
129+
130+
/* Get configurations for OIS through OIS interface for default values */
131+
rslt = bmi2_ois_get_config(&ois_dev);
132+
if (rslt != BMI2_OK) {
133+
printf("Error: %d\n", rslt);
134+
return;
135+
}
136+
137+
/* Enable accelerometer and gyroscope for reading OIS data */
138+
ois_dev.acc_en = BMI2_ENABLE;
139+
ois_dev.gyr_en = BMI2_ENABLE;
140+
141+
/* Set configurations for OIS through OIS interface */
142+
rslt = bmi2_ois_set_config(&ois_dev);
143+
if (rslt == BMI2_OK) {
144+
/* Get OIS accelerometer and gyroscope data through OIS interface */
145+
rslt = bmi2_ois_read_data(sens_sel, 2, &ois_dev);
146+
if (rslt == BMI2_OK) {
147+
/* Print accelerometer data */
148+
printf("OIS Accel x-axis = %d\t", ois_dev.acc_data.x);
149+
printf("OIS Accel y-axis= %d\t", ois_dev.acc_data.y);
150+
printf("OIS Accel z-axis = %d\r\n", ois_dev.acc_data.z);
151+
152+
/* Print gyroscope data */
153+
printf("OIS Gyro x-axis = %d\t", ois_dev.gyr_data.x);
154+
printf("OIS Gyro y-axis= %d\t", ois_dev.gyr_data.y);
155+
printf("OIS Gyro z-axis = %d\r\n", ois_dev.gyr_data.z);
156+
}
157+
}
158+
159+
if (rslt != BMI2_OK) {
160+
printf("Error code: %d\n", rslt);
161+
return;
162+
}
163+
164+
/* Enable Advance Power Save Mode through host interface */
165+
rslt = bmi2_set_adv_power_save(BMI2_ENABLE, &dev);
166+
if (rslt != BMI2_OK) {
167+
printf("Error: %d\n", rslt);
168+
return;
169+
}
170+
```
171+
172+

‎README.md

+2-7
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,13 @@ BMI2xy Sensor API
22

33
> This package contains BMI2xy sensor API
44
5-
**Note : When updating from 2.19.0 to 2.34.0, the gyroscope offset calibration data cannot be reused. In case of a permanently stored gyroscope offset (inside the sensor NVM or on the host), please perform calibration again with API version 2.34.0.
6-
75
## Sensor Overview
8-
96
The BMI2xy is a small, low power, low noise inertial measurement unit designed for use in mobile applications like augmented reality or indoor navigation which require highly accurate, real-time sensor data.
107

118
### Features
129

1310
- Indoor navigation, pedestrian dead-reckoning, step-counting
1411

15-
For more information refer [product page](https://www.bosch-sensortec.com/bst/products/all_products/bmi270)
16-
17-
---
12+
For more information refer product page [Link](https://www.bosch-sensortec.com/products/motion-sensors/imus/bmi270.html)
1813

19-
#### Copyright (C) 2019 Bosch Sensortec GmbH
14+
---

0 commit comments

Comments
 (0)
Updated to v2.53.0. Added the support for the context variant. Added &hellip; &middot; boschsensortec/BMI270_SensorAPI@0f89760 · GitHub