A set of data recording functions to locally store data in a circular buffer, with functions for offloading to an SD Card when convenient. dataRecorderr.h shows accessible functions to the main program - all direct SD operations are abstracted away by the library. When using this library, #include dataRecorder.h

Dependencies:   sd-driver_compatible_with_MAX32630FTHR

Fork of CircularBufferSDCardLib by Daniel Levine

Revision:
1:45627bbdeb69
Parent:
0:ebe71c7e7854
Child:
2:c2cfb0ebc3bd
--- a/sdCardReader.h	Tue Apr 03 21:50:25 2018 +0000
+++ b/sdCardReader.h	Tue Apr 03 22:41:46 2018 -0400
@@ -6,6 +6,7 @@
 #include "vector"
 #include <errno.h>
 #include "HeapBlockDevice.h"
+#include "platform/CircularBuffer.h"
 
 // File systems
 //#include "LittleFileSystem.h"
@@ -13,24 +14,25 @@
 
 class SDCardReader : public SDBlockDevice{
     public:
-        SDCardReader(PinName a=MBED_CONF_SD_SPI_MOSI, PinName b=MBED_CONF_SD_SPI_MISO, PinName c=MBED_CONF_SD_SPI_CLK, PinName d=MBED_CONF_SD_SPI_CS):SDBlockDevice(a, b, c, d){
-            };
-        
-        //static SDBlockDevice m_sd(MBED_CONF_SD_SPI_MOSI, MBED_CONF_SD_SPI_MISO, MBED_CONF_SD_SPI_CLK, MBED_CONF_SD_SPI_CS);
-        //SDBlockDevice* m_sd;//(MBED_CONF_SD_SPI_MOSI, MBED_CONF_SD_SPI_MISO, MBED_CONF_SD_SPI_CLK, MBED_CONF_SD_SPI_CS);
-        
-        // File system declaration
-        FATFileSystem fs("fs");
-        
-        int writeBlock(uint8_t* blockToWrite, int dataLength);        
-        int writeData(string title, string dataToWrite);
-        
-        int writeFile(string filename); 
-        int eraseData();
-        //string readData();       
+        SDCardReader(PinName a=MBED_CONF_SD_SPI_MOSI, PinName b=MBED_CONF_SD_SPI_MISO, PinName c=MBED_CONF_SD_SPI_CLK, PinName d=MBED_CONF_SD_SPI_CS):SDBlockDevice(a, b, c, d){};
+        	
+  	FILE* openFile(string filename);
+	void closeFile(FILE* fileToClose);
+
+	int writeDataPoint(int index, uint32_t timestamp, uint16_t* data);
+	int eraseData();
+
+	int fullWriteProcedure(string filename,int* indexArr, uint32_t* timeArr, uint16_t** allData);
+		
+	void mountFileSystem();
+	void unmountFileSystem();
+	
     private:
-        FILE * mountFileSystem();
-        
-    
-        uint8_t block[512]; // block of data;
+
+	void write_uint16_t(uint16_t data, bool endline, FILE* fileToUse);
+	void write_uint32_t(uint32_t data, bool endline, FILE* fileToUse);
+
+
+	// Define file system
+        FATFileSystem m_fs("fs");
 };