upm  1.7.1
Sensor/Actuator repository for libmraa (v2.0.0)
bmm150.hpp
1 /*
2  * Author: Jon Trulson <jtrulson@ics.com>
3  * Copyright (c) 2016-2017 Intel Corporation.
4  *
5  * The MIT License
6  *
7  * Permission is hereby granted, free of charge, to any person obtaining
8  * a copy of this software and associated documentation files (the
9  * "Software"), to deal in the Software without restriction, including
10  * without limitation the rights to use, copy, modify, merge, publish,
11  * distribute, sublicense, and/or sell copies of the Software, and to
12  * permit persons to whom the Software is furnished to do so, subject to
13  * the following conditions:
14  *
15  * The above copyright notice and this permission notice shall be
16  * included in all copies or substantial portions of the Software.
17  *
18  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
19  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
21  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
22  * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
23  * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
24  * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25  */
26 #pragma once
27 
28 #include <string>
29 #include <vector>
30 
31 #include <mraa/gpio.hpp>
32 #include "bmm150.h"
33 
34 namespace upm {
35 
76  class BMM150 {
77  public:
95  BMM150(int bus=BMM150_DEFAULT_I2C_BUS,
96  int addr=BMM150_DEFAULT_ADDR,
97  int cs=-1);
98 
102  ~BMM150();
103 
109  void update();
110 
116  uint8_t getChipID();
117 
129  void getMagnetometer(float *x, float *y, float *z);
130 
139  std::vector<float> getMagnetometer();
140 
151  void init(BMM150_USAGE_PRESETS_T usage=BMM150_USAGE_HIGH_ACCURACY);
152 
162  void setPresetMode(BMM150_USAGE_PRESETS_T usage);
163 
172  void reset();
173 
181  void setOutputDataRate(BMM150_DATA_RATE_T odr);
182 
195  void setPowerBit(bool power);
196 
204  void setOpmode(BMM150_OPERATION_MODE_T opmode);
205 
212  BMM150_OPERATION_MODE_T getOpmode();
213 
221  uint8_t getInterruptEnable();
222 
230  void setInterruptEnable(uint8_t bits);
231 
240  uint8_t getInterruptConfig();
241 
251  void setInterruptConfig(uint8_t bits);
252 
260  uint8_t getInterruptStatus();
261 
271  void setRepetitionsXY(uint8_t reps);
272 
282  void setRepetitionsZ(uint8_t reps);
283 
297  void installISR(BMM150_INTERRUPT_PINS_T intr, int gpio,
298  mraa::Edge level,
299  void (*isr)(void *), void *arg);
300 
307  void uninstallISR(BMM150_INTERRUPT_PINS_T intr);
308 
315  uint8_t readReg(uint8_t reg);
316 
325  int readRegs(uint8_t reg, uint8_t *buffer, int len);
326 
334  void writeReg(uint8_t reg, uint8_t val);
335 
336  protected:
337  bmm150_context m_bmm150;
338 
339  private:
340  /* Disable implicit copy and assignment operators */
341  BMM150(const BMM150&) = delete;
342  BMM150 &operator=(const BMM150&) = delete;
343 
344  };
345 }
uint8_t getChipID()
Definition: bmm150.cxx:87
uint8_t getInterruptEnable()
Definition: bmm150.cxx:138
void setPowerBit(bool power)
Definition: bmm150.cxx:119
void setPresetMode(BMM150_USAGE_PRESETS_T usage)
Definition: bmm150.cxx:181
void writeReg(uint8_t reg, uint8_t val)
Definition: bmm150.cxx:80
int readRegs(uint8_t reg, uint8_t *buffer, int len)
Definition: bmm150.cxx:70
void reset()
Definition: bmm150.cxx:105
C API for the bmm150 driver.
API for the BMM150 3-Axis Geomagnetic Sensor.
Definition: bmm150.hpp:76
~BMM150()
Definition: bmm150.cxx:46
BMM150(int bus=BMM150_DEFAULT_I2C_BUS, int addr=BMM150_DEFAULT_ADDR, int cs=-1)
Definition: bmm150.cxx:38
C++ API wrapper for the bh1749 driver.
Definition: a110x.hpp:29
void setRepetitionsXY(uint8_t reps)
Definition: bmm150.cxx:167
void setRepetitionsZ(uint8_t reps)
Definition: bmm150.cxx:174
void setInterruptConfig(uint8_t bits)
Definition: bmm150.cxx:155
void setOpmode(BMM150_OPERATION_MODE_T opmode)
Definition: bmm150.cxx:126
uint8_t getInterruptConfig()
Definition: bmm150.cxx:150
void installISR(BMM150_INTERRUPT_PINS_T intr, int gpio, mraa::Edge level, void(*isr)(void *), void *arg)
Definition: bmm150.cxx:188
std::vector< float > getMagnetometer()
Definition: bmm150.cxx:97
void uninstallISR(BMM150_INTERRUPT_PINS_T intr)
Definition: bmm150.cxx:198
Definition: bmm150.h:54
void setInterruptEnable(uint8_t bits)
Definition: bmm150.cxx:143
void setOutputDataRate(BMM150_DATA_RATE_T odr)
Definition: bmm150.cxx:112
uint8_t getInterruptStatus()
Definition: bmm150.cxx:162
uint8_t readReg(uint8_t reg)
Definition: bmm150.cxx:65
void update()
Definition: bmm150.cxx:58
void init(BMM150_USAGE_PRESETS_T usage=BMM150_USAGE_HIGH_ACCURACY)
Definition: bmm150.cxx:51
BMM150_OPERATION_MODE_T getOpmode()
Definition: bmm150.cxx:133