A basic library for the MMA8652 accelerometer, provides data in either floating point G's or as a signed 16 bit integer.
Dependents: Hello_MMA8652 Multi-Sensor Buddi_Blueband Freescale_Multi-Sensor_Shield ... more
Revision 2:29c2dd97ca95, committed 2014-06-02
- Comitter:
- screamer
- Date:
- Mon Jun 02 18:22:59 2014 +0000
- Parent:
- 1:ff30cc4759b4
- Commit message:
- Documentation fixes
Changed in this revision
MMA8652.h | Show annotated file Show diff for this revision Revisions of this file |
diff -r ff30cc4759b4 -r 29c2dd97ca95 MMA8652.h --- a/MMA8652.h Sat Apr 19 01:28:26 2014 +0000 +++ b/MMA8652.h Mon Jun 02 18:22:59 2014 +0000 @@ -33,44 +33,54 @@ #define MMA8652_CTRL_REG1 0x2A #define MMA8652_WHOAMI_VAL 0x4A +/** + * MMA8652 Xtrinsic accelerometer on I2C + */ class MMA8652 { public: /** - * MMA8652 constructor - * - * @param sda SDA pin - * @param sdl SCL pin - * @param addr addr of the I2C peripheral - */ + * MMA8652 constructor + * + * @param sda SDA pin + * @param sdl SCL pin + */ MMA8652(PinName sda, PinName scl); - /** - * MMA8652 destructor - */ - ~MMA8652(); - /** - * Get XYZ axis acceleration in floating point G's - * - * @param res array where acceleration data will be stored - */ - void ReadXYZ(float * a); + /** + * MMA8652 destructor + */ + ~MMA8652(); - /** - * Get XYZ axis acceleration, signed 16 bit values - * - * @param res array where acceleration data will be stored - */ + /** + * Get XYZ axis acceleration in floating point G's + * + * @param res array where acceleration data will be stored + */ + void ReadXYZ(float * a); + + /** + * Get XYZ axis acceleration, signed 16 bit values + * + * @param res array where acceleration data will be stored + */ void ReadXYZraw(int16_t * d); - char getWhoAmI(void); + /** + * Get the value of the WHO_AM_I register + * + * @returns DEVICE_ID value == 0x3A + */ + char getWhoAmI(void); + private: - I2C _i2c; - /** Set the device in active mode - */ + + /** + * Set the device in active mode + */ void begin( void); - + void RegRead( char reg, char * d, int len); };