GSMA version

Dependencies:   FXOS8700CQ mbed sfh7779

Fork of StarterKit by Rick McConney

Revision:
30:48b43538e98b
Parent:
29:e6c8bd41caa6
--- a/sensors.cpp	Sat Jul 16 17:35:15 2016 +0000
+++ b/sensors.cpp	Wed Jul 20 04:01:03 2016 +0000
@@ -6,12 +6,9 @@
 #define Si7020_PMOD_I2C_ADDR   0x80 //this is for 7-bit addr 0x4 for the Si7020
 
 #include "hardware.h"
-//I2C i2c(PTC11, PTC10); //SDA, SCL
 
 #include "FXOS8700CQ.h"
-// Pin names for the motion sensor FRDM-K64F board:
-FXOS8700CQ fxos(PTE25, PTE24, FXOS8700CQ_SLAVE_ADDR1); // SDA, SCL, (addr << 1)
-// Storage for the data from the sensor
+// Storage for the data from the motion sensor
 SRAWDATA accel_data;
 SRAWDATA magn_data;
 //InterruptIn fxos_int1(PTC6); // unused, common with SW2 on FRDM-K64F
@@ -20,7 +17,6 @@
 void trigger_fxos_int2(void)
 {
     fxos_int2_triggered = true;
-    //us_ellapsed = t.read_us();
 }
 
 /*------------------------------------------------------------------------------
@@ -318,8 +314,10 @@
 bool bMotionSensor_present = false;
 void init_motion_sensor()
 {
+    // Note: this class is instantiated here because if it is statically declared, the cellular shield init kills the I2C bus...
+    // Class instantiation with pin names for the motion sensor on the FRDM-K64F board:
+    FXOS8700CQ fxos(PTE25, PTE24, FXOS8700CQ_SLAVE_ADDR1); // SDA, SCL, (addr << 1)
     int iWhoAmI = fxos.get_whoami();
-    
     printf("FXOS8700CQ WhoAmI = %X\r\n", iWhoAmI);
     // Iterrupt for active-low interrupt line from FXOS
     // Configured with only one interrupt on INT2 signaling Data-Ready
@@ -338,8 +336,12 @@
 
 void read_motion_sensor()
 {
+    // Note: this class is instantiated here because if it is statically declared, the cellular shield init kills the I2C bus...
+    // Class instantiation with pin names for the motion sensor on the FRDM-K64F board:
+    FXOS8700CQ fxos(PTE25, PTE24, FXOS8700CQ_SLAVE_ADDR1); // SDA, SCL, (addr << 1)
     if (bMotionSensor_present)
     {
+        fxos.enable();
         fxos.get_data(&accel_data, &magn_data);
         //printf("Roll=%5d, Pitch=%5d, Yaw=%5d;\r\n", magn_data.x, magn_data.y, magn_data.z);
         sprintf(SENSOR_DATA.MagnetometerX, "%5d", magn_data.x);