Utilities for BORCH accelerometer BMA250E

Dependents:   MtConnect04S_Bike_Proximity Mt05_MtSense03

Committer:
mtmkimi
Date:
Mon Dec 19 06:07:10 2016 +0000
Revision:
0:8273e9b80c39
Child:
1:b6bb47e17a9a
Initialize BMA250E library.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
mtmkimi 0:8273e9b80c39 1 /* Copyright (c) 2016 MtM Technology Corporation, MIT License
mtmkimi 0:8273e9b80c39 2 *
mtmkimi 0:8273e9b80c39 3 * Permission is hereby granted, free of charge, to any person obtaining a copy of this software
mtmkimi 0:8273e9b80c39 4 * and associated documentation files (the "Software"), to deal in the Software without restriction,
mtmkimi 0:8273e9b80c39 5 * including without limitation the rights to use, copy, modify, merge, publish, distribute,
mtmkimi 0:8273e9b80c39 6 * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
mtmkimi 0:8273e9b80c39 7 * furnished to do so, subject to the following conditions:
mtmkimi 0:8273e9b80c39 8 *
mtmkimi 0:8273e9b80c39 9 * The above copyright notice and this permission notice shall be included in all copies or
mtmkimi 0:8273e9b80c39 10 * substantial portions of the Software.
mtmkimi 0:8273e9b80c39 11 *
mtmkimi 0:8273e9b80c39 12 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
mtmkimi 0:8273e9b80c39 13 * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
mtmkimi 0:8273e9b80c39 14 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
mtmkimi 0:8273e9b80c39 15 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
mtmkimi 0:8273e9b80c39 16 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
mtmkimi 0:8273e9b80c39 17 */
mtmkimi 0:8273e9b80c39 18 #ifndef BMA250E_h
mtmkimi 0:8273e9b80c39 19 #define BMA250E_h
mtmkimi 0:8273e9b80c39 20
mtmkimi 0:8273e9b80c39 21 #include "mbed.h"
mtmkimi 0:8273e9b80c39 22
mtmkimi 0:8273e9b80c39 23 #define BMA250E_SLAVE_ADDR 0x30
mtmkimi 0:8273e9b80c39 24
mtmkimi 0:8273e9b80c39 25 class BMA250E {
mtmkimi 0:8273e9b80c39 26 public:
mtmkimi 0:8273e9b80c39 27 BMA250E(PinName i2c_sda, PinName i2c_scl, PinName int1 = NC, PinName int2 = NC);
mtmkimi 0:8273e9b80c39 28
mtmkimi 0:8273e9b80c39 29 void ReadXYZ(int16_t *xyz);
mtmkimi 0:8273e9b80c39 30
mtmkimi 0:8273e9b80c39 31 void NewData (void(*fptr)(void));
mtmkimi 0:8273e9b80c39 32 void AnyMotion (void(*fptr)(void));
mtmkimi 0:8273e9b80c39 33 void TapSening (void(*fptr)(void), bool double_tap);
mtmkimi 0:8273e9b80c39 34 void OrientationRecognition (void(*fptr)(void));
mtmkimi 0:8273e9b80c39 35 void FlatDetection (void(*fptr)(void));
mtmkimi 0:8273e9b80c39 36 void LowHighGDetection (void(*fptr)(void), bool high_g);
mtmkimi 0:8273e9b80c39 37 void ShakeDetection (void(*fptr)(void));
mtmkimi 0:8273e9b80c39 38
mtmkimi 0:8273e9b80c39 39 void EnterStandbyMode(void);
mtmkimi 0:8273e9b80c39 40 void LeaveStandbyMode(void);
mtmkimi 0:8273e9b80c39 41
mtmkimi 0:8273e9b80c39 42 private:
mtmkimi 0:8273e9b80c39 43 I2C i2c_;
mtmkimi 0:8273e9b80c39 44 PinName interrupt1_pinname_;
mtmkimi 0:8273e9b80c39 45 InterruptIn interrupt1_;
mtmkimi 0:8273e9b80c39 46 PinName interrupt2_pinname_;
mtmkimi 0:8273e9b80c39 47 InterruptIn interrupt2_;
mtmkimi 0:8273e9b80c39 48
mtmkimi 0:8273e9b80c39 49 void RegWrite(char reg, char val);
mtmkimi 0:8273e9b80c39 50 void RegRead (char reg, char *val, int len);
mtmkimi 0:8273e9b80c39 51 void RegReadModifyWrite(char reg, char clr_mask, char set_mask);
mtmkimi 0:8273e9b80c39 52 };
mtmkimi 0:8273e9b80c39 53
mtmkimi 0:8273e9b80c39 54 #endif