![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
K64F based data logger for GPS (ublox MAX M8Q) & 6 Axis Sensor (FXOS8700Q) - Outputs to SD + UDP - Uses FRDM K64F + ublox "Cellular and positioning shield" (3G version)
Dependencies: MAX_M8Q_Capture EthernetInterface FXOS8700Q SDFileSystem eCompass_FPU_Lib mbed-rtos mbed
sd.cpp
- Committer:
- rlinnmoran
- Date:
- 2015-05-20
- Revision:
- 3:6085916c9d74
- Parent:
- 2:bcd60a69583f
File content as of revision 3:6085916c9d74:
#include "mbed.h" #include "SDFileSystem.h" #include "debug.h" //#include "main.h" int sd_append(char*); DigitalIn sdDetect(PTE6,PullDown); // SD Detect Pin SDFileSystem sd(PTE3, PTE1, PTE2, PTE4, "sd"); // MOSI, MISO, SCK, CS FILE *fp; //Serial pc(USBTX, USBRX); char buffer[1024]; double utc = 123456.34; double mg = 123.4; double la = 12345.67; int sd_append(char* CSVOutput) { D(printf("Booting... SD Preset?=%d\r\n",sdDetect.read())); // Test to see if SD card is present, if not return. if (sdDetect == NULL){ D(printf("No SD card present\r\n")); return -1; } D(printf("Initializing \r\n")); /* fp = fopen("/sd/metaData.csv", "r"); if (fp != NULL) { fclose(fp); //remove("/sd/hello.txt"); D(printf("Could not open file\n")); return -1; } */ D(printf("Appending data to the sd card \r\n")); fp = fopen("/sd/metaData.csv", "a"); if (fp == NULL) { D(printf("Unable to write the file \r\n")); } else { fprintf(fp, "%s", CSVOutput); fclose(fp); D(printf("File successfully written! \r\n")); return -1; } /* printf("\nReading data from the SD card. \r\n"); fp = fopen("/sd/metaData.csv", "r"); if (fp != NULL) { int size = fread(buffer, sizeof(char), 1024, fp); printf("Number of data read: %d, text from hello.txt file: %s \r\n", size, buffer); fclose(fp); } //printf("End of Lab 4. \n"); */ return 0; }