Rev 0.1 Simple operation of just X, Y, Z values in floating point G's

Dependents:   Hello_FXLS8471Q Multi-Sensor sensor AerCloud_MutliTech_Socket_Modem_Example ... more

Files at this revision

API Documentation at this revision

Comitter:
screamer
Date:
Mon Jun 02 17:14:15 2014 +0000
Parent:
1:c80be04510fe
Child:
3:b1fd3a2572e2
Commit message:
Updated documentation (now visible)

Changed in this revision

FXLS8471Q.cpp Show annotated file Show diff for this revision Revisions of this file
FXLS8471Q.h Show annotated file Show diff for this revision Revisions of this file
--- a/FXLS8471Q.cpp	Sat Apr 19 01:26:12 2014 +0000
+++ b/FXLS8471Q.cpp	Mon Jun 02 17:14:15 2014 +0000
@@ -17,17 +17,16 @@
 */
 
 
- #include "FXLS8471Q.h"
- #define UINT14_MAX        16383
- 
-FXLS8471Q::FXLS8471Q(PinName mosi, PinName miso, PinName sck, PinName cs) : _spi(mosi, miso, sck), _spi_cs(cs) {
+#include "FXLS8471Q.h"
+#define UINT14_MAX        16383
+
+FXLS8471Q::FXLS8471Q(PinName mosi, PinName miso, PinName sck, PinName cs) : _spi(mosi, miso, sck), _spi_cs(cs)
+{
     _spi_cs = 1;
     wait(0.1);
     begin();
 }
-    
 
-    
 void FXLS8471Q::RegWrite( int reg, int *d, int len)
 {
     int ob[2];
@@ -40,7 +39,7 @@
     while(c < len) _spi.write(d[c++]);
     _spi_cs = 1;
 }
-   
+
 void FXLS8471Q::RegRead( int reg, int *d, int len)
 {
     int ob[2];
@@ -91,27 +90,27 @@
     // [1]: f_read=0 for normal 16 bit reads
     // [0]: active=1 to take the part out of standby and enable sampling
     databyte = 0x15;
-    RegWrite(FXLS8471Q_CTRL_REG1, &databyte, 1); 
+    RegWrite(FXLS8471Q_CTRL_REG1, &databyte, 1);
 }
 
 void FXLS8471Q::ReadXYZ(float * fdata)
 {
-int raw[7];
-int16_t ix, iy, iz;
-RegRead(FXLS8471Q_STATUS, raw, 7);
+    int raw[7];
+    int16_t ix, iy, iz;
+    RegRead(FXLS8471Q_STATUS, raw, 7);
 
-ix = ((raw[1] * 256) + raw[2]);// / 4;
-iy = ((raw[3] * 256) + raw[4]);// / 4;
-iz = ((raw[5] * 256) + raw[6]);// / 4;
-fdata[0] = ((float) ix) / 16384.0;
-fdata[1] = ((float) iy) / 16384.0;
-fdata[2] = ((float) iz) / 16384.0;
+    ix = ((raw[1] * 256) + raw[2]);// / 4;
+    iy = ((raw[3] * 256) + raw[4]);// / 4;
+    iz = ((raw[5] * 256) + raw[6]);// / 4;
+    fdata[0] = ((float) ix) / 16384.0;
+    fdata[1] = ((float) iy) / 16384.0;
+    fdata[2] = ((float) iz) / 16384.0;
 }
 
 void FXLS8471Q::ReadXYZraw(int16_t * d)
 {
-int res[6];
-int16_t acc;
+    int res[6];
+    int16_t acc;
     RegRead(FXLS8471Q_OUT_X_MSB, res, 6);
 
     acc = (res[0] << 6) | (res[1] >> 2);
@@ -127,5 +126,4 @@
         acc -= UINT14_MAX;
     d[2] = acc;
 }
-  
-   
\ No newline at end of file
+
--- a/FXLS8471Q.h	Sat Apr 19 01:26:12 2014 +0000
+++ b/FXLS8471Q.h	Mon Jun 02 17:14:15 2014 +0000
@@ -31,51 +31,52 @@
 #define FXLS8471Q_CTRL_REG1 0x2A
 #define FXLS8471Q_WHOAMI_VAL 0x6A
 
+/**
+ * FXLS8471Q Xtrinsic accelerometer on SPI
+ */
 class FXLS8471Q
 {
 public:
-  /**
-  * FXOS8700Q constructor
-  *
-  * @param mosi MOSI pin
-  * @param miso MISO pin
-  * @param scl  SCL  pin
-  * @param cs   Device Chip Select pin
-  */
-FXLS8471Q(PinName mosi, PinName miso, PinName scl, PinName cs);
+    /**
+    * FXLS8471Q constructor
+    *
+    * @param mosi MOSI pin
+    * @param miso MISO pin
+    * @param scl  SCL  pin
+    * @param cs   Device Chip Select pin
+    */
+    FXLS8471Q(PinName mosi, PinName miso, PinName scl, PinName cs);
 
 
-  /**
-   * Get XYZ axis acceleration in G's
-   *
-   * @param res array where acceleration data will be stored
-   */
-void ReadXYZ(float * a);
-  
-  /**
-   * Get XYZ axis acceleration, signed 16 bit values
-   *
-   * @param res array where acceleration data will be stored
-   */
-void ReadXYZraw(int16_t * d);
+    /**
+     * Get XYZ axis acceleration in G's
+     *
+     * @param res array where acceleration data will be stored
+     */
+    void ReadXYZ(float * a);
 
-  /**
-   * Get the value of the WHO_AM_I register
-   *
-   * @returns WHO_AM_I value
-   */
-char getWhoAmI(void);
-      
+    /**
+     * Get XYZ axis acceleration, signed 16 bit values
+     *
+     * @param res array where acceleration data will be stored
+     */
+    void ReadXYZraw(int16_t * d);
+
+    /**
+     * Get the value of the WHO_AM_I register
+     *
+     * @returns WHO_AM_I value
+     */
+    char getWhoAmI(void);
+
 private:
 
     SPI _spi;
     DigitalOut _spi_cs;
 
     void begin( void);
-    void RegWrite( int reg, int * d, int len);    
+    void RegWrite( int reg, int * d, int len);
     void RegRead( int reg, int * d, int len);
-
-
 };
 
 #endif