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
MMA8652.h
- Committer:
- JimCarver
- Date:
- 2014-04-07
- Revision:
- 0:3ae1e808e61c
- Child:
- 1:ff30cc4759b4
File content as of revision 0:3ae1e808e61c:
#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