Fork of trm's FXOS8700CQ library

Dependents:   co657_lcdplay

Fork of FXOS8700CQ by Thomas Murphy

Revision:
5:f27f2c5dc320
Parent:
4:e2fe752b881e
--- a/FXOS8700CQ.h	Tue Jun 03 19:02:19 2014 +0000
+++ b/FXOS8700CQ.h	Fri Nov 20 12:31:26 2015 +0000
@@ -100,13 +100,18 @@
 // For processing the accelerometer data to right-justified 2's complement
 #define UINT14_MAX 16383
 
-// TODO: struct to hold the data out of the sensor
-typedef struct {
-    int16_t x;
-    int16_t y;
-    int16_t z;
-} SRAWDATA;
 
+typedef union {
+    struct {
+        int16_t acc_x;
+        int16_t acc_y;
+        int16_t acc_z;
+        int16_t mag_x;
+        int16_t mag_y;
+        int16_t mag_z;
+    } __attribute__ ((packed)) s;
+    int16_t v[6];
+} FXOSData_t;
 
 /**
 * A driver on top of mbed-I2C to operate the FXOS8700CQ accelerometer/magnetometer
@@ -124,26 +129,26 @@
     * @param sdl SCL pin
     * @param addr address of the I2C peripheral in (7-bit << 1) form
     */
-    FXOS8700CQ(PinName sda, PinName scl, int addr);
+    FXOS8700CQ (PinName sda, PinName scl, int addr);
 
     /**
     * FXOS8700CQ destructor
     */
-    ~FXOS8700CQ(void);
+    ~FXOS8700CQ (void);
 
-    void enable(void);
-    void disable(void);
+    void enable (void);
+    void disable (void);
 
     /**
     * @return the contents of device register FXOS8700CQ_WHOAMI 0x0D,
     * should be FXOS8700CQ_WHOAMI_VAL 0xC7
     */
-    uint8_t get_whoami(void);
+    uint8_t get_whoami (void);
     
     /**
     * @return the contents of device register FXOS8700CQ_STATUS 0x00
     */
-    uint8_t status(void);
+    uint8_t status (void);
 
     /**
     * Data retrieval from the FXOS8700CQ
@@ -152,14 +157,14 @@
     * @param magn_data destination XYZ magnetometer data struct
     * @return 0 on success, non-zero on failure
     */
-    uint8_t get_data(SRAWDATA *accel_data, SRAWDATA *magn_data);
+    uint8_t get_data (FXOSData_t *data);
 
     /**
     * Retrieve the full-range scale value of the accelerometer
     *
     * @return 2, 4, or 8, depending on part configuration; 0 on error
     */
-    uint8_t get_accel_scale(void);
+    uint8_t get_accel_scale (void);