upm  1.7.1
Sensor/Actuator repository for libmraa (v2.0.0)
Data Fields
_bmi160_context Struct Reference

BMI160 3-axis Accelerometer, Gyroscope and (optionally) a Magnetometer. More...

Detailed Description

The Bosch BMI160 is a 3-axis Accelerometer and Gyroscope. Additionally it supports an external Magnetometer, accessed through the BMI160's register interface. This driver was developed with a BMI160 "Shuttle" board, which included a BMM150 Magnetometer.

The device is driven by either 1.8v or 3.3vdc. This driver incorporates the Bosch BMI160 driver code at https://github.com/BoschSensortec/BMI160_driver

The Bosch driver code does not provide a mechanism for passing user data around (like the device context). For this reason, only one instance of this driver can be used in a given process, due to the use of static data in the driver.

While not all of the functionality of this device is supported initially, the inclusion of the Bosch driver in the source code makes it possible to support whatever features are required that the driver can support.

// Instantiate a BMI160 sensor on I2C bus 0, address 0x69, and
// disable the magnetometer (since it is an optional component
// that may not be present). Since we are using I2C, pass a valid
// I2C address, and supply -1 as the cs_pin.
bmi160_context sensor = bmi160_init(0, 0x69, -1, false);
// For SPI, you would use something like this, using gpio 10 as
// the cs pin. Passing -1 as the address indicates SPI operation.
//
// bmi160_context sensor = bmi160_init(0, -1, 10, false);
if (!sensor)
{
printf("bmi160_init() failed.\n");
return(1);
}
// Every half second, update and print values
while (shouldRun)
{
bmi160_update(sensor);
float x, y, z;
bmi160_get_accelerometer(sensor, &x, &y, &z);
printf("Acceleration x = %f y = %f z = %f\n",
x, y, z);
bmi160_get_gyroscope(sensor, &x, &y, &z);
printf("Gyroscope x = %f y = %f z = %f\n",
x, y, z);
//bmi160_get_magnetometer(sensor, &x, &y, &z);
//printf("Magnetometer x = %f y = %f z = %f\n",
// x, y, z);
printf("\n");
upm_delay_ms(500);
}

Data Fields

float accelX
 
float accelY
 
float accelZ
 
float gyroX
 
float gyroY
 
float gyroZ
 
float magX
 
float magY
 
float magZ
 
unsigned int sensorTime
 
float accelScale
 
float gyroScale
 
bool magEnabled
 

The documentation for this struct was generated from the following file: