Code to send data from a FRDM-K64F development board to any board through UART.

Dependencies:   mbed FXOS8700Q

Files at this revision

API Documentation at this revision

Comitter:
saurabh2691
Date:
Sun Mar 24 06:45:18 2019 +0000
Commit message:
Code for UART connection between FRDM-K64F and S32K144 development board. Data is sent from the FRDM-K64F to the S32K144 board.

Changed in this revision

FXOS8700Q.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
diff -r 000000000000 -r 585ff5a0167f FXOS8700Q.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/FXOS8700Q.lib	Sun Mar 24 06:45:18 2019 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/JimCarver/code/FXOS8700Q/#c53dda05b8cf
diff -r 000000000000 -r 585ff5a0167f main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Sun Mar 24 06:45:18 2019 +0000
@@ -0,0 +1,51 @@
+#include "mbed.h"
+#include "FXOS8700Q.h"             // Sensor Header File
+#include "math.h"
+#include <string>
+
+FXOS8700Q_acc acc( PTE25, PTE24, FXOS8700CQ_SLAVE_ADDR1);    // Proper Ports and I2C Address for K64F Freedom board
+MotionSensorDataUnits acc_data;
+
+Serial pc(USBTX, USBRX);            // UART for Tera-Term
+Serial device(PTC17, PTC16);
+
+void updateSensor();                // Updates sensor values in "acc_data"
+
+int main()
+{
+    pc.baud(115200);
+    device.baud(115200);
+    
+    acc.enable();
+
+    while (true) {
+        updateSensor();
+        pc.printf("Current State: ");
+        
+        if (-0.1 < acc_data.x && acc_data.x < 0.1) {
+            device.printf("1");
+            pc.printf("1\n");
+        } else if (0.1 < acc_data.x && acc_data.x < 0.55) {
+            device.printf("2");
+            pc.printf("2\n");
+        } else if (0.55 < acc_data.x && acc_data.x < 1.0) {
+            device.printf("3");
+            pc.printf("3\n");
+        } else if (-0.55 < acc_data.x && acc_data.x < -0.1) {
+            device.printf("4");
+            pc.printf("4\n");
+        } else if (-1.0 < acc_data.x && acc_data.x < -0.55) {
+            device.printf("5");
+            pc.printf("5\n");
+        } else {
+            device.printf("1");
+            pc.printf("1\n");
+        }
+        wait(1);
+    }
+}
+
+void updateSensor() {
+    acc.getAxis(acc_data);
+    //pc.printf("\nACC: X=%1.4f Y=%1.4f Z=%1.4f  \n", acc_data.x, acc_data.y, acc_data.z);  // Prints current sensor values
+}
\ No newline at end of file
diff -r 000000000000 -r 585ff5a0167f mbed.bld
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Sun Mar 24 06:45:18 2019 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/users/mbed_official/code/mbed/builds/3a7713b1edbc
\ No newline at end of file