Code for measuring the signal with a specified length and sampling rate, and saving it on a SD card.

Dependencies:   EALib I2S mbed

Revision:
0:c05b00be2229
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/sdcard.cpp	Thu Jul 13 19:33:37 2017 +0000
@@ -0,0 +1,28 @@
+#include "sdcard.h"
+#include "MCIFileSystem.h"
+#include "mbed.h"
+#include <string>
+
+
+void saveToSD(float signal[],int sig_length,char const *filename)
+{
+
+    printf("Saving to SD card...\n");
+
+    string str_name(filename);
+
+    std::string fullname="/mci/"+str_name+".txt";
+
+    MCIFileSystem mcifs("mci", NC);
+    FILE* File = fopen(fullname.c_str(),"w"); // open file
+
+    for (int i = 0; i < sig_length; i++) {
+
+        //fprintf(File,"%f              %f                %f                 %f\r\n",acc_signal_f[i],xfilt[i],xAnalytic[i],xEnv[i]);
+        fprintf(File,"%f           \r\n",signal[i]);
+    }
+
+    fclose(File);
+    printf("Saved to SD card.\n\n");
+
+}
\ No newline at end of file