asdf

Dependencies:   SDFileSystem mbed

Fork of All_Combined_Real by JanPaul Bergeson

Committer:
jphbergeson
Date:
Thu Mar 10 17:27:10 2016 +0000
Revision:
0:26713d1db198
Child:
1:5fa445bd14a6
Working w/ led flashing

Who changed what in which revision?

UserRevisionLine numberNew contents of line
jphbergeson 0:26713d1db198 1 #include "mbed.h"
jphbergeson 0:26713d1db198 2 #include "nmea.h"
jphbergeson 0:26713d1db198 3 #include "SDFileSystem.h"
jphbergeson 0:26713d1db198 4
jphbergeson 0:26713d1db198 5 #define BUF_SIZE 1024
jphbergeson 0:26713d1db198 6
jphbergeson 0:26713d1db198 7 DigitalOut gpo(D0);
jphbergeson 0:26713d1db198 8 DigitalOut led(LED_RED);
jphbergeson 0:26713d1db198 9
jphbergeson 0:26713d1db198 10 Serial duino(PTC4, PTC3);
jphbergeson 0:26713d1db198 11 Serial pc(USBTX, USBRX);
jphbergeson 0:26713d1db198 12
jphbergeson 0:26713d1db198 13 /**************************************************
jphbergeson 0:26713d1db198 14 ** SD FILE SYSTEM **
jphbergeson 0:26713d1db198 15 **************************************************/
jphbergeson 0:26713d1db198 16 SDFileSystem sd(PTE3, PTE1, PTE2, PTE4, "sd");
jphbergeson 0:26713d1db198 17 FILE *fpData;
jphbergeson 0:26713d1db198 18
jphbergeson 0:26713d1db198 19 int main()
jphbergeson 0:26713d1db198 20 {
jphbergeson 0:26713d1db198 21 pc.baud(115200); // make sure to set computer TERA Term or whatever to 115200 baud!!!
jphbergeson 0:26713d1db198 22 duino.baud(9600);
jphbergeson 0:26713d1db198 23 pc.printf("Initializing ...\r\n");
jphbergeson 0:26713d1db198 24 char buffer[BUF_SIZE];
jphbergeson 0:26713d1db198 25
jphbergeson 0:26713d1db198 26 while (true) {
jphbergeson 0:26713d1db198 27
jphbergeson 0:26713d1db198 28 led = !led;
jphbergeson 0:26713d1db198 29
jphbergeson 0:26713d1db198 30 get_nmea(&duino, buffer, BUF_SIZE);
jphbergeson 0:26713d1db198 31
jphbergeson 0:26713d1db198 32 struct NMEA_data nmea = parse_line(buffer);
jphbergeson 0:26713d1db198 33
jphbergeson 0:26713d1db198 34 // determine whether there's a lock
jphbergeson 0:26713d1db198 35 char lock_str[BUF_SIZE];
jphbergeson 0:26713d1db198 36 if ( nmea.lock_flag == 'A' )
jphbergeson 0:26713d1db198 37 sprintf(lock_str, "Has lock");
jphbergeson 0:26713d1db198 38 else
jphbergeson 0:26713d1db198 39 sprintf(lock_str, "No lock");
jphbergeson 0:26713d1db198 40
jphbergeson 0:26713d1db198 41 // assemble data into summary string
jphbergeson 0:26713d1db198 42 char status_str[BUF_SIZE];
jphbergeson 0:26713d1db198 43 sprintf(status_str, "%02d:%02d:%02d, %d/%d/%d, %dd %lf' %c %dd %lf' %c, %s\r\n",
jphbergeson 0:26713d1db198 44 nmea.hours, nmea.minutes, nmea.seconds,
jphbergeson 0:26713d1db198 45 nmea.month, nmea.day, nmea.year,
jphbergeson 0:26713d1db198 46 nmea.latitude, nmea.latitude_minutes, nmea.latitude_direction,
jphbergeson 0:26713d1db198 47 nmea.longitude, nmea.longitude_minutes, nmea.longitude_direction, lock_str);
jphbergeson 0:26713d1db198 48
jphbergeson 0:26713d1db198 49 // print to pc, sd card
jphbergeson 0:26713d1db198 50 pc.printf("%s", status_str);
jphbergeson 0:26713d1db198 51
jphbergeson 0:26713d1db198 52 fpData = fopen("/sd/data.txt", "a");
jphbergeson 0:26713d1db198 53 fprintf(fpData, "%s", status_str);
jphbergeson 0:26713d1db198 54 fclose(fpData);
jphbergeson 0:26713d1db198 55 wait(0.5f);
jphbergeson 0:26713d1db198 56 }
jphbergeson 0:26713d1db198 57 }