Generation 3 of the Harp project

Dependencies:   Servo TMP36 GZ buffered-serial1 chan_fatfs_sd nmea_parser watchdog mbed-rtos mbed

Fork of HARP2 by Tyler Weaver

Files at this revision

API Documentation at this revision

Comitter:
tylerjw
Date:
Tue Dec 11 06:46:11 2012 +0000
Parent:
10:b13416bbb4cd
Child:
12:0d943d69d3ec
Commit message:
working writing to 2gb micro sd card with by open, write line, close file, repeat...

Changed in this revision

SDFileSystem.lib Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/SDFileSystem.lib	Tue Dec 11 06:46:11 2012 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/SDFileSystem/#c8f66dc765d4
--- a/main.cpp	Tue Dec 11 00:27:45 2012 +0000
+++ b/main.cpp	Tue Dec 11 06:46:11 2012 +0000
@@ -1,6 +1,9 @@
 #include "mbed.h"
 #include "rtos.h"
 #include "buffered_serial.h"
+#include "SDFileSystem.h"
+ 
+SDFileSystem sd(p5, p6, p7, p8, "sd"); 
 
 #define CELLS       3.0
 #define LIPO_EMPTY  3.4
@@ -22,11 +25,18 @@
     DigitalOut gps_led(LED4);
 
     gps.baud(4800);
+    mkdir("/sd/hab", 0777);
+    FILE *fp = fopen("/sd/hab/gps.txt", "a");
+    fputs("--- new log --- \r\n", fp);
+    fclose(fp);
 
     while(true) {
+        fp = fopen("/sd/hab/gps.txt", "a");
         gps.read_line(buffer);
         gps_led = !gps_led;
         //pc.puts(buffer);
+        fputs(buffer, fp);
+        fclose(fp);
     }
 }
 
@@ -34,7 +44,7 @@
 {
     pc.baud(9600);
     Thread thread(gps_thread, NULL, osPriorityHigh);
-
+    
     while(true) {
         float sample = gps_battery.read();
         pc.printf("Sample: %f Volts\r\n", sample*3.3);
@@ -42,7 +52,6 @@
         pc.printf("Battery Voltage: %f Volts\r\n", voltage);
         float level = (voltage-BAT_EMPTY) / (BAT_RANGE);
         pc.printf("Battery Level: %f \r\n", level);
-        
         Thread::wait(1000);
     }
 }
\ No newline at end of file