Utilities for BORCH accelerometer BMA250E
Dependents: MtConnect04S_Bike_Proximity Mt05_MtSense03
BMA250E.h
- Committer:
- johnathanlyu
- Date:
- 2018-04-27
- Revision:
- 1:b6bb47e17a9a
- Parent:
- 0:8273e9b80c39
File content as of revision 1:b6bb47e17a9a:
/* Copyright (c) 2016 MtM Technology Corporation, MIT License
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software
* and associated documentation files (the "Software"), to deal in the Software without restriction,
* including without limitation the rights to use, copy, modify, merge, publish, distribute,
* sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all copies or
* substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
* BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#ifndef BMA250E_h
#define BMA250E_h
#include "mbed.h"
#define BMA250E_SLAVE_ADDR 0x30
class BMA250E {
public:
BMA250E(PinName i2c_sda, PinName i2c_scl, PinName int1 = NC, PinName int2 = NC, uint8_t range = 0x03, uint8_t bandwith =0x0C);
void ReadXYZ(int16_t *xyz);
void NewData (void(*fptr)(void));
void AnyMotion (void(*fptr)(void));
void TapSening (void(*fptr)(void), bool double_tap);
void OrientationRecognition (void(*fptr)(void));
void FlatDetection (void(*fptr)(void));
void LowHighGDetection (void(*fptr)(void), bool high_g);
void ShakeDetection (void(*fptr)(void));
void EnterStandbyMode(void);
void LeaveStandbyMode(void);
private:
I2C i2c_;
PinName interrupt1_pinname_;
InterruptIn interrupt1_;
PinName interrupt2_pinname_;
InterruptIn interrupt2_;
uint8_t range_;
uint8_t bandwith_;
void RegWrite(char reg, char val);
void RegRead (char reg, char *val, int len);
void RegReadModifyWrite(char reg, char clr_mask, char set_mask);
};
#endif
MtM+