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
sdCardReader.h
00001 #include "mbed.h" 00002 #include "SDBlockDevice.h" 00003 #include "iostream" 00004 #include "stdio.h" 00005 #include "string" 00006 #include "vector" 00007 #include <errno.h> 00008 #include "HeapBlockDevice.h" 00009 #include "platform/CircularBuffer.h" 00010 00011 //For saving funny int formats 00012 #include <inttypes.h> 00013 00014 // File systems 00015 //#include "LittleFileSystem.h" 00016 #include "FATFileSystem.h" 00017 00018 class SDCardReader:public SDBlockDevice{ 00019 public: 00020 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){ 00021 m_fs = new FATFileSystem("fs"); 00022 }; 00023 00024 FILE* openFile(string filename); 00025 void closeFile(FILE* fileToClose); 00026 00027 int writeDataPoint(FILE* theFile, int index, uint32_t timestamp, vector<uint16_t> data); 00028 int eraseData(); 00029 00030 int fullWriteProcedure(string filename,vector<int> indexArr, vector<uint32_t> timeArr, vector<vector <uint16_t> > allData); 00031 00032 void mountFileSystem(); 00033 void unmountFileSystem(); 00034 00035 00036 //Read and increment for keeping track of SDcard files 00037 //Each file gets a new number 00038 int readAndIncrement(string filename); 00039 00040 00041 private: 00042 00043 void write_uint16_t(uint16_t data, bool endline, FILE* fileToUse); 00044 void write_uint32_t(uint32_t data, bool endline, FILE* fileToUse); 00045 00046 // Define file system 00047 FATFileSystem* m_fs; 00048 };
Generated on Fri Jul 15 2022 02:01:26 by 1.7.2