test
Fork of MMA8652 by
Diff: MMA8652.h
- Revision:
- 0:3ae1e808e61c
- Child:
- 1:ff30cc4759b4
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/MMA8652.h Mon Apr 07 00:59:06 2014 +0000 @@ -0,0 +1,65 @@ +#ifndef MMA8652_H +#define MMA8652_H + +#include "mbed.h" + + +// MMA8652 Slave Address +#define MMA8652_SLAVE_ADDR 0x3A + +// MMA8652 internal register addresses +#define MMA8652_STATUS 0x00 +#define MMA8652_WHOAMI 0x0D +#define MMA8652_XYZ_DATA_CFG 0x0E +#define MMA8652_CTRL_REG1 0x2A +#define MMA8652_WHOAMI_VAL 0x4A + +class MMA8652 +{ +public: + /** + * MPL3115A2 constructor + * + * @param sda SDA pin + * @param sdl SCL pin + * @param addr addr of the I2C peripheral + */ + MMA8652(PinName sda, PinName scl); + + /** + * Get the value of the WHO_AM_I register + * + * @returns DEVICE_ID value == ?? + */ + //uint8_t getDeviceID(); + + /** + * Return the STATUS register value + * + * @returns STATUS register value + */ + //unsigned char getStatus( void); + + /** + * Get the Accelerometer & Magnetometer values + * Accelerometer data is in G's + * MAgnetometer Data is in microteslas + * + * @returns altimeter value as float + */ + void ReadXYZ(float * a); + + +private: + + I2C _i2c; + /** Set the device in active mode + */ + void begin( void); + + void RegRead( char reg, char * d, int len); + + +}; + +#endif