library mma8452
Fork of MMA8452 by
Diff: MMA8452.h
- Revision:
- 1:ef026bf28798
- Parent:
- 0:bcf2aa85d7f9
- Child:
- 2:66db0f91b215
diff -r bcf2aa85d7f9 -r ef026bf28798 MMA8452.h --- a/MMA8452.h Fri Oct 04 14:48:02 2013 +0000 +++ b/MMA8452.h Tue Oct 08 15:25:32 2013 +0000 @@ -89,7 +89,7 @@ #define FF_MT_CFG 0X15 // Type 'read/write' : Freefaul motion functional block configuration #define FF_MT_SRC 0X16 // Type 'read' : Freefaul motion event source register -#define FF_COUNT 0X17 // Type 'read' : Freefaul motion threshold register +#define FF_MT_THS 0X17 // Type 'read' : Freefaul motion threshold register #define FF_COUNT 0X18 // Type 'read' : Freefaul motion debouce counter #define ASLP_COUNT 0x29 // Type 'read/write' : Counter setting for auto sleep @@ -126,7 +126,8 @@ * @param scl I2C8452 clock port * */ - Accelerometer_MMA8452(PinName sda, PinName scl); + Accelerometer_MMA8452(PinName sda, PinName scl, int frequency); + //Accelerometer_MMA8452(PinName sda, PinName scl); /** Destroys an MMA8452 object * @@ -134,16 +135,23 @@ ~Accelerometer_MMA8452(); /** Activate the MMA8452 (required) - * - * - */ + * returns 0 for success in activating the chip + * returns 1 for failure in activating the chip + * -currrently no retries or waiting is done, this method tries 1 time the exits. + */ int activate(); /** Initialization of device MMA8452 (required) - * */ void init(); + /** Read the device ID from the accelerometer + * + * @param *deviceID Value of device - is should be 0x2A + * return 0 for success or + * return 1 for failure. + */ + int Get_DeviceID(int *deviceID); /** Read the Tilt Angle using Three Axis * * @param *x Value of x tilt @@ -169,6 +177,15 @@ * @returns The value of z acceleration */ int read_z(); + + /** Read the x,y and z registers of the MMA8452 + * + * takes a 2 byte char buffer to store the value + * for each axis. + * returns 0 for success, and 1 for failure + * + */ + int read_xyz(char *x, char *y, char *z); /** Read from specified MMA8452 register * @@ -187,7 +204,7 @@ private: I2C m_i2c; - int m_frequencey; + int m_frequency; };