upm  1.7.1
Sensor/Actuator repository for libmraa (v2.0.0)
mpu9150.hpp
1 /*
2  * Author: Jon Trulson <jtrulson@ics.com>
3  * Copyright (c) 2015 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 
25 #pragma once
26 #include <vector>
27 
28 #include "mpu60x0.hpp"
29 #include "ak8975.hpp"
30 
31 #define MPU9150_I2C_BUS 0
32 #define MPU9150_DEFAULT_I2C_ADDR MPU60X0_DEFAULT_I2C_ADDR
33 
34 
35 namespace upm {
36 
61  class MPU9150: public MPU60X0
62  {
63  public:
73  MPU9150 (int bus=MPU9150_I2C_BUS, int address=MPU9150_DEFAULT_I2C_ADDR,
74  int magAddress=AK8975_DEFAULT_I2C_ADDR, bool enableAk8975=true);
75 
79  virtual ~MPU9150 ();
80 
86  bool init();
87 
100  void update();
101 
110  void getMagnetometer(float *x, float *y, float *z);
111 
118  std::vector<float> getMagnetometer();
119 
120  protected:
121  // magnetometer instance
122  AK8975* m_mag;
123 
124 
125  private:
126  /* Disable implicit copy and assignment operators */
127  MPU9150(const MPU9150&) = delete;
128  MPU9150 &operator=(const MPU9150&) = delete;
129 
130  int m_i2cBus;
131  uint8_t m_magAddress;
132  bool m_enableAk8975;
133  };
134 
135 }
MPU9150(int bus=MPU9150_I2C_BUS, int address=MPU9150_DEFAULT_I2C_ADDR, int magAddress=AK8975_DEFAULT_I2C_ADDR, bool enableAk8975=true)
Definition: mpu9150.cxx:34
std::vector< float > getMagnetometer()
Definition: mpu9150.cxx:112
API for the AK8975 magnetometer.
Definition: ak8975.hpp:53
virtual ~MPU9150()
Definition: mpu9150.cxx:42
C++ API wrapper for the bh1749 driver.
Definition: a110x.hpp:29
void update()
Definition: mpu9150.cxx:87
bool init()
Definition: mpu9150.cxx:48
API for the MPU60X0 3-axis Gyroscope and 3-axis Accelerometer.
Definition: mpu60x0.hpp:62
API for MPU9150 chip (Accelerometer, Gyro and Magnetometer Sensor)
Definition: mpu9150.hpp:61