Added function to retrieve raw data from sensor

Dependencies:   MotionSensor

Dependents:   KL46_eCompass KL46_eCompass_TiltCompensed_Acel-Mag Ragnarok_2ejes compass_acc ... more

Fork of MMA8451Q by Emilio Monti

Revision:
6:d3f7851ff32e
Parent:
5:b8512e0de86b
--- a/MMA8451Q.h	Mon Apr 07 21:03:37 2014 +0000
+++ b/MMA8451Q.h	Fri May 16 18:21:49 2014 +0000
@@ -20,33 +20,10 @@
 #define MMA8451Q_H
 
 #include "mbed.h"
+#include "MotionSensor.h"
 
-/**
-* MMA8451Q accelerometer example
-*
-* @code
-* #include "mbed.h"
-* #include "MMA8451Q.h"
-* 
-* #define MMA8451_I2C_ADDRESS (0x1d<<1)
-* 
-* int main(void) {
-* 
-* MMA8451Q acc(P_E25, P_E24, MMA8451_I2C_ADDRESS);
-* PwmOut rled(LED_RED);
-* PwmOut gled(LED_GREEN);
-* PwmOut bled(LED_BLUE);
-* 
-*     while (true) {       
-*         rled = 1.0 - abs(acc.getAccX());
-*         gled = 1.0 - abs(acc.getAccY());
-*         bled = 1.0 - abs(acc.getAccZ());
-*         wait(0.1);
-*     }
-* }
-* @endcode
-*/
-class MMA8451Q
+
+class MMA8451Q : public MotionSensor
 {
 public:
   /**
@@ -63,47 +40,27 @@
   */
   ~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);
-  void getAccXYZraw(int16_t * d);
+    void enable(void);
+    void disable(void);
+    uint32_t sampleRate(uint32_t fequency);
+    uint32_t whoAmI(void);
+    uint32_t dataReady(void);
+    void getX(int16_t * x);
+    void getY(int16_t * y);
+    void getZ(int16_t * z);
+    void getX(float * x);
+    void getY(float * y);
+    void getZ(float * z);
+    void getAxis(MotionSensorDataCounts &data);
+    void getAxis(MotionSensorDataUnits &data);
+    void readRegs(int addr, uint8_t * data, int len);
+  
 private:
   I2C m_i2c;
-  int m_addr;
-  void readRegs(int addr, uint8_t * data, int len);
+  char m_addr;
+  int16_t getAccAxis(uint8_t addr);
   void writeRegs(uint8_t * data, int len);
-  int16_t getAccAxis(uint8_t addr);
+
 
 };