GHI Electronics / Mbed 2 deprecated Official_E-Dice

Dependencies:   mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers MMA845x.h Source File

MMA845x.h

00001 /* Copyright (c) 2014 GHI Electronics, LLC
00002 *
00003 * Permission is hereby granted, free of charge, to any person obtaining a copy of this software
00004 * and associated documentation files (the "Software"), to deal in the Software without
00005 * restriction, including without limitation the rights to use, copy, modify, merge, publish,
00006 * distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the
00007 * Software is furnished to do so, subject to the following conditions:
00008 *
00009 * The above copyright notice and this permission notice shall be included in all copies or
00010 * substantial portions of the Software.
00011 *
00012 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
00013 * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
00014 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
00015 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
00016 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
00017 */
00018 
00019 #ifndef MMA845X_H
00020 #define MMA845X_H
00021 
00022 #include "mbed.h"
00023 
00024 class MMA845x
00025 {
00026 public:
00027     MMA845x(PinName sda, PinName scl, int i2cAddress);
00028     ~MMA845x();
00029 
00030     int16_t getX();
00031     int16_t getY();
00032     int16_t getZ();
00033     void GetXYZ(int& x, int& y, int& z);
00034   
00035     struct AccelerationAxes
00036     {
00037         int x;
00038         int y;
00039         int z;
00040     };
00041 
00042 private:
00043     I2C i2cBus;
00044     int i2cAddress;
00045     void readRegister(uint8_t registerAddress, uint8_t* data, int length);
00046     int16_t readAxisRegister(uint8_t axisRegisterAddress);
00047     //void writeRegister(uint8_t * data, int length);
00048     //int16_t getAccAxis(uint8_t address);
00049 
00050 };
00051 
00052 #endif
00053 
00054