Simple accelerometer and magnetometer program example for Hexiwear featuring UART

Dependencies:   FXOS8700

Fork of Hexi_Accelero_Magneto_Example by Hexiwear

This project demonstrates the use of the FXOS8700CQ combo Accelerometer and Magnetometer sensor embedded in hexiwear

Open a Hyperterminal tool on your computer and connect it to the "mbed Serial port (COMxx)" with Baud rate "9600bps"

Compile the project and copy the binary "Hexi_Accelero_Magneto_Example_HEXIWEAR.bin" in the DAP-LINK drive from your computer file explorer Press the K64F-RESET button on the docking station to start the program on your board

Message "Begin Data Acquisition from FXOS8700CQ sensor..." will appear in the Hyperterminal window
Then every 500ms the value of the Accelerometer and the Magnetometer for the Axis X, Y and Z plus their RMS value will be displayed in the Hyperterminal window and the LED will blink Green

Revision:
0:207337d58f96
Child:
1:6da908234299
diff -r 000000000000 -r 207337d58f96 main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Fri Aug 12 16:08:20 2016 +0000
@@ -0,0 +1,27 @@
+#include "mbed.h"
+#include "FXOS8700CQ.h"
+
+DigitalOut led1(LED1);
+
+// Pin connections & address for Hexiwear
+FXOS8700CQ fxos(PTC11, PTC10, FXOS8700CQ_SLAVE_ADDR0); // SDA, SCL, (addr << 1)
+// Storage for the data from the sensor
+SRAWDATA accel_data;
+SRAWDATA magn_data;
+
+// main() runs in its own thread in the OS
+// (note the calls to Thread::wait below for delays)
+int main() {
+    
+    fxos.enable();
+    while (true) {
+        led1 = !led1;
+        // Example data printing
+        fxos.get_data(&accel_data, &magn_data);
+        printf("A X:%5d,Y:%5d,Z:%5d   M X:%5d,Y:%5d,Z:%5d\r\n",
+                 accel_data.x, accel_data.y, accel_data.z,
+                 magn_data.x, magn_data.y, magn_data.z);
+        
+        Thread::wait(500);
+    }
+}
\ No newline at end of file