a
Fork of FRDM_MMA8451Q by
Diff: MMA8451Q.h
- Revision:
- 5:695063448f2a
- Parent:
- 4:c4d879a39775
- Child:
- 6:c52175d13e0a
diff -r c4d879a39775 -r 695063448f2a MMA8451Q.h --- a/MMA8451Q.h Fri Oct 12 11:35:07 2012 +0000 +++ b/MMA8451Q.h Tue May 28 04:39:42 2013 +0000 @@ -49,62 +49,68 @@ class MMA8451Q { public: - /** - * MMA8451Q constructor - * - * @param sda SDA pin - * @param sdl SCL pin - * @param addr addr of the I2C peripheral - */ - MMA8451Q(PinName sda, PinName scl, int addr); - - /** - * MMA8451Q destructor - */ - ~MMA8451Q(); - - /** - * Get the value of the WHO_AM_I register - * - * @returns WHO_AM_I value - */ - uint8_t getWhoAmI(); - - /** - * Get X axis acceleration - * - * @returns X axis acceleration - */ - float getAccX(); + /** + * MMA8451Q constructor + * + * @param sda SDA pin + * @param sdl SCL pin + * @param addr addr of the I2C peripheral + */ + MMA8451Q(PinName sda, PinName scl, int addr); + + /** + * MMA8451Q destructor + */ + ~MMA8451Q(); + + /** + * Get the value of the WHO_AM_I register + * + * @returns WHO_AM_I value + */ + uint8_t getWhoAmI(); + + /** + * Get X axis acceleration + * + * @returns X axis acceleration + */ + float getAccX(); + + /** + * Get Y axis acceleration + * + * @returns Y axis acceleration + */ + float getAccY(); + + /** + * Get Z axis acceleration + * + * @returns Z axis acceleration + */ + float getAccZ(); + + /** + * Get XYZ axis acceleration + * + * @param res array where acceleration data will be stored + */ + void getAccAllAxis(float * res); - /** - * Get Y axis acceleration - * - * @returns Y axis acceleration - */ - float getAccY(); - - /** - * Get Z axis acceleration - * - * @returns Z axis acceleration - */ - float getAccZ(); - - /** - * Get XYZ axis acceleration - * - * @param res array where acceleration data will be stored - */ - void getAccAllAxis(float * res); - + void FreFallDetection( void(*fptr)(void)); + void MotionDetection( void(*fptr)(void)); + private: - I2C m_i2c; - int m_addr; - void readRegs(int addr, uint8_t * data, int len); - void writeRegs(uint8_t * data, int len); - int16_t getAccAxis(uint8_t addr); - + I2C m_i2c; + int m_addr; + void readRegs(int addr, uint8_t * data, int len); + void writeRegs(uint8_t * data, int len); + int16_t getAccAxis(uint8_t addr); + void Standby( void); + void Active( void); + void Fall_IRQ( void); + void Motion_IRQ( void); }; #endif