upm  1.7.1
Sensor/Actuator repository for libmraa (v2.0.0)
bmi160.hpp
1 /*
2  * Author: Jon Trulson <jtrulson@ics.com>
3  * Copyright (c) 2016 Intel Corporation.
4  *
5  * Permission is hereby granted, free of charge, to any person obtaining
6  * a copy of this software and associated documentation files (the
7  * "Software"), to deal in the Software without restriction, including
8  * without limitation the rights to use, copy, modify, merge, publish,
9  * distribute, sublicense, and/or sell copies of the Software, and to
10  * permit persons to whom the Software is furnished to do so, subject to
11  * the following conditions:
12  *
13  * The above copyright notice and this permission notice shall be
14  * included in all copies or substantial portions of the Software.
15  *
16  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20  * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21  * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22  * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23  */
24 #pragma once
25 #include <string>
26 #include "bmi160.h"
27 
28 #define BMI160_I2C_BUS 0
29 #define BMI160_DEFAULT_I2C_ADDR 0x69
30 
31 namespace upm {
32 
75  class BMI160 {
76  public:
77 
91  BMI160(int bus=BMI160_I2C_BUS, int address=BMI160_DEFAULT_I2C_ADDR,
92  int csPin=-1, bool enableMag=true);
93 
97  ~BMI160();
98 
105  void update();
106 
112  void setAccelerometerScale(BMI160_ACC_RANGE_T scale);
113 
119  void setGyroscopeScale(BMI160_GYRO_RANGE_T scale);
120 
132  float *getAccelerometer();
133 
143  void getAccelerometer(float *x, float *y, float *z);
144 
156  float *getGyroscope();
157 
167  void getGyroscope(float *x, float *y, float *z);
168 
182  float *getMagnetometer();
183 
193  void getMagnetometer(float *x, float *y, float *z);
194 
201  void enableMagnetometer(bool enable);
202 
210  unsigned int getSensorTime();
211 
212  protected:
213  bmi160_context m_bmi160;
214 
228  std::string busRead(int addr, int reg, int len);
229 
242  void busWrite(int addr, int reg, std::string data);
243 
244  private:
245  /* Disable implicit copy and assignment operators */
246  BMI160(const BMI160&) = delete;
247  BMI160 &operator=(const BMI160&) = delete;
248  };
249 }
void setAccelerometerScale(BMI160_ACC_RANGE_T scale)
Definition: bmi160.cxx:53
BMI160 3-axis Accelerometer, Gyroscope and (optionally) a Magnetometer.
Definition: bmi160.h:65
float * getMagnetometer()
Definition: bmi160.cxx:96
unsigned int getSensorTime()
Definition: bmi160.cxx:110
float * getGyroscope()
Definition: bmi160.cxx:87
UPM API for the BMI160 3-axis Accelerometer, Gyroscope and Magnetometer.
Definition: bmi160.hpp:75
void setGyroscopeScale(BMI160_GYRO_RANGE_T scale)
Definition: bmi160.cxx:58
void enableMagnetometer(bool enable)
Definition: bmi160.cxx:105
C++ API wrapper for the bh1749 driver.
Definition: a110x.hpp:29
~BMI160()
Definition: bmi160.cxx:43
BMI160(int bus=BMI160_I2C_BUS, int address=BMI160_DEFAULT_I2C_ADDR, int csPin=-1, bool enableMag=true)
Definition: bmi160.cxx:35
void busWrite(int addr, int reg, std::string data)
Definition: bmi160.cxx:136
void update()
Definition: bmi160.cxx:48
float * getAccelerometer()
Definition: bmi160.cxx:78
std::string busRead(int addr, int reg, int len)
Definition: bmi160.cxx:115