Minor changes to the MMA8451Q library.

Fork of MMA8451Q by Emilio Monti

Committer:
emilmont
Date:
Thu Oct 11 10:54:16 2012 +0000
Revision:
0:6149091f755d
Child:
1:d2630136d51e
Package samux acceleromiter library;

Who changed what in which revision?

UserRevisionLine numberNew contents of line
emilmont 0:6149091f755d 1 #ifndef MMA8451Q_H
emilmont 0:6149091f755d 2 #define MMA8451Q_H
emilmont 0:6149091f755d 3
emilmont 0:6149091f755d 4 #include "mbed.h"
emilmont 0:6149091f755d 5
emilmont 0:6149091f755d 6 //!Library for the MMA8451Q motion sensor.
emilmont 0:6149091f755d 7 class MMA8451Q
emilmont 0:6149091f755d 8 {
emilmont 0:6149091f755d 9 public:
emilmont 0:6149091f755d 10 //!Creates an instance of the class.
emilmont 0:6149091f755d 11 /*
emilmont 0:6149091f755d 12 * Connect module at I2C address addr using I2C port pins sda and scl.
emilmont 0:6149091f755d 13 * MMA8451Q
emilmont 0:6149091f755d 14 * \param sda SDA pin
emilmont 0:6149091f755d 15 * \param sdl SCL pin
emilmont 0:6149091f755d 16 * \param addr addr of the I2C peripheral
emilmont 0:6149091f755d 17 */
emilmont 0:6149091f755d 18 MMA8451Q(PinName sda, PinName scl, int addr);
emilmont 0:6149091f755d 19
emilmont 0:6149091f755d 20 /*
emilmont 0:6149091f755d 21 * Destroys instance.
emilmont 0:6149091f755d 22 */
emilmont 0:6149091f755d 23 ~MMA8451Q();
emilmont 0:6149091f755d 24
emilmont 0:6149091f755d 25 /*
emilmont 0:6149091f755d 26 * Get the value of the WHO_AM_I register
emilmont 0:6149091f755d 27 *
emilmont 0:6149091f755d 28 * \returns WHO_AM_I value
emilmont 0:6149091f755d 29 */
emilmont 0:6149091f755d 30 uint8_t getWhoAmI();
emilmont 0:6149091f755d 31
emilmont 0:6149091f755d 32 /*
emilmont 0:6149091f755d 33 * Get X axis acceleration
emilmont 0:6149091f755d 34 *
emilmont 0:6149091f755d 35 * \returns X axis acceleration
emilmont 0:6149091f755d 36 */
emilmont 0:6149091f755d 37 int16_t getAccX();
emilmont 0:6149091f755d 38
emilmont 0:6149091f755d 39 /*
emilmont 0:6149091f755d 40 * Get Y axis acceleration
emilmont 0:6149091f755d 41 *
emilmont 0:6149091f755d 42 * \returns Y axis acceleration
emilmont 0:6149091f755d 43 */
emilmont 0:6149091f755d 44 int16_t getAccY();
emilmont 0:6149091f755d 45
emilmont 0:6149091f755d 46 /*
emilmont 0:6149091f755d 47 * Get Z axis acceleration
emilmont 0:6149091f755d 48 *
emilmont 0:6149091f755d 49 * \returns Z axis acceleration
emilmont 0:6149091f755d 50 */
emilmont 0:6149091f755d 51 int16_t getAccZ();
emilmont 0:6149091f755d 52
emilmont 0:6149091f755d 53 /*
emilmont 0:6149091f755d 54 * Get XYZ axis acceleration
emilmont 0:6149091f755d 55 *
emilmont 0:6149091f755d 56 * \param res array where acceleration data will be stored
emilmont 0:6149091f755d 57 */
emilmont 0:6149091f755d 58 void getAccAllAxis(int16_t * res);
emilmont 0:6149091f755d 59
emilmont 0:6149091f755d 60 I2C m_i2c;
emilmont 0:6149091f755d 61
emilmont 0:6149091f755d 62 private:
emilmont 0:6149091f755d 63 int m_addr;
emilmont 0:6149091f755d 64 void read_regs(int addr, uint8_t * data, int len);
emilmont 0:6149091f755d 65 void write_regs(uint8_t * data, int len);
emilmont 0:6149091f755d 66 int16_t getAccAxis(uint8_t addr);
emilmont 0:6149091f755d 67
emilmont 0:6149091f755d 68 };
emilmont 0:6149091f755d 69
emilmont 0:6149091f755d 70 #endif