Accelerometer logger for FRDM-KL25. Use 921600bps for serial connection over USB.

Dependencies:   MMA8451Q mbed

Files at this revision

API Documentation at this revision

Comitter:
quevedo
Date:
Wed Jun 04 19:18:25 2014 +0000
Commit message:
Accelerometer logger for the FRDM-KL25 board, at a data rate of 800Hz. Please use a serial connection at 921600bps.

Changed in this revision

MMA8451Q.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
nRF24L01P.lib Show annotated file Show diff for this revision Revisions of this file
diff -r 000000000000 -r bf43b555301c MMA8451Q.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/MMA8451Q.lib	Wed Jun 04 19:18:25 2014 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/quevedo/code/MMA8451Q/#7c9ab58f6af3
diff -r 000000000000 -r bf43b555301c main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Wed Jun 04 19:18:25 2014 +0000
@@ -0,0 +1,52 @@
+#include "mbed.h"
+#include "MMA8451Q.h"
+
+// Defines for sensors I2C
+#define SDA     PTE25
+#define SCL     PTE24
+#define INT1    PTA14
+
+// Define for LED
+#define  LRED   PTC7
+
+MMA8451Q acc(SDA, SCL);
+Serial pc(USBTX, USBRX);
+Ticker t; // Periodical timer for reading sensors
+//InterruptIn drdy(INT1);
+DigitalOut myled(LRED);
+
+void newdata() {
+    int16_t accdata[3];
+    
+    myled = !myled;
+    // Reads all accelerometer and magnetometer data, and also reads analog from FSR1 and FSR2
+    acc.getAccAllAxis(accdata);
+    // Now we transmit data
+    pc.printf("%d,%d,%d\r\n", accdata[0], accdata[1], accdata[2]);
+}
+
+int main() {
+    char cmd;
+    myled = 1;
+    pc.baud(921600); // 176kbps ou mais
+    //drdy.disable_irq();
+    //drdy.fall(&newdata);
+    
+    while(1) {
+            if(pc.readable()) {
+            cmd = pc.getc();
+            if(cmd == '1') {
+                t.attach(&newdata, 0.00125); //  800Hz samples
+                //drdy.enable_irq();
+            } else if(cmd == '0') {
+                t.detach();
+                //drdy.disable_irq();
+                myled = 1;
+            } 
+        }
+    }
+}
+
+/*
+
+        */
\ No newline at end of file
diff -r 000000000000 -r bf43b555301c mbed.bld
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Wed Jun 04 19:18:25 2014 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/7d30d6019079
\ No newline at end of file
diff -r 000000000000 -r bf43b555301c nRF24L01P.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/nRF24L01P.lib	Wed Jun 04 19:18:25 2014 +0000
@@ -0,0 +1,1 @@
+nRF24L01P