Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: MMA8451Q_tb SDFileSystem mbed
Fork of StepLogger by
Revision 0:75c161b9fc38, committed 2014-04-30
- Comitter:
- donoman
- Date:
- Wed Apr 30 00:44:56 2014 +0000
- Child:
- 1:03f0a25c5a86
- Commit message:
- First pass at datalogger --- still problems when writing to SD card due to buffer full causing delay.;
Changed in this revision
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/MMA8451Q_tb.lib Wed Apr 30 00:44:56 2014 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/tim_b/code/MMA8451Q_tb/#c6db5b21ad79
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/SDFileSystem.lib Wed Apr 30 00:44:56 2014 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/SDFileSystem/#7b35d1709458
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp Wed Apr 30 00:44:56 2014 +0000
@@ -0,0 +1,38 @@
+#include "mbed.h"
+#include "MMA8451Q_tb.h"
+#include "SDFileSystem.h"
+
+
+#define MMA8451_I2C_ADDRESS (0x1d<<1)
+float acc_all[3];
+DigitalOut pinout(PTD4);
+Timer timer;
+Serial pc(USBTX, USBRX);
+SDFileSystem sd(PTD2, PTD3, PTD1, PTD0, "sd"); // (mosi, miso, sclok, cs, name)
+
+int main(void) {
+
+//Initialize
+ int now; //used for timestamping
+ timer.start();
+ MMA8451Q acc(PTE25, PTE24, MMA8451_I2C_ADDRESS);
+ printf("MMA8451 ID: %d\n", acc.getWhoAmI());
+
+//Open File
+ mkdir("/sd/mydir", 0777);
+ FILE *fp = fopen("/sd/mydir/sdtest.txt", "a");
+ if(fp == NULL) {
+ error("Could not open file for write\n");
+ }
+
+ for(int i=0; i<2000; i++) {
+ pinout = !pinout;
+ now = timer.read_ms();
+ acc.fastRead(&acc_all[0]);
+
+ //Print to file
+ fprintf(fp, "%d, %f,%f,%f\n",now, acc_all[0],acc_all[1],acc_all[2]);
+
+ }
+ fclose(fp);
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Wed Apr 30 00:44:56 2014 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed/builds/8e73be2a2ac1 \ No newline at end of file
