A basic library for the FXOS8700Q combination accelerometer / magnetometer

Dependencies:   MotionSensor

Dependents:   K64F_eCompass_LCD Hello_FXOS8700Q rtos_compass K64F_eCompass ... more

This library supports the 6 axis combination Accelerometer / Magnetometer. Functions are provided to retrieve data in raw 16 bit signed integers or unit converted G's and micro-teslas

Revision:
0:2562215f5bc0
Child:
1:8b53edef272f
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/FXOS8700Q.h	Mon Apr 07 00:58:50 2014 +0000
@@ -0,0 +1,65 @@
+#ifndef FXOS8700Q_H
+#define FXOS8700Q_H
+
+#include "mbed.h"
+// FXOS8700CQ I2C address
+#define FXOS8700CQ_SLAVE_ADDR 0x3C // with pins SA0=0, SA1=0
+
+// FXOS8700CQ internal register addresses
+#define FXOS8700CQ_STATUS 0x00
+#define FXOS8700CQ_WHOAMI 0x0D
+#define FXOS8700CQ_XYZ_DATA_CFG 0x0E
+#define FXOS8700CQ_CTRL_REG1 0x2A
+#define FXOS8700CQ_M_CTRL_REG1 0x5B
+#define FXOS8700CQ_M_CTRL_REG2 0x5C
+#define FXOS8700CQ_WHOAMI_VAL 0xC7
+
+class FXOS8700Q
+{
+public:
+    /**
+    * MPL3115A2 constructor
+    *
+    * @param sda SDA pin
+    * @param sdl SCL pin
+    * @param addr addr of the I2C peripheral
+    */
+    FXOS8700Q(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, float * m);
+      
+
+private:
+
+    I2C _i2c;
+    /** Set the device in active mode
+    */
+    void begin( void);
+    
+    void RegRead( char reg, char * d, int len);
+
+
+};
+
+#endif