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
Diff: sd.cpp
- Revision:
- 2:bcd60a69583f
- Parent:
- 0:77857a36b4ff
--- a/sd.cpp Fri Mar 27 08:40:00 2015 +0000 +++ b/sd.cpp Thu Apr 02 20:09:44 2015 +0000 @@ -1,9 +1,13 @@ #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); @@ -14,25 +18,37 @@ double la = 12345.67; int sd_append(char* CSVOutput) { - printf("Initializing \n"); - wait(2); + + 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"); - printf("Could not open file\n"); + D(printf("Could not open file\n")); + return -1; } +*/ - - printf("\r\nAppending data to the sd card \r\n"); + D(printf("Appending data to the sd card \r\n")); fp = fopen("/sd/metaData.csv", "a"); if (fp == NULL) { - printf("Unable to write the file \r\n"); + D(printf("Unable to write the file \r\n")); } else { fprintf(fp, "%s", CSVOutput); fclose(fp); - printf("File successfully written! \r\n"); + D(printf("File successfully written! \r\n")); + return -1; } /*