example code to get data from internal accelerometer of FRDM-K64

Dependencies:   FXOS8700CQ mbed

Files at this revision

API Documentation at this revision

Comitter:
JalilChavez
Date:
Sat Oct 11 21:01:25 2014 +0000
Commit message:
First revision of accelerometer library

Changed in this revision

FXOS8700CQ.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/FXOS8700CQ.lib	Sat Oct 11 21:01:25 2014 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/trm/code/FXOS8700CQ/#e2fe752b881e
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Sat Oct 11 21:01:25 2014 +0000
@@ -0,0 +1,37 @@
+#include "mbed.h"
+#include "FXOS8700CQ.h"
+ 
+FXOS8700CQ IMU( PTE25 /*SDA*/,
+                PTE24 /*SCL*/,
+                FXOS8700CQ_SLAVE_ADDR1/*ADDRESS*/
+               );
+ 
+//Temrinal enable
+Serial pc(USBTX, USBRX);
+ 
+SRAWDATA acc_data;
+SRAWDATA mag_data;
+ 
+ 
+int main()
+{
+    uint8_t u8Status = 0;
+    pc.baud(115200);
+    IMU.enable();
+    pc.printf("\r\n\nFXOS8700Q Who Am I= %X\r\n", IMU.get_whoami());
+ 
+    while (true)
+    {
+        u8Status = IMU.get_data(&acc_data,&mag_data);
+        if( u8Status == 0 )
+        {
+            pc.printf("ACC: X=%i Y=%i Z=%i  \r", acc_data.x, acc_data.y, acc_data.z);
+            pc.printf("MAG: X=%d Y=%d Z=%d  \r\n", mag_data.x, mag_data.y, mag_data.z);
+        }
+        else
+        {
+            pc.printf("COMMUNICATION UNSUCCESSFUL!!!!\r\n");
+        }
+        wait(0.1);
+    }
+}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Sat Oct 11 21:01:25 2014 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/9327015d4013
\ No newline at end of file