This is an example program for the Freescale multi-sensor shield, part number FRDM-FXS-MULTI

Dependencies:   FXAS21000 FXLS8471Q FXOS8700Q MAG3110 MMA8652 MPL3115A2 mbed

Files at this revision

API Documentation at this revision

Comitter:
JimCarver
Date:
Sat Apr 19 01:30:29 2014 +0000
Child:
1:d3ecb4ecdfda
Commit message:
This is an example program for the Freescale Multi sensor shield using the provided sensors: FXAS21000, FXLA8471, FXOS8700, MAG3110, MMA8652 and MPL3115;

Changed in this revision

FXAS21000.lib Show annotated file Show diff for this revision Revisions of this file
FXLS8471Q.lib Show annotated file Show diff for this revision Revisions of this file
FXOS8700Q.lib Show annotated file Show diff for this revision Revisions of this file
MAG3110.lib Show annotated file Show diff for this revision Revisions of this file
MMA8652.lib Show annotated file Show diff for this revision Revisions of this file
MPL3115A2.lib Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/FXAS21000.lib	Sat Apr 19 01:30:29 2014 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/JimCarver/code/FXAS21000/#88a036a417bf
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/FXLS8471Q.lib	Sat Apr 19 01:30:29 2014 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/JimCarver/code/FXLS8471Q/#c80be04510fe
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/FXOS8700Q.lib	Sat Apr 19 01:30:29 2014 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/JimCarver/code/FXOS8700Q/#be6abf9f2d59
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/MAG3110.lib	Sat Apr 19 01:30:29 2014 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/JimCarver/code/MAG3110/#f3abe901c33a
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/MMA8652.lib	Sat Apr 19 01:30:29 2014 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/JimCarver/code/MMA8652/#ff30cc4759b4
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/MPL3115A2.lib	Sat Apr 19 01:30:29 2014 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/clemente/code/MPL3115A2/#82ac06669316
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Sat Apr 19 01:30:29 2014 +0000
@@ -0,0 +1,117 @@
+#include "mbed.h"
+#include "MAG3110.h"
+#include "MPL3115A2.h"
+#include "FXOS8700Q.h"
+#include "MMA8652.h"
+#include "FXLS8471Q.h"
+#include "FXAS21000.h"
+
+#define MPL3115A2_I2C_ADDRESS (0x60<<1)
+
+
+DigitalOut  red(LED_RED);
+
+MAG3110   mag1(A4, A5);
+MAG3110   mag2(PTE25, PTE24); // Magnetometer on KL46 board
+
+FXLS8471Q acc1(D11, D12, D13, D10);
+MMA8652   acc2( A4, A5);
+MPL3115A2 alt( A4, A5, MPL3115A2_I2C_ADDRESS);
+FXOS8700Q combo( A4, A5, FXOS8700CQ_SLAVE_ADDR0);
+FXAS21000 gyro( A4, A5);
+
+Serial pc(USBTX, USBRX);
+
+
+
+float print_AltimiterValue( unsigned char *dt)
+{
+    unsigned short altm;
+    float faltm;
+
+    /*
+    * dt[0] = Bits 12-19 of 20-bit real-time Altitude sample. (b7-b0)
+    * dt[1] = Bits 4-11 of 20-bit real-time Altitude sample. (b7-b0)
+    * dt[2] = Bits 0-3 of 20-bit real-time Altitude sample (b7-b4)
+    */    
+    altm = (dt[0]<<8) | dt[1];
+    //
+    if ( dt[0] > 0x7F) {
+        altm = ~altm + 1;
+        faltm = (float)altm * -1.0f;
+    } else {
+        faltm = (float)altm * 1.0f;
+    }
+    //
+    faltm = faltm+((float)(dt[2]>>4) * 0.0625f);
+    return faltm;
+}
+
+float print_TemperatureValue( unsigned char *dt)
+{
+    unsigned short temp;
+    float ftemp;
+    
+    /*
+    * dt[0] = Bits 4-11 of 16-bit real-time temperature sample. (b7-b0)
+    * dt[1] = Bits 0-3 of 16-bit real-time temperature sample. (b7-b4)
+    */
+    temp = dt[0];
+    //
+    if ( dt[0] > 0x7F) {
+        temp = ~temp + 1;
+        ftemp = (float)temp * -1.0f;
+    } else {
+        ftemp = (float)temp * 1.0f;
+    }
+    //
+    ftemp = ftemp+((float)(dt[1]>>4) * 0.0625f);
+    return ftemp;
+
+}
+
+
+int main() {
+    //int who;
+    float acc_data[3], mag_data[3], gyro_data[3];
+    int16_t acc_raw[3];
+    unsigned char raw_data[8];
+    pc.baud(115200);
+    red = 1;
+    printf("\r\n\r\n\r\n");
+    alt.Altimeter_Mode();
+    printf("MMA8652   Who Am I= %X\r\n", acc2.getWhoAmI());
+    printf("FXOS8700  Who Am I= %X\r\n", combo.getWhoAmI());
+    printf("FXLS8471  Who Am I= %X\r\n", acc1.getWhoAmI());
+    printf("FXAS21000 Who Am I= %X\r\n", gyro.getWhoAmI());
+    wait(5.0);
+    while(1) {
+
+        acc1.ReadXYZ(acc_data);
+        printf("FXLS8471      X=%1.5f Y=%1.5f Z=%1.5f\r\n", acc_data[0], acc_data[1], acc_data[2]);
+        acc2.ReadXYZ(acc_data);
+        printf("MMA8652       X=%1.5f Y=%1.5f Z=%1.5f\r\n", acc_data[0], acc_data[1], acc_data[2]);        
+        combo.getAccAllAxis( acc_data);
+        combo.getMagAllAxis( mag_data);
+        printf("FXOS8700 Acc: X=%1.5f Y=%1.5f Z=%1.5f", acc_data[0], acc_data[1], acc_data[2]);
+        printf(" Mag: X=%4.1f Y=%4.1f Z=%4.1f\r\n", mag_data[0], mag_data[1], mag_data[2]);
+        mag1.ReadXYZ(mag_data);
+        printf("                                            ");
+        printf(" Mag1: X=%4.1f Y=%4.1f Z=%4.1f\r\n", mag_data[0], mag_data[1], mag_data[2]);
+        mag2.ReadXYZ(mag_data);
+        printf("                                            ");
+        printf(" Mag2: X=%4.1f Y=%4.1f Z=%4.1f\r\n", mag_data[0], mag_data[1], mag_data[2]);
+        alt.getAllDataRaw( &raw_data[0]);
+        printf("\r\nAlt: %5.1f\tT: %3.1f\r\n", print_AltimiterValue( &raw_data[0]), print_TemperatureValue( &raw_data[3]));
+        gyro.ReadXYZ(gyro_data);
+        printf("FXAS21000      X=%4.2f Y=%4.2f Z=%4.1f\r\n", gyro_data[0], gyro_data[1], gyro_data[2]);
+        acc1.ReadXYZraw(acc_raw);
+        printf("FXLS8471: X= %d Y= %d Z= %d\r\n\n\n", acc_raw[0], acc_raw[1], acc_raw[2]);
+        acc2.ReadXYZraw(acc_raw);
+        printf("MMA8652: X= %d Y= %d Z= %d\r\n\n\n", acc_raw[0], acc_raw[1], acc_raw[2]);
+        red = 1;
+        wait(0.5);
+        red = 0;
+        wait(0.5);
+        }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Sat Apr 19 01:30:29 2014 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/8e73be2a2ac1
\ No newline at end of file